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