r4331: Implement SAMR query_dom_info-call info-level 8 server- and client-side,
[jra/samba/.git] / source3 / include / rpc_samr.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup
4    Copyright (C) Andrew Tridgell              1992-2000
5    Copyright (C) Luke Kenneth Casson Leighton 1996-2000
6    Copyright (C) Paul Ashton                  1997-2000
7    Copyright (C) Jean François Micouleau      1998-2001
8    Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
9    
10    
11    This program is free software; you can redistribute it and/or modify
12    it under the terms of the GNU General Public License as published by
13    the Free Software Foundation; either version 2 of the License, or
14    (at your option) any later version.
15    
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19    GNU General Public License for more details.
20    
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software
23    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26 #ifndef _RPC_SAMR_H /* _RPC_SAMR_H */
27 #define _RPC_SAMR_H 
28
29 #include "rpc_misc.h"
30
31 /*******************************************************************
32  the following information comes from a QuickView on samsrv.dll,
33  and gives an idea of exactly what is needed:
34  
35 x SamrAddMemberToAlias
36 x SamrAddMemberToGroup
37 SamrAddMultipleMembersToAlias
38 x SamrChangePasswordUser
39 x SamrCloseHandle
40 x SamrConnect
41 x SamrCreateAliasInDomain
42 x SamrCreateGroupInDomain
43 x SamrCreateUserInDomain
44 ? SamrDeleteAlias
45 SamrDeleteGroup
46 x SamrDeleteUser
47 x SamrEnumerateAliasesInDomain
48 SamrEnumerateDomainsInSamServer
49 x SamrEnumerateGroupsInDomain
50 x SamrEnumerateUsersInDomain
51 SamrGetUserDomainPasswordInformation
52 SamrLookupDomainInSamServer
53 ? SamrLookupIdsInDomain
54 x SamrLookupNamesInDomain
55 x SamrOpenAlias
56 x SamrOpenDomain
57 x SamrOpenGroup
58 x SamrOpenUser
59 x SamrQueryDisplayInformation
60 x SamrQueryInformationAlias
61 SamrQueryInformationDomain
62 ? SamrQueryInformationUser
63 x SamrQuerySecurityObject
64 SamrRemoveMemberFromAlias
65 SamrRemoveMemberFromForiegnDomain
66 SamrRemoveMemberFromGroup
67 SamrRemoveMultipleMembersFromAlias
68 x SamrSetInformationAlias
69 SamrSetInformationDomain
70 x SamrSetInformationGroup
71 x SamrSetInformationUser
72 SamrSetMemberAttributesOfGroup
73 SamrSetSecurityObject
74 SamrShutdownSamServer
75 SamrTestPrivateFunctionsDomain
76 SamrTestPrivateFunctionsUser
77
78 ********************************************************************/
79
80 #define SAMR_CONNECT_ANON      0x00
81 #define SAMR_CLOSE_HND         0x01
82 #define SAMR_SET_SEC_OBJECT    0x02
83 #define SAMR_QUERY_SEC_OBJECT  0x03
84
85 #define SAMR_UNKNOWN_4         0x04 /* profile info? */
86 #define SAMR_LOOKUP_DOMAIN     0x05
87 #define SAMR_ENUM_DOMAINS      0x06
88 #define SAMR_OPEN_DOMAIN       0x07
89 #define SAMR_QUERY_DOMAIN_INFO 0x08
90 #define SAMR_SET_DOMAIN_INFO   0x09
91
92 #define SAMR_CREATE_DOM_GROUP  0x0a
93 #define SAMR_ENUM_DOM_GROUPS   0x0b
94 #define SAMR_ENUM_DOM_USERS    0x0d
95 #define SAMR_CREATE_DOM_ALIAS  0x0e
96 #define SAMR_ENUM_DOM_ALIASES  0x0f
97 #define SAMR_QUERY_USERALIASES 0x10
98
99 #define SAMR_LOOKUP_NAMES      0x11
100 #define SAMR_LOOKUP_RIDS       0x12
101
102 #define SAMR_OPEN_GROUP        0x13
103 #define SAMR_QUERY_GROUPINFO   0x14
104 #define SAMR_SET_GROUPINFO     0x15
105 #define SAMR_ADD_GROUPMEM      0x16
106 #define SAMR_DELETE_DOM_GROUP  0x17
107 #define SAMR_DEL_GROUPMEM      0x18
108 #define SAMR_QUERY_GROUPMEM    0x19
109 #define SAMR_UNKNOWN_1A        0x1a
110
111 #define SAMR_OPEN_ALIAS        0x1b
112 #define SAMR_QUERY_ALIASINFO   0x1c
113 #define SAMR_SET_ALIASINFO     0x1d
114 #define SAMR_DELETE_DOM_ALIAS  0x1e
115 #define SAMR_ADD_ALIASMEM      0x1f
116 #define SAMR_DEL_ALIASMEM      0x20
117 #define SAMR_QUERY_ALIASMEM    0x21
118
119 #define SAMR_OPEN_USER         0x22
120 #define SAMR_DELETE_DOM_USER   0x23
121 #define SAMR_QUERY_USERINFO    0x24
122 #define SAMR_SET_USERINFO2     0x25
123 #define SAMR_QUERY_USERGROUPS  0x27
124
125 #define SAMR_QUERY_DISPINFO    0x28
126 #define SAMR_UNKNOWN_29        0x29
127 #define SAMR_UNKNOWN_2a        0x2a
128 #define SAMR_UNKNOWN_2b        0x2b
129 #define SAMR_GET_USRDOM_PWINFO 0x2c
130 #define SAMR_REMOVE_SID_FOREIGN_DOMAIN        0x2d
131 #define SAMR_UNKNOWN_2E        0x2e /* looks like an alias for SAMR_QUERY_DOMAIN_INFO */
132 #define SAMR_UNKNOWN_2f        0x2f
133 #define SAMR_QUERY_DISPINFO3   0x30 /* Alias for SAMR_QUERY_DISPINFO
134                                        with info level 3 */
135 #define SAMR_UNKNOWN_31        0x31
136 #define SAMR_CREATE_USER       0x32
137 #define SAMR_QUERY_DISPINFO4   0x33 /* Alias for SAMR_QUERY_DISPINFO
138                                        with info level 4 */
139 #define SAMR_ADDMULTI_ALIASMEM 0x34
140
141 #define SAMR_UNKNOWN_35        0x35
142 #define SAMR_UNKNOWN_36        0x36
143 #define SAMR_CHGPASSWD_USER    0x37
144 #define SAMR_GET_DOM_PWINFO    0x38
145 #define SAMR_CONNECT           0x39
146 #define SAMR_SET_USERINFO      0x3A
147 #define SAMR_CONNECT4          0x3E
148
149 typedef struct logon_hours_info
150 {
151         uint32 len; /* normally 21 bytes */
152         uint8 hours[32];
153
154 } LOGON_HRS;
155
156 /* SAM_USER_INFO_23 */
157 typedef struct sam_user_info_23
158 {
159         /* TIMES MAY NOT IN RIGHT ORDER!!!! */
160         NTTIME logon_time;            /* logon time */
161         NTTIME logoff_time;           /* logoff time */
162         NTTIME kickoff_time;          /* kickoff time */
163         NTTIME pass_last_set_time;    /* password last set time */
164         NTTIME pass_can_change_time;  /* password can change time */
165         NTTIME pass_must_change_time; /* password must change time */
166
167         UNIHDR hdr_user_name;    /* NULL - user name unicode string header */
168         UNIHDR hdr_full_name;    /* user's full name unicode string header */
169         UNIHDR hdr_home_dir;     /* home directory unicode string header */
170         UNIHDR hdr_dir_drive;    /* home drive unicode string header */
171         UNIHDR hdr_logon_script; /* logon script unicode string header */
172         UNIHDR hdr_profile_path; /* profile path unicode string header */
173         UNIHDR hdr_acct_desc  ;  /* user description */
174         UNIHDR hdr_workstations; /* comma-separated workstations user can log in from */
175         UNIHDR hdr_unknown_str ; /* don't know what this is, yet. */
176         UNIHDR hdr_munged_dial ; /* munged path name and dial-back tel number */
177
178         uint8 lm_pwd[16];    /* lm user passwords */
179         uint8 nt_pwd[16];    /* nt user passwords */
180
181         uint32 user_rid;      /* Primary User ID */
182         uint32 group_rid;     /* Primary Group ID */
183
184         uint32 acb_info; /* account info (ACB_xxxx bit-mask) */
185
186         uint32 fields_present; /* 0x09f8 27fa */
187
188         uint16 logon_divs; /* 0x0000 00a8 which is 168 which is num hrs in a week */
189         /* uint8 pad[2] */
190         uint32 ptr_logon_hrs; /* pointer to logon hours */
191
192         /* Was unknown_5. */
193         uint16 bad_password_count;
194         uint16 logon_count;
195
196         uint8 padding1[6];
197                 
198         uint8 passmustchange; /* 0x00 must change = 0x01 */
199
200         uint8 padding2;
201
202         uint8 pass[516];
203
204         UNISTR2 uni_user_name;    /* NULL - username unicode string */
205         UNISTR2 uni_full_name;    /* user's full name unicode string */
206         UNISTR2 uni_home_dir;     /* home directory unicode string */
207         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
208         UNISTR2 uni_logon_script; /* logon script unicode string */
209         UNISTR2 uni_profile_path; /* profile path unicode string */
210         UNISTR2 uni_acct_desc  ;  /* user description unicode string */
211         UNISTR2 uni_workstations; /* login from workstations unicode string */
212         UNISTR2 uni_unknown_str ; /* don't know what this is, yet. */
213         UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel no */
214
215         uint32 unknown_6; /* 0x0000 04ec */
216         uint32 padding4;
217
218         LOGON_HRS logon_hrs;
219
220 } SAM_USER_INFO_23;
221
222 /* SAM_USER_INFO_24 */
223 typedef struct sam_user_info_24
224 {
225         uint8 pass[516];
226         uint16 pw_len;
227 } SAM_USER_INFO_24;
228
229 /*
230  * NB. This structure is *definately* incorrect. It's my best guess
231  * currently for W2K SP2. The password field is encrypted in a different
232  * way than normal... And there are definately other problems. JRA.
233  */
234
235 /* SAM_USER_INFO_25 */
236 typedef struct sam_user_info_25
237 {
238         /* TIMES MAY NOT IN RIGHT ORDER!!!! */
239         NTTIME logon_time;            /* logon time */
240         NTTIME logoff_time;           /* logoff time */
241         NTTIME kickoff_time;          /* kickoff time */
242         NTTIME pass_last_set_time;    /* password last set time */
243         NTTIME pass_can_change_time;  /* password can change time */
244         NTTIME pass_must_change_time; /* password must change time */
245
246         UNIHDR hdr_user_name;    /* NULL - user name unicode string header */
247         UNIHDR hdr_full_name;    /* user's full name unicode string header */
248         UNIHDR hdr_home_dir;     /* home directory unicode string header */
249         UNIHDR hdr_dir_drive;    /* home drive unicode string header */
250         UNIHDR hdr_logon_script; /* logon script unicode string header */
251         UNIHDR hdr_profile_path; /* profile path unicode string header */
252         UNIHDR hdr_acct_desc  ;  /* user description */
253         UNIHDR hdr_workstations; /* comma-separated workstations user can log in from */
254         UNIHDR hdr_unknown_str ; /* don't know what this is, yet. */
255         UNIHDR hdr_munged_dial ; /* munged path name and dial-back tel number */
256
257         uint8 lm_pwd[16];    /* lm user passwords */
258         uint8 nt_pwd[16];    /* nt user passwords */
259
260         uint32 user_rid;      /* Primary User ID */
261         uint32 group_rid;     /* Primary Group ID */
262
263         uint32 acb_info; /* account info (ACB_xxxx bit-mask) */
264
265         uint32 unknown_6[6];
266
267         uint8 pass[532];
268
269         UNISTR2 uni_user_name;    /* NULL - username unicode string */
270         UNISTR2 uni_full_name;    /* user's full name unicode string */
271         UNISTR2 uni_home_dir;     /* home directory unicode string */
272         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
273         UNISTR2 uni_logon_script; /* logon script unicode string */
274         UNISTR2 uni_profile_path; /* profile path unicode string */
275         UNISTR2 uni_acct_desc  ;  /* user description unicode string */
276         UNISTR2 uni_workstations; /* login from workstations unicode string */
277         UNISTR2 uni_unknown_str ; /* don't know what this is, yet. */
278         UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel no */
279 } SAM_USER_INFO_25;
280
281
282 /* SAM_USER_INFO_21 */
283 typedef struct sam_user_info_21
284 {
285         NTTIME logon_time;            /* logon time */
286         NTTIME logoff_time;           /* logoff time */
287         NTTIME kickoff_time;          /* kickoff time */
288         NTTIME pass_last_set_time;    /* password last set time */
289         NTTIME pass_can_change_time;  /* password can change time */
290         NTTIME pass_must_change_time; /* password must change time */
291
292         UNIHDR hdr_user_name;    /* username unicode string header */
293         UNIHDR hdr_full_name;    /* user's full name unicode string header */
294         UNIHDR hdr_home_dir;     /* home directory unicode string header */
295         UNIHDR hdr_dir_drive;    /* home drive unicode string header */
296         UNIHDR hdr_logon_script; /* logon script unicode string header */
297         UNIHDR hdr_profile_path; /* profile path unicode string header */
298         UNIHDR hdr_acct_desc  ;  /* user description */
299         UNIHDR hdr_workstations; /* comma-separated workstations user can log in from */
300         UNIHDR hdr_unknown_str ; /* don't know what this is, yet. */
301         UNIHDR hdr_munged_dial ; /* munged path name and dial-back tel number */
302
303         uint8 lm_pwd[16];    /* lm user passwords */
304         uint8 nt_pwd[16];    /* nt user passwords */
305
306         uint32 user_rid;      /* Primary User ID */
307         uint32 group_rid;     /* Primary Group ID */
308
309         uint32 acb_info; /* account info (ACB_xxxx bit-mask) */
310
311         /* Was unknown_3 */
312         uint32 fields_present; /* 0x00ff ffff */
313
314         uint16 logon_divs; /* 0x0000 00a8 which is 168 which is num hrs in a week */
315         /* uint8 pad[2] */
316         uint32 ptr_logon_hrs; /* unknown pointer */
317
318         /* Was unknown_5. */
319         uint16 bad_password_count;
320         uint16 logon_count;
321
322         uint8 padding1[6];
323                 
324         uint8 passmustchange; /* 0x00 must change = 0x01 */
325
326         uint8 padding2;
327
328         UNISTR2 uni_user_name;    /* username unicode string */
329         UNISTR2 uni_full_name;    /* user's full name unicode string */
330         UNISTR2 uni_home_dir;     /* home directory unicode string */
331         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
332         UNISTR2 uni_logon_script; /* logon script unicode string */
333         UNISTR2 uni_profile_path; /* profile path unicode string */
334         UNISTR2 uni_acct_desc  ;  /* user description unicode string */
335         UNISTR2 uni_workstations; /* login from workstations unicode string */
336         UNISTR2 uni_unknown_str ; /* don't know what this is, yet. */
337         UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel number */
338
339         uint32 unknown_6; /* 0x0000 04ec */
340         uint32 padding4;
341
342         LOGON_HRS logon_hrs;
343
344 } SAM_USER_INFO_21;
345
346 #define PASS_MUST_CHANGE_AT_NEXT_LOGON  0x01
347 #define PASS_DONT_CHANGE_AT_NEXT_LOGON  0x00
348
349 /* SAM_USER_INFO_20 */
350 typedef struct sam_user_info_20
351 {
352         UNIHDR hdr_munged_dial ; /* munged path name and dial-back tel number */
353
354         UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel number */
355
356 } SAM_USER_INFO_20;
357
358 /* SAM_USER_INFO_12 */
359 typedef struct sam_user_info_12
360 {
361         uint8 lm_pwd[16];    /* lm user passwords */
362         uint8 nt_pwd[16];    /* nt user passwords */
363
364         uint8 lm_pwd_active; 
365         uint8 nt_pwd_active; 
366
367 } SAM_USER_INFO_12;
368
369 /* SAM_USER_INFO_11 */
370 typedef struct sam_user_info_11
371 {
372         uint8  padding_0[16];  /* 0 - padding 16 bytes */
373         NTTIME expiry;         /* expiry time or something? */
374         uint8  padding_1[24];  /* 0 - padding 24 bytes */
375
376         UNIHDR hdr_mach_acct;  /* unicode header for machine account */
377         uint32 padding_2;      /* 0 - padding 4 bytes */
378
379         uint32 ptr_1;          /* pointer */
380         uint8  padding_3[32];  /* 0 - padding 32 bytes */
381         uint32 padding_4;      /* 0 - padding 4 bytes */
382
383         uint32 ptr_2;          /* pointer */
384         uint32 padding_5;      /* 0 - padding 4 bytes */
385
386         uint32 ptr_3;          /* pointer */
387         uint8  padding_6[32];  /* 0 - padding 32 bytes */
388
389         uint32 rid_user;       /* user RID */
390         uint32 rid_group;      /* group RID */
391
392         uint16 acct_ctrl;      /* 0080 - ACB_XXXX */
393         uint16 unknown_3;      /* 16 bit padding */
394
395         uint16 unknown_4;      /* 0x003f      - 16 bit unknown */
396         uint16 unknown_5;      /* 0x003c      - 16 bit unknown */
397
398         uint8  padding_7[16];  /* 0 - padding 16 bytes */
399         uint32 padding_8;      /* 0 - padding 4 bytes */
400         
401         UNISTR2 uni_mach_acct; /* unicode string for machine account */
402
403         uint8  padding_9[48];  /* 0 - padding 48 bytes */
404
405 } SAM_USER_INFO_11;
406
407
408 /* SAM_USER_INFO_10 */
409 typedef struct sam_user_info_10
410 {
411         uint32 acb_info;
412
413 } SAM_USER_INFO_10;
414
415
416
417 /* SAMR_Q_CLOSE_HND - probably a policy handle close */
418 typedef struct q_samr_close_hnd_info
419 {
420     POLICY_HND pol;          /* policy handle */
421
422 } SAMR_Q_CLOSE_HND;
423
424
425 /* SAMR_R_CLOSE_HND - probably a policy handle close */
426 typedef struct r_samr_close_hnd_info
427 {
428         POLICY_HND pol;       /* policy handle */
429         NTSTATUS status;         /* return status */
430
431 } SAMR_R_CLOSE_HND;
432
433
434 /****************************************************************************
435 SAMR_Q_GET_USRDOM_PWINFO - a "set user info" occurs just after this
436 *****************************************************************************/
437
438 /* SAMR_Q_GET_USRDOM_PWINFO */
439 typedef struct q_samr_usrdom_pwinfo_info
440 {
441         POLICY_HND user_pol;          /* policy handle */
442
443 } SAMR_Q_GET_USRDOM_PWINFO;
444
445
446 /****************************************************************************
447 SAMR_R_GET_USRDOM_PWINFO - a "set user info" occurs just after this
448 *****************************************************************************/
449
450 /* SAMR_R_GET_USRDOM_PWINFO */
451 typedef struct r_samr_usrdom_pwinfo_info
452 {
453         uint16 unknown_0; /* 0000 */
454         uint16 unknown_1; /* 0x0016 or 0x0015 */
455         uint32 unknown_2; /* 0x0000 0000 */
456         NTSTATUS status; 
457
458 } SAMR_R_GET_USRDOM_PWINFO;
459
460 /****************************************************************************
461 SAMR_Q_SET_SEC_OBJ - info level 4.
462 *****************************************************************************/
463
464 /* SAMR_Q_SET_SEC_OBJ - */
465 typedef struct q_samr_set_sec_obj_info
466 {
467         POLICY_HND pol;          /* policy handle */
468         uint32 sec_info;         /* xxxx_SECURITY_INFORMATION 0x0000 0004 */
469         SEC_DESC_BUF *buf;
470
471 } SAMR_Q_SET_SEC_OBJ;
472
473 /* SAMR_R_SET_SEC_OBJ - */
474 typedef struct r_samr_set_sec_obj_info
475 {
476         NTSTATUS status;         /* return status */
477
478 } SAMR_R_SET_SEC_OBJ;
479
480
481 /****************************************************************************
482 SAMR_Q_QUERY_SEC_OBJ - info level 4.  returns SIDs.
483 *****************************************************************************/
484
485 /* SAMR_Q_QUERY_SEC_OBJ - probably get domain info... */
486 typedef struct q_samr_query_sec_obj_info
487 {
488         POLICY_HND user_pol;          /* policy handle */
489         uint32 sec_info;     /* xxxx_SECURITY_INFORMATION 0x0000 0004 */
490
491 } SAMR_Q_QUERY_SEC_OBJ;
492
493 /* SAMR_R_QUERY_SEC_OBJ - probably an open */
494 typedef struct r_samr_query_sec_obj_info
495 {
496         uint32 ptr;
497         SEC_DESC_BUF *buf;
498
499         NTSTATUS status;         /* return status */
500
501 } SAMR_R_QUERY_SEC_OBJ;
502
503
504 /****************************************************************************
505 SAMR_Q_QUERY_DOMAIN_INFO - probably a query on domain group info.
506 *****************************************************************************/
507
508 /* SAMR_Q_QUERY_DOMAIN_INFO - */
509 typedef struct q_samr_query_domain_info
510 {
511         POLICY_HND domain_pol;   /* policy handle */
512         uint16 switch_value;     /* 0x0002, 0x0001 */
513
514 } SAMR_Q_QUERY_DOMAIN_INFO;
515
516 typedef struct sam_unknown_info_3_info
517 {
518         NTTIME logout;  
519         /* 0x8000 0000 */ /* DON'T forcibly disconnect remote users from server when logon hours expire*/
520
521         /* 0x0000 0000 */ /* forcibly disconnect remote users from server when logon hours expire*/
522
523 } SAM_UNK_INFO_3;
524
525 typedef struct sam_unknown_info_6_info
526 {
527         uint32 unknown_0; /* 0x0000 0000 */
528
529         uint32 ptr_0;     /* pointer to unknown structure */
530         uint8  padding[12]; /* 12 bytes zeros */
531
532 } SAM_UNK_INFO_6;
533
534 typedef struct sam_unknown_info_7_info
535 {
536         uint16 unknown_0; /* 0x0003 */
537
538 } SAM_UNK_INFO_7;
539
540 typedef struct sam_unknown_info_8_info
541 {
542         UINT64_S seq_num;
543         NTTIME domain_create_time;
544
545 } SAM_UNK_INFO_8;
546
547 typedef struct sam_unknown_info_12_inf
548 {
549         NTTIME duration;
550         NTTIME reset_count;
551         uint16 bad_attempt_lockout;
552
553 } SAM_UNK_INFO_12;
554
555 typedef struct sam_unknown_info_5_inf
556 {
557         UNIHDR hdr_server; /* server name unicode header */
558         UNISTR2 uni_server; /* server name unicode string */
559
560 } SAM_UNK_INFO_5;
561
562 typedef struct sam_unknown_info_2_inf
563 {
564         uint32 unknown_0; /* 0x0000 0000 */
565         uint32 unknown_1; /* 0x8000 0000 */
566         UNIHDR hdr_comment; /* comment according to samba4 idl */
567         UNIHDR hdr_domain; /* domain name unicode header */
568         UNIHDR hdr_server; /* server name unicode header */
569
570         /* put all the data in here, at the moment, including what the above
571            pointer is referring to
572          */
573
574         UINT64_S seq_num;
575         
576         uint32 unknown_4; /* 0x0000 0001 */
577         uint32 unknown_5; /* 0x0000 0003 */
578         uint32 unknown_6; /* 0x0000 0001 */
579         uint32 num_domain_usrs; /* number of users in domain */
580         uint32 num_domain_grps; /* number of domain groups in domain */
581         uint32 num_local_grps; /* number of local groups in domain */
582
583         uint8 padding[12]; /* 12 bytes zeros */
584
585         UNISTR2 uni_comment; /* comment unicode string */
586         UNISTR2 uni_domain; /* domain name unicode string */
587         UNISTR2 uni_server; /* server name unicode string */
588
589 } SAM_UNK_INFO_2;
590
591 typedef struct sam_unknown_info_1_inf
592 {
593         uint16 min_length_password;
594         uint16 password_history;
595         uint32 flag;
596         NTTIME expire;
597         NTTIME min_passwordage;
598
599 } SAM_UNK_INFO_1;
600
601
602 typedef struct sam_unknown_ctr_info
603 {
604         union
605         {
606                 SAM_UNK_INFO_1 inf1;
607                 SAM_UNK_INFO_2 inf2;
608                 SAM_UNK_INFO_3 inf3;
609                 SAM_UNK_INFO_5 inf5;
610                 SAM_UNK_INFO_6 inf6;
611                 SAM_UNK_INFO_7 inf7;
612                 SAM_UNK_INFO_8 inf8;
613                 SAM_UNK_INFO_12 inf12;
614
615         } info;
616
617 } SAM_UNK_CTR;
618
619
620 /* SAMR_R_QUERY_DOMAIN_INFO - */
621 typedef struct r_samr_query_domain_info
622 {
623         uint32 ptr_0;
624         uint16 switch_value; /* same as in query */
625
626         SAM_UNK_CTR *ctr;
627
628         NTSTATUS status;         /* return status */
629
630 } SAMR_R_QUERY_DOMAIN_INFO;
631
632
633 /* SAMR_Q_LOOKUP_DOMAIN - obtain SID for a local domain */
634 typedef struct q_samr_lookup_domain_info
635 {
636         POLICY_HND connect_pol;
637
638         UNIHDR  hdr_domain;
639         UNISTR2 uni_domain;
640
641 } SAMR_Q_LOOKUP_DOMAIN;
642
643
644 /* SAMR_R_LOOKUP_DOMAIN */
645 typedef struct r_samr_lookup_domain_info
646 {
647         uint32   ptr_sid;
648         DOM_SID2 dom_sid;
649
650         NTSTATUS status;
651
652 } SAMR_R_LOOKUP_DOMAIN;
653
654
655 /****************************************************************************
656 SAMR_Q_OPEN_DOMAIN - unknown_0 values seen associated with SIDs:
657
658 0x0000 03f1 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
659 0x0000 0200 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
660 *****************************************************************************/
661
662 /* SAMR_Q_OPEN_DOMAIN */
663 typedef struct q_samr_open_domain_info
664 {
665         POLICY_HND pol;   /* policy handle */
666         uint32 flags;               /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - flags? */
667         DOM_SID2 dom_sid;         /* domain SID */
668
669 } SAMR_Q_OPEN_DOMAIN;
670
671
672 /* SAMR_R_OPEN_DOMAIN - probably an open */
673 typedef struct r_samr_open_domain_info
674 {
675         POLICY_HND domain_pol; /* policy handle associated with the SID */
676         NTSTATUS status;         /* return status */
677
678 } SAMR_R_OPEN_DOMAIN;
679
680 #define MAX_SAM_ENTRIES_W2K 0x400
681 #define MAX_SAM_ENTRIES_W95 50
682 /* The following should be the greater of the preceeding two. */
683 #define MAX_SAM_ENTRIES MAX_SAM_ENTRIES_W2K
684
685 typedef struct samr_entry_info
686 {
687         uint32 rid;
688         UNIHDR hdr_name;
689
690 } SAM_ENTRY;
691
692
693 /* SAMR_Q_ENUM_DOMAINS - SAM rids and names */
694 typedef struct q_samr_enum_domains_info
695 {
696         POLICY_HND pol;     /* policy handle */
697
698         uint32 start_idx;   /* enumeration handle */
699         uint32 max_size;    /* 0x0000 ffff */
700
701 } SAMR_Q_ENUM_DOMAINS;
702
703 /* SAMR_R_ENUM_DOMAINS - SAM rids and Domain names */
704 typedef struct r_samr_enum_domains_info
705 {
706         uint32 next_idx;     /* next starting index required for enum */
707         uint32 ptr_entries1;  
708
709         uint32 num_entries2;
710         uint32 ptr_entries2;
711
712         uint32 num_entries3;
713
714         SAM_ENTRY *sam;
715         UNISTR2 *uni_dom_name;
716
717         uint32 num_entries4;
718
719         NTSTATUS status;
720
721 } SAMR_R_ENUM_DOMAINS;
722
723 /* SAMR_Q_ENUM_DOM_USERS - SAM rids and names */
724 typedef struct q_samr_enum_dom_users_info
725 {
726         POLICY_HND pol;          /* policy handle */
727
728         uint32 start_idx;   /* number of values (0 indicates unlimited?) */
729         uint16 acb_mask;          /* 0x0000 indicates all */
730         uint16 unknown_1;         /* 0x0000 */
731
732         uint32 max_size;              /* 0x0000 ffff */
733
734 } SAMR_Q_ENUM_DOM_USERS;
735
736
737 /* SAMR_R_ENUM_DOM_USERS - SAM rids and names */
738 typedef struct r_samr_enum_dom_users_info
739 {
740         uint32 next_idx;     /* next starting index required for enum */
741         uint32 ptr_entries1;  
742
743         uint32 num_entries2;
744         uint32 ptr_entries2;
745
746         uint32 num_entries3;
747
748         SAM_ENTRY *sam;
749         UNISTR2 *uni_acct_name;
750
751         uint32 num_entries4;
752
753         NTSTATUS status;
754
755 } SAMR_R_ENUM_DOM_USERS;
756
757
758 /* SAMR_Q_ENUM_DOM_GROUPS - SAM rids and names */
759 typedef struct q_samr_enum_dom_groups_info
760 {
761         POLICY_HND pol;          /* policy handle */
762
763         /* this is possibly an enumeration context handle... */
764         uint32 start_idx;         /* 0x0000 0000 */
765
766         uint32 max_size;              /* 0x0000 ffff */
767
768 } SAMR_Q_ENUM_DOM_GROUPS;
769
770
771 /* SAMR_R_ENUM_DOM_GROUPS - SAM rids and names */
772 typedef struct r_samr_enum_dom_groups_info
773 {
774         uint32 next_idx;
775         uint32 ptr_entries1;
776
777         uint32 num_entries2;
778         uint32 ptr_entries2;
779
780         uint32 num_entries3;
781
782         SAM_ENTRY *sam;
783         UNISTR2 *uni_grp_name;
784
785         uint32 num_entries4;
786
787         NTSTATUS status;
788
789 } SAMR_R_ENUM_DOM_GROUPS;
790
791
792 /* SAMR_Q_ENUM_DOM_ALIASES - SAM rids and names */
793 typedef struct q_samr_enum_dom_aliases_info
794 {
795         POLICY_HND pol;          /* policy handle */
796
797         /* this is possibly an enumeration context handle... */
798         uint32 start_idx;         /* 0x0000 0000 */
799
800         uint32 max_size;              /* 0x0000 ffff */
801
802 } SAMR_Q_ENUM_DOM_ALIASES;
803
804
805 /* SAMR_R_ENUM_DOM_ALIASES - SAM rids and names */
806 typedef struct r_samr_enum_dom_aliases_info
807 {
808         uint32 next_idx;
809         uint32 ptr_entries1;
810
811         uint32 num_entries2;
812         uint32 ptr_entries2;
813
814         uint32 num_entries3;
815
816         SAM_ENTRY *sam;
817         UNISTR2 *uni_grp_name;
818
819         uint32 num_entries4;
820
821         NTSTATUS status;
822
823 } SAMR_R_ENUM_DOM_ALIASES;
824
825
826 /* -- Level 1 Display Info - User Information -- */
827
828 typedef struct samr_entry_info1
829 {
830         uint32 user_idx;
831
832         uint32 rid_user;
833         uint16 acb_info;
834
835         UNIHDR hdr_acct_name;
836         UNIHDR hdr_user_name;
837         UNIHDR hdr_user_desc;
838
839 } SAM_ENTRY1;
840
841 typedef struct samr_str_entry_info1
842 {
843         UNISTR2 uni_acct_name;
844         UNISTR2 uni_full_name;
845         UNISTR2 uni_acct_desc;
846
847 } SAM_STR1;
848
849 typedef struct sam_entry_info_1
850 {
851         SAM_ENTRY1 *sam;
852         SAM_STR1   *str;
853
854 } SAM_DISPINFO_1;
855
856
857 /* -- Level 2 Display Info - Trust Account Information -- */
858
859 typedef struct samr_entry_info2
860 {
861         uint32 user_idx;
862
863         uint32 rid_user;
864         uint16 acb_info;
865
866         UNIHDR hdr_srv_name;
867         UNIHDR hdr_srv_desc;
868
869 } SAM_ENTRY2;
870
871 typedef struct samr_str_entry_info2
872 {
873         UNISTR2 uni_srv_name;
874         UNISTR2 uni_srv_desc;
875
876 } SAM_STR2;
877
878 typedef struct sam_entry_info_2
879 {
880         SAM_ENTRY2 *sam;
881         SAM_STR2   *str;
882
883 } SAM_DISPINFO_2;
884
885
886 /* -- Level 3 Display Info - Domain Group Information -- */
887
888 typedef struct samr_entry_info3
889 {
890         uint32 grp_idx;
891
892         uint32 rid_grp;
893         uint32 attr;     /* SE_GROUP_xxx, usually 7 */
894
895         UNIHDR hdr_grp_name;
896         UNIHDR hdr_grp_desc;
897
898 } SAM_ENTRY3;
899
900 typedef struct samr_str_entry_info3
901 {
902         UNISTR2 uni_grp_name;
903         UNISTR2 uni_grp_desc;
904
905 } SAM_STR3;
906
907 typedef struct sam_entry_info_3
908 {
909         SAM_ENTRY3 *sam;
910         SAM_STR3   *str;
911
912 } SAM_DISPINFO_3;
913
914
915 /* -- Level 4 Display Info - User List (ASCII) -- */
916
917 typedef struct samr_entry_info4
918 {
919         uint32 user_idx;
920         STRHDR hdr_acct_name;
921
922 } SAM_ENTRY4;
923
924 typedef struct samr_str_entry_info4
925 {
926         STRING2 acct_name;
927
928 } SAM_STR4;
929
930 typedef struct sam_entry_info_4
931 {
932         SAM_ENTRY4 *sam;
933         SAM_STR4   *str;
934
935 } SAM_DISPINFO_4;
936
937
938 /* -- Level 5 Display Info - Group List (ASCII) -- */
939
940 typedef struct samr_entry_info5
941 {
942         uint32 grp_idx;
943         STRHDR hdr_grp_name;
944
945 } SAM_ENTRY5;
946
947 typedef struct samr_str_entry_info5
948 {
949         STRING2 grp_name;
950
951 } SAM_STR5;
952
953 typedef struct sam_entry_info_5
954 {
955         SAM_ENTRY5 *sam;
956         SAM_STR5   *str;
957
958 } SAM_DISPINFO_5;
959
960
961 typedef struct sam_dispinfo_ctr_info
962 {
963         union
964         {
965                 SAM_DISPINFO_1 *info1; /* users/names/descriptions */
966                 SAM_DISPINFO_2 *info2; /* trust accounts */
967                 SAM_DISPINFO_3 *info3; /* domain groups/descriptions */
968                 SAM_DISPINFO_4 *info4; /* user list (ASCII) - used by Win95 */
969                 SAM_DISPINFO_5 *info5; /* group list (ASCII) */
970                 void       *info; /* allows assignment without typecasting, */
971
972         } sam;
973
974 } SAM_DISPINFO_CTR;
975
976
977 /* SAMR_Q_QUERY_DISPINFO - SAM rids, names and descriptions */
978 typedef struct q_samr_query_disp_info
979 {
980         POLICY_HND domain_pol;
981
982         uint16 switch_level;    /* see SAM_DISPINFO_CTR above */
983         /* align */
984
985         uint32 start_idx;       /* start enumeration index */
986         uint32 max_entries;     /* maximum number of entries to return */
987         uint32 max_size;        /* recommended data size; if exceeded server
988                                    should return STATUS_MORE_ENTRIES */
989
990 } SAMR_Q_QUERY_DISPINFO;
991
992
993 /* SAMR_R_QUERY_DISPINFO  */
994 typedef struct r_samr_query_dispinfo_info
995 {
996         uint32 total_size;     /* total data size for all matching entries
997                                   (0 = uncalculated) */
998         uint32 data_size;      /* actual data size returned = size of SAM_ENTRY
999                                   structures + total length of strings */
1000
1001         uint16 switch_level;   /* see SAM_DISPINFO_CTR above */
1002         /* align */
1003
1004         uint32 num_entries;    /* number of entries returned */
1005         uint32 ptr_entries;
1006         uint32 num_entries2;
1007
1008         SAM_DISPINFO_CTR *ctr;
1009
1010         NTSTATUS status;
1011
1012 } SAMR_R_QUERY_DISPINFO;
1013
1014
1015 /* SAMR_Q_DELETE_DOM_GROUP - delete domain group */
1016 typedef struct q_samr_delete_dom_group_info
1017 {
1018     POLICY_HND group_pol;          /* policy handle */
1019
1020 } SAMR_Q_DELETE_DOM_GROUP;
1021
1022
1023 /* SAMR_R_DELETE_DOM_GROUP - delete domain group */
1024 typedef struct r_samr_delete_dom_group_info
1025 {
1026         POLICY_HND pol;       /* policy handle */
1027         NTSTATUS status;        /* return status */
1028
1029 } SAMR_R_DELETE_DOM_GROUP;
1030
1031
1032 /* SAMR_Q_CREATE_DOM_GROUP - SAM create group */
1033 typedef struct q_samr_create_dom_group_info
1034 {
1035         POLICY_HND pol;        /* policy handle */
1036
1037         UNIHDR hdr_acct_desc;
1038         UNISTR2 uni_acct_desc;
1039
1040         uint32 access_mask;    
1041
1042 } SAMR_Q_CREATE_DOM_GROUP;
1043
1044 /* SAMR_R_CREATE_DOM_GROUP - SAM create group */
1045 typedef struct r_samr_create_dom_group_info
1046 {
1047         POLICY_HND pol;        /* policy handle */
1048
1049         uint32 rid;    
1050         NTSTATUS status;    
1051
1052 } SAMR_R_CREATE_DOM_GROUP;
1053
1054 /* SAMR_Q_QUERY_GROUPINFO - SAM Group Info */
1055 typedef struct q_samr_query_group_info
1056 {
1057         POLICY_HND pol;        /* policy handle */
1058
1059         uint16 switch_level;    /* 0x0001 seen */
1060
1061 } SAMR_Q_QUERY_GROUPINFO;
1062
1063 typedef struct samr_group_info1
1064 {
1065         UNIHDR hdr_acct_name;
1066
1067         uint32 unknown_1; /* 0x0000 0003 - number of group members? */
1068         uint32 num_members; /* 0x0000 0001 - number of group members? */
1069
1070         UNIHDR hdr_acct_desc;
1071
1072         UNISTR2 uni_acct_name;
1073         UNISTR2 uni_acct_desc;
1074
1075 } GROUP_INFO1;
1076
1077 typedef struct samr_group_info2
1078 {
1079         uint16 level;
1080         UNIHDR hdr_acct_name;
1081         UNISTR2 uni_acct_name;
1082
1083 } GROUP_INFO2;
1084
1085 typedef struct samr_group_info3
1086 {
1087         uint32 unknown_1; /* 0x0000 0003 - number of group members? */
1088
1089 } GROUP_INFO3;
1090
1091 typedef struct samr_group_info4
1092 {
1093         uint16 level;
1094         UNIHDR hdr_acct_desc;
1095         UNISTR2 uni_acct_desc;
1096
1097 } GROUP_INFO4;
1098
1099 /* GROUP_INFO_CTR */
1100 typedef struct group_info_ctr
1101 {
1102         uint16 switch_value1;
1103
1104         union
1105         {
1106                 GROUP_INFO1 info1;
1107                 GROUP_INFO2 info2;
1108                 GROUP_INFO3 info3;
1109                 GROUP_INFO4 info4;
1110
1111         } group;
1112
1113 } GROUP_INFO_CTR;
1114
1115 /* SAMR_R_QUERY_GROUPINFO - SAM Group Info */
1116 typedef struct r_samr_query_groupinfo_info
1117 {
1118         uint32 ptr;        
1119         GROUP_INFO_CTR *ctr;
1120
1121         NTSTATUS status;
1122
1123 } SAMR_R_QUERY_GROUPINFO;
1124
1125
1126 /* SAMR_Q_SET_GROUPINFO - SAM Group Info */
1127 typedef struct q_samr_set_group_info
1128 {
1129         POLICY_HND pol;        /* policy handle */
1130         GROUP_INFO_CTR *ctr;
1131
1132 } SAMR_Q_SET_GROUPINFO;
1133
1134 /* SAMR_R_SET_GROUPINFO - SAM Group Info */
1135 typedef struct r_samr_set_group_info
1136 {
1137         NTSTATUS status;
1138
1139 } SAMR_R_SET_GROUPINFO;
1140
1141
1142 /* SAMR_Q_DELETE_DOM_ALIAS - delete domain alias */
1143 typedef struct q_samr_delete_dom_alias_info
1144 {
1145     POLICY_HND alias_pol;          /* policy handle */
1146
1147 } SAMR_Q_DELETE_DOM_ALIAS;
1148
1149
1150 /* SAMR_R_DELETE_DOM_ALIAS - delete domain alias */
1151 typedef struct r_samr_delete_dom_alias_info
1152 {
1153         POLICY_HND pol;       /* policy handle */
1154         NTSTATUS status;        /* return status */
1155
1156 } SAMR_R_DELETE_DOM_ALIAS;
1157
1158
1159 /* SAMR_Q_CREATE_DOM_ALIAS - SAM create alias */
1160 typedef struct q_samr_create_dom_alias_info
1161 {
1162         POLICY_HND dom_pol;        /* policy handle */
1163
1164         UNIHDR hdr_acct_desc;
1165         UNISTR2 uni_acct_desc;
1166
1167         uint32 access_mask;    /* 0x001f000f */
1168
1169 } SAMR_Q_CREATE_DOM_ALIAS;
1170
1171 /* SAMR_R_CREATE_DOM_ALIAS - SAM create alias */
1172 typedef struct r_samr_create_dom_alias_info
1173 {
1174         POLICY_HND alias_pol;        /* policy handle */
1175
1176         uint32 rid;    
1177         NTSTATUS status;    
1178
1179 } SAMR_R_CREATE_DOM_ALIAS;
1180
1181 /* SAMR_Q_QUERY_ALIASINFO - SAM Alias Info */
1182 typedef struct q_samr_query_alias_info
1183 {
1184         POLICY_HND pol;        /* policy handle */
1185
1186         uint16 switch_level;    /* 0x0003 seen */
1187
1188 } SAMR_Q_QUERY_ALIASINFO;
1189
1190 typedef struct samr_alias_info1
1191 {
1192         UNIHDR hdr_acct_name;
1193         UNIHDR hdr_acct_desc;
1194         uint32 num_member;
1195         UNISTR2 uni_acct_name;
1196         UNISTR2 uni_acct_desc;
1197
1198 } ALIAS_INFO1;
1199
1200 typedef struct samr_alias_info3
1201 {
1202         UNIHDR hdr_acct_desc;
1203         UNISTR2 uni_acct_desc;
1204
1205 } ALIAS_INFO3;
1206
1207 /* ALIAS_INFO_CTR */
1208 typedef struct alias_info_ctr
1209 {
1210         uint16 switch_value1;
1211         uint16 switch_value2;
1212
1213         union
1214         {
1215                 ALIAS_INFO1 info1;
1216                 ALIAS_INFO3 info3;
1217
1218         } alias;
1219
1220 } ALIAS_INFO_CTR;
1221
1222 /* SAMR_R_QUERY_ALIASINFO - SAM alias info */
1223 typedef struct r_samr_query_aliasinfo_info
1224 {
1225         uint32 ptr;        
1226         ALIAS_INFO_CTR ctr;
1227
1228         NTSTATUS status;
1229
1230 } SAMR_R_QUERY_ALIASINFO;
1231
1232
1233 /* SAMR_Q_SET_ALIASINFO - SAM Alias Info */
1234 typedef struct q_samr_set_alias_info
1235 {
1236         POLICY_HND alias_pol;        /* policy handle */
1237         ALIAS_INFO_CTR ctr;
1238
1239 } SAMR_Q_SET_ALIASINFO;
1240
1241 /* SAMR_R_SET_ALIASINFO - SAM alias info */
1242 typedef struct r_samr_set_aliasinfo_info
1243 {
1244         NTSTATUS status;
1245
1246 } SAMR_R_SET_ALIASINFO;
1247
1248
1249 /* SAMR_Q_QUERY_USERGROUPS - */
1250 typedef struct q_samr_query_usergroup_info
1251 {
1252         POLICY_HND pol;          /* policy handle associated with unknown id */
1253
1254 } SAMR_Q_QUERY_USERGROUPS;
1255
1256 /* SAMR_R_QUERY_USERGROUPS - probably a get sam info */
1257 typedef struct r_samr_query_usergroup_info
1258 {
1259         uint32 ptr_0;            /* pointer */
1260         uint32 num_entries;      /* number of RID groups */
1261         uint32 ptr_1;            /* pointer */
1262         uint32 num_entries2;     /* number of RID groups */
1263
1264         DOM_GID *gid; /* group info */
1265
1266         NTSTATUS status;         /* return status */
1267
1268 } SAMR_R_QUERY_USERGROUPS;
1269
1270 /* SAM_USERINFO_CTR - sam user info */
1271 typedef struct sam_userinfo_ctr_info
1272 {
1273         uint16 switch_value;      
1274
1275         union
1276         {
1277                 SAM_USER_INFO_10 *id10; /* auth-level 0x10 */
1278                 SAM_USER_INFO_11 *id11; /* auth-level 0x11 */
1279                 SAM_USER_INFO_12 *id12; /* auth-level 0x12 */
1280                 SAM_USER_INFO_20 *id20; /* auth-level 20 */
1281                 SAM_USER_INFO_21 *id21; /* auth-level 21 */
1282                 SAM_USER_INFO_23 *id23; /* auth-level 0x17 */
1283                 SAM_USER_INFO_24 *id24; /* auth-level 0x18 */
1284                 SAM_USER_INFO_25 *id25; /* auth-level 0x19 */
1285                 void* id; /* to make typecasting easy */
1286
1287         } info;
1288
1289 } SAM_USERINFO_CTR;
1290
1291
1292 /* SAMR_Q_SET_USERINFO2 - set sam info */
1293 typedef struct q_samr_set_user_info2
1294 {
1295         POLICY_HND pol;          /* policy handle associated with user */
1296         uint16 switch_value;      /* 0x0010 */
1297
1298         SAM_USERINFO_CTR *ctr;
1299
1300 } SAMR_Q_SET_USERINFO2;
1301
1302 /* SAMR_R_SET_USERINFO2 - set sam info */
1303 typedef struct r_samr_set_user_info2
1304 {
1305         NTSTATUS status;         /* return status */
1306
1307 } SAMR_R_SET_USERINFO2;
1308
1309 /* SAMR_Q_SET_USERINFO - set sam info */
1310 typedef struct q_samr_set_user_info
1311 {
1312         POLICY_HND pol;          /* policy handle associated with user */
1313         uint16 switch_value;
1314         SAM_USERINFO_CTR *ctr;
1315
1316 } SAMR_Q_SET_USERINFO;
1317
1318 /* SAMR_R_SET_USERINFO - set sam info */
1319 typedef struct r_samr_set_user_info
1320 {
1321         NTSTATUS status;         /* return status */
1322
1323 } SAMR_R_SET_USERINFO;
1324
1325
1326 /* SAMR_Q_QUERY_USERINFO - probably a get sam info */
1327 typedef struct q_samr_query_user_info
1328 {
1329         POLICY_HND pol;          /* policy handle associated with unknown id */
1330         uint16 switch_value;         /* 0x0015, 0x0011 or 0x0010 - 16 bit unknown */
1331
1332 } SAMR_Q_QUERY_USERINFO;
1333
1334 /* SAMR_R_QUERY_USERINFO - probably a get sam info */
1335 typedef struct r_samr_query_user_info
1336 {
1337         uint32 ptr;            /* pointer */
1338         SAM_USERINFO_CTR *ctr;
1339
1340         NTSTATUS status;         /* return status */
1341
1342 } SAMR_R_QUERY_USERINFO;
1343
1344
1345 /****************************************************************************
1346 SAMR_Q_QUERY_USERALIASES - do a conversion from name to RID.
1347
1348 the policy handle allocated by an "samr open secret" call is associated
1349 with a SID.  this policy handle is what is queried here, *not* the SID
1350 itself.  the response to the lookup rids is relative to this SID.
1351 *****************************************************************************/
1352 /* SAMR_Q_QUERY_USERALIASES */
1353 typedef struct q_samr_query_useraliases_info
1354 {
1355         POLICY_HND pol;       /* policy handle */
1356
1357         uint32 num_sids1;      /* number of rids being looked up */
1358         uint32 ptr;            /* buffer pointer */
1359         uint32 num_sids2;      /* number of rids being looked up */
1360
1361         uint32   *ptr_sid; /* pointers to sids to be looked up */
1362         DOM_SID2 *sid    ; /* sids to be looked up. */
1363
1364 } SAMR_Q_QUERY_USERALIASES;
1365
1366
1367 /* SAMR_R_QUERY_USERALIASES */
1368 typedef struct r_samr_query_useraliases_info
1369 {
1370         uint32 num_entries;
1371         uint32 ptr; /* undocumented buffer pointer */
1372
1373         uint32 num_entries2; 
1374         uint32 *rid; /* domain RIDs being looked up */
1375
1376         NTSTATUS status; /* return code */
1377
1378 } SAMR_R_QUERY_USERALIASES;
1379
1380
1381 /****************************************************************************
1382 SAMR_Q_LOOKUP_NAMES - do a conversion from Names to RIDs+types.
1383 *****************************************************************************/
1384 /* SAMR_Q_LOOKUP_NAMES */
1385 typedef struct q_samr_lookup_names_info
1386 {
1387         POLICY_HND pol;       /* policy handle */
1388
1389         uint32 num_names1;      /* number of names being looked up */
1390         uint32 flags;           /* 0x0000 03e8 - unknown */
1391         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
1392         uint32 num_names2;      /* number of names being looked up */
1393
1394         UNIHDR  *hdr_name; /* unicode account name header */
1395         UNISTR2 *uni_name; /* unicode account name string */
1396
1397 } SAMR_Q_LOOKUP_NAMES;
1398
1399
1400 /* SAMR_R_LOOKUP_NAMES */
1401 typedef struct r_samr_lookup_names_info
1402 {
1403         uint32 num_rids1;      /* number of aliases being looked up */
1404         uint32 ptr_rids;       /* pointer to aliases */
1405         uint32 num_rids2;      /* number of aliases being looked up */
1406
1407         uint32 *rids; /* rids */
1408
1409         uint32 num_types1;      /* number of users in aliases being looked up */
1410         uint32 ptr_types;       /* pointer to users in aliases */
1411         uint32 num_types2;      /* number of users in aliases being looked up */
1412
1413         uint32 *types; /* SID_ENUM type */
1414
1415         NTSTATUS status; /* return code */
1416
1417 } SAMR_R_LOOKUP_NAMES;
1418
1419
1420 /****************************************************************************
1421 SAMR_Q_LOOKUP_RIDS - do a conversion from RID groups to something.
1422
1423 called to resolve domain RID groups.
1424 *****************************************************************************/
1425 /* SAMR_Q_LOOKUP_RIDS */
1426 typedef struct q_samr_lookup_rids_info
1427 {
1428         POLICY_HND pol;       /* policy handle */
1429
1430         uint32 num_rids1;      /* number of rids being looked up */
1431         uint32 flags;          /* 0x0000 03e8 - unknown */
1432         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
1433         uint32 num_rids2;      /* number of rids being looked up */
1434
1435         uint32 *rid; /* domain RIDs being looked up */
1436
1437 } SAMR_Q_LOOKUP_RIDS;
1438
1439
1440 /****************************************************************************
1441 SAMR_R_LOOKUP_RIDS - do a conversion from group RID to names
1442
1443 *****************************************************************************/
1444 /* SAMR_R_LOOKUP_RIDS */
1445 typedef struct r_samr_lookup_rids_info
1446 {
1447         uint32 num_names1;      /* number of aliases being looked up */
1448         uint32 ptr_names;       /* pointer to aliases */
1449         uint32 num_names2;      /* number of aliases being looked up */
1450
1451         UNIHDR  *hdr_name; /* unicode account name header */
1452         UNISTR2 *uni_name; /* unicode account name string */
1453
1454         uint32 num_types1;      /* number of users in aliases being looked up */
1455         uint32 ptr_types;       /* pointer to users in aliases */
1456         uint32 num_types2;      /* number of users in aliases being looked up */
1457
1458         uint32 *type; /* SID_ENUM type */
1459
1460         NTSTATUS status;
1461
1462 } SAMR_R_LOOKUP_RIDS;
1463
1464
1465 /* SAMR_Q_OPEN_USER - probably an open */
1466 typedef struct q_samr_open_user_info
1467 {
1468         POLICY_HND domain_pol;       /* policy handle */
1469         uint32 access_mask;     /* 32 bit unknown - 0x02011b */
1470         uint32 user_rid;      /* user RID */
1471
1472 } SAMR_Q_OPEN_USER;
1473
1474
1475 /* SAMR_R_OPEN_USER - probably an open */
1476 typedef struct r_samr_open_user_info
1477 {
1478         POLICY_HND user_pol;       /* policy handle associated with unknown id */
1479         NTSTATUS status;         /* return status */
1480
1481 } SAMR_R_OPEN_USER;
1482
1483
1484 /* SAMR_Q_CREATE_USER - probably a create */
1485 typedef struct q_samr_create_user_info
1486 {
1487         POLICY_HND domain_pol;       /* policy handle */
1488
1489         UNIHDR  hdr_name;       /* unicode account name header */
1490         UNISTR2 uni_name;       /* unicode account name */
1491
1492         uint32 acb_info;      /* account control info */
1493         uint32 access_mask;     /* 0xe005 00b0 */
1494
1495 } SAMR_Q_CREATE_USER;
1496
1497
1498 /* SAMR_R_CREATE_USER - probably a create */
1499 typedef struct r_samr_create_user_info
1500 {
1501         POLICY_HND user_pol;       /* policy handle associated with user */
1502
1503         uint32 access_granted;
1504         uint32 user_rid;      /* user RID */
1505         NTSTATUS status;         /* return status */
1506
1507 } SAMR_R_CREATE_USER;
1508
1509
1510 /* SAMR_Q_DELETE_DOM_USER - delete domain user */
1511 typedef struct q_samr_delete_dom_user_info
1512 {
1513     POLICY_HND user_pol;          /* policy handle */
1514
1515 } SAMR_Q_DELETE_DOM_USER;
1516
1517
1518 /* SAMR_R_DELETE_DOM_USER - delete domain user */
1519 typedef struct r_samr_delete_dom_user_info
1520 {
1521         POLICY_HND pol;       /* policy handle */
1522         NTSTATUS status;        /* return status */
1523
1524 } SAMR_R_DELETE_DOM_USER;
1525
1526
1527 /* SAMR_Q_QUERY_GROUPMEM - query group members */
1528 typedef struct q_samr_query_groupmem_info
1529 {
1530         POLICY_HND group_pol;        /* policy handle */
1531
1532 } SAMR_Q_QUERY_GROUPMEM;
1533
1534
1535 /* SAMR_R_QUERY_GROUPMEM - query group members */
1536 typedef struct r_samr_query_groupmem_info
1537 {
1538         uint32 ptr;
1539         uint32 num_entries;
1540
1541         uint32 ptr_rids;
1542         uint32 ptr_attrs;
1543
1544         uint32 num_rids;
1545         uint32 *rid;
1546
1547         uint32 num_attrs;
1548         uint32 *attr;
1549
1550         NTSTATUS status;
1551
1552 } SAMR_R_QUERY_GROUPMEM;
1553
1554
1555 /* SAMR_Q_DEL_GROUPMEM - probably an del group member */
1556 typedef struct q_samr_del_group_mem_info
1557 {
1558         POLICY_HND pol;       /* policy handle */
1559         uint32 rid;         /* rid */
1560
1561 } SAMR_Q_DEL_GROUPMEM;
1562
1563
1564 /* SAMR_R_DEL_GROUPMEM - probably an del group member */
1565 typedef struct r_samr_del_group_mem_info
1566 {
1567         NTSTATUS status;         /* return status */
1568
1569 } SAMR_R_DEL_GROUPMEM;
1570
1571
1572 /* SAMR_Q_ADD_GROUPMEM - probably an add group member */
1573 typedef struct q_samr_add_group_mem_info
1574 {
1575         POLICY_HND pol;       /* policy handle */
1576
1577         uint32 rid;         /* rid */
1578         uint32 unknown;     /* 0x0000 0005 */
1579
1580 } SAMR_Q_ADD_GROUPMEM;
1581
1582
1583 /* SAMR_R_ADD_GROUPMEM - probably an add group member */
1584 typedef struct r_samr_add_group_mem_info
1585 {
1586         NTSTATUS status;         /* return status */
1587
1588 } SAMR_R_ADD_GROUPMEM;
1589
1590
1591 /* SAMR_Q_OPEN_GROUP - probably an open */
1592 typedef struct q_samr_open_group_info
1593 {
1594         POLICY_HND domain_pol;       /* policy handle */
1595         uint32 access_mask;         /* 0x0000 0001, 0x0000 0003, 0x0000 001f */
1596         uint32 rid_group;        /* rid */
1597
1598 } SAMR_Q_OPEN_GROUP;
1599
1600
1601 /* SAMR_R_OPEN_GROUP - probably an open */
1602 typedef struct r_samr_open_group_info
1603 {
1604         POLICY_HND pol;       /* policy handle */
1605         NTSTATUS status;         /* return status */
1606
1607 } SAMR_R_OPEN_GROUP;
1608
1609
1610 /* SAMR_Q_QUERY_ALIASMEM - query alias members */
1611 typedef struct q_samr_query_aliasmem_info
1612 {
1613         POLICY_HND alias_pol;        /* policy handle */
1614
1615 } SAMR_Q_QUERY_ALIASMEM;
1616
1617
1618 /* SAMR_R_QUERY_ALIASMEM - query alias members */
1619 typedef struct r_samr_query_aliasmem_info
1620 {
1621         uint32 num_sids;
1622         uint32 ptr;
1623         uint32 num_sids1;
1624
1625         DOM_SID2 *sid;
1626
1627         NTSTATUS status;
1628
1629 } SAMR_R_QUERY_ALIASMEM;
1630
1631
1632 /* SAMR_Q_ADD_ALIASMEM - add alias member */
1633 typedef struct q_samr_add_alias_mem_info
1634 {
1635         POLICY_HND alias_pol;       /* policy handle */
1636
1637         DOM_SID2 sid; /* member sid to be added to the alias */
1638
1639 } SAMR_Q_ADD_ALIASMEM;
1640
1641
1642 /* SAMR_R_ADD_ALIASMEM - add alias member */
1643 typedef struct r_samr_add_alias_mem_info
1644 {
1645         NTSTATUS status;         /* return status */
1646
1647 } SAMR_R_ADD_ALIASMEM;
1648
1649
1650 /* SAMR_Q_DEL_ALIASMEM - add an add alias member */
1651 typedef struct q_samr_del_alias_mem_info
1652 {
1653         POLICY_HND alias_pol;       /* policy handle */
1654
1655         DOM_SID2 sid; /* member sid to be added to alias */
1656
1657 } SAMR_Q_DEL_ALIASMEM;
1658
1659
1660 /* SAMR_R_DEL_ALIASMEM - delete alias member */
1661 typedef struct r_samr_del_alias_mem_info
1662 {
1663         NTSTATUS status;         /* return status */
1664
1665 } SAMR_R_DEL_ALIASMEM;
1666
1667
1668
1669 /* SAMR_Q_OPEN_ALIAS - probably an open */
1670 typedef struct q_samr_open_alias_info
1671 {
1672         POLICY_HND dom_pol;
1673
1674         uint32 access_mask;         
1675         uint32 rid_alias;
1676
1677 } SAMR_Q_OPEN_ALIAS;
1678
1679
1680 /* SAMR_R_OPEN_ALIAS - probably an open */
1681 typedef struct r_samr_open_alias_info
1682 {
1683         POLICY_HND pol;       /* policy handle */
1684         NTSTATUS status;         /* return status */
1685
1686 } SAMR_R_OPEN_ALIAS;
1687
1688
1689 /* SAMR_Q_CONNECT_ANON - probably an open */
1690 typedef struct q_samr_connect_anon_info
1691 {
1692         uint32 ptr;                  /* ptr? */
1693         uint16 unknown_0;            /* 0x005c */
1694         uint16 unknown_1;            /* 0x0001 */
1695         uint32 access_mask;
1696
1697 } SAMR_Q_CONNECT_ANON;
1698
1699 /* SAMR_R_CONNECT_ANON - probably an open */
1700 typedef struct r_samr_connect_anon_info
1701 {
1702         POLICY_HND connect_pol;       /* policy handle */
1703         NTSTATUS status;         /* return status */
1704
1705 } SAMR_R_CONNECT_ANON;
1706
1707 /* SAMR_Q_CONNECT - probably an open */
1708 typedef struct q_samr_connect_info
1709 {
1710         uint32 ptr_srv_name;         /* pointer (to server name?) */
1711         UNISTR2 uni_srv_name;        /* unicode server name starting with '\\' */
1712
1713         uint32 access_mask;            
1714
1715 } SAMR_Q_CONNECT;
1716
1717
1718 /* SAMR_R_CONNECT - probably an open */
1719 typedef struct r_samr_connect_info
1720 {
1721     POLICY_HND connect_pol;       /* policy handle */
1722         NTSTATUS status;         /* return status */
1723
1724 } SAMR_R_CONNECT;
1725
1726 /* SAMR_Q_CONNECT4 */
1727 typedef struct q_samr_connect4_info
1728 {
1729         uint32 ptr_srv_name; /* pointer to server name */
1730         UNISTR2 uni_srv_name;
1731
1732         uint32 unk_0; /* possible server name type, 1 for IP num, 2 for name */
1733         uint32 access_mask;
1734 } SAMR_Q_CONNECT4;
1735
1736 /* SAMR_R_CONNECT4 - same format as connect */
1737 typedef struct r_samr_connect_info SAMR_R_CONNECT4;       
1738
1739 /* SAMR_Q_GET_DOM_PWINFO */
1740 typedef struct q_samr_get_dom_pwinfo
1741 {
1742         uint32 ptr; 
1743         UNIHDR  hdr_srv_name;
1744         UNISTR2 uni_srv_name;
1745
1746 } SAMR_Q_GET_DOM_PWINFO;
1747
1748 /* SAMR_R_GET_DOM_PWINFO */
1749 typedef struct r_samr_get_dom_pwinfo
1750 {
1751         /*
1752          * See Samba4 IDL
1753          */
1754         uint16 unk_0;
1755         uint32 unk_1;
1756         NTSTATUS status;
1757
1758 } SAMR_R_GET_DOM_PWINFO;
1759
1760 /* SAMR_ENC_PASSWD */
1761 typedef struct enc_passwd_info
1762 {
1763         uint32 ptr;
1764         uint8 pass[516];
1765
1766 } SAMR_ENC_PASSWD;
1767
1768 /* SAMR_ENC_HASH */
1769 typedef struct enc_hash_info
1770 {
1771         uint32 ptr;
1772         uint8 hash[16];
1773
1774 } SAMR_ENC_HASH;
1775
1776 /* SAMR_Q_CHGPASSWD_USER */
1777 typedef struct q_samr_chgpasswd_user_info
1778 {
1779         uint32 ptr_0;
1780
1781         UNIHDR hdr_dest_host; /* server name unicode header */
1782         UNISTR2 uni_dest_host; /* server name unicode string */
1783
1784         UNIHDR hdr_user_name;    /* username unicode string header */
1785         UNISTR2 uni_user_name;    /* username unicode string */
1786
1787         SAMR_ENC_PASSWD nt_newpass;
1788         SAMR_ENC_HASH nt_oldhash;
1789
1790         uint32 unknown; /* 0x0000 0001 */
1791
1792         SAMR_ENC_PASSWD lm_newpass;
1793         SAMR_ENC_HASH lm_oldhash;
1794
1795 } SAMR_Q_CHGPASSWD_USER;
1796
1797 /* SAMR_R_CHGPASSWD_USER */
1798 typedef struct r_samr_chgpasswd_user_info
1799 {
1800         NTSTATUS status; /* 0 == OK, C000006A (NT_STATUS_WRONG_PASSWORD) */
1801
1802 } SAMR_R_CHGPASSWD_USER;
1803
1804
1805 /* SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN */
1806 typedef struct q_samr_remove_sid_foreign_domain_info
1807 {
1808         POLICY_HND dom_pol;   /* policy handle */
1809         DOM_SID2 sid;         /* SID */
1810
1811 } SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN;
1812
1813
1814 /* SAMR_R_REMOVE_SID_FOREIGN_DOMAIN */
1815 typedef struct r_samr_remove_sid_foreign_domain_info
1816 {
1817         NTSTATUS status;         /* return status */
1818
1819 } SAMR_R_REMOVE_SID_FOREIGN_DOMAIN;
1820
1821
1822
1823 /* these are from the old rpc_samr.h - they are needed while the merge
1824    is still going on */
1825 #define MAX_SAM_SIDS 15
1826
1827 /* DOM_SID3 - security id */
1828 typedef struct sid_info_3
1829 {
1830         uint16 len; /* length, bytes, including length of len :-) */
1831         /* uint8  pad[2]; */
1832         
1833         DOM_SID sid;
1834
1835 } DOM_SID3;
1836
1837 /* SAMR_Q_UNKNOWN_2E */
1838 typedef struct q_samr_unknown_2e_info
1839 {
1840         POLICY_HND domain_pol;   /* policy handle */
1841         uint16 switch_value;
1842
1843 } SAMR_Q_UNKNOWN_2E;
1844
1845 /* SAMR_R_UNKNOWN_2E */
1846 typedef struct r_samr_unknown_2e_info
1847 {
1848         uint32 ptr_0;
1849         uint16 switch_value;
1850         SAM_UNK_CTR *ctr;
1851         NTSTATUS status;         /* return status */
1852
1853 } SAMR_R_UNKNOWN_2E;
1854
1855 /* SAMR_Q_SET_DOMAIN_INFO */
1856 typedef struct q_samr_set_domain_info
1857 {
1858         POLICY_HND domain_pol;   /* policy handle */
1859         uint16 switch_value0;
1860         uint16 switch_value;
1861         SAM_UNK_CTR *ctr;
1862
1863 } SAMR_Q_SET_DOMAIN_INFO;
1864
1865 /* SAMR_R_SET_DOMAIN_INFO */
1866 typedef struct r_samr_set_domain_info
1867 {
1868         NTSTATUS status;         /* return status */
1869
1870 } SAMR_R_SET_DOMAIN_INFO;
1871
1872 #endif /* _RPC_SAMR_H */