* fix RemoveSidForeignDomain() ; bug 252
[samba.git] / 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 #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 unknown_3; /* 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         uint32 unknown_3; /* 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         uint32 unknown_6; /* 0x0000 04ec */
339         uint32 padding4;
340
341         LOGON_HRS logon_hrs;
342
343 } SAM_USER_INFO_21;
344
345 #define PASS_MUST_CHANGE_AT_NEXT_LOGON  0x01
346 #define PASS_DONT_CHANGE_AT_NEXT_LOGON  0x00
347
348 /* SAM_USER_INFO_20 */
349 typedef struct sam_user_info_20
350 {
351         UNIHDR hdr_munged_dial ; /* munged path name and dial-back tel number */
352
353         UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel number */
354
355 } SAM_USER_INFO_20;
356
357 /* SAM_USER_INFO_12 */
358 typedef struct sam_user_info_12
359 {
360         uint8 lm_pwd[16];    /* lm user passwords */
361         uint8 nt_pwd[16];    /* nt user passwords */
362
363         uint8 lm_pwd_active; 
364         uint8 nt_pwd_active; 
365
366 } SAM_USER_INFO_12;
367
368 /* SAM_USER_INFO_11 */
369 typedef struct sam_user_info_11
370 {
371         uint8  padding_0[16];  /* 0 - padding 16 bytes */
372         NTTIME expiry;         /* expiry time or something? */
373         uint8  padding_1[24];  /* 0 - padding 24 bytes */
374
375         UNIHDR hdr_mach_acct;  /* unicode header for machine account */
376         uint32 padding_2;      /* 0 - padding 4 bytes */
377
378         uint32 ptr_1;          /* pointer */
379         uint8  padding_3[32];  /* 0 - padding 32 bytes */
380         uint32 padding_4;      /* 0 - padding 4 bytes */
381
382         uint32 ptr_2;          /* pointer */
383         uint32 padding_5;      /* 0 - padding 4 bytes */
384
385         uint32 ptr_3;          /* pointer */
386         uint8  padding_6[32];  /* 0 - padding 32 bytes */
387
388         uint32 rid_user;       /* user RID */
389         uint32 rid_group;      /* group RID */
390
391         uint16 acct_ctrl;      /* 0080 - ACB_XXXX */
392         uint16 unknown_3;      /* 16 bit padding */
393
394         uint16 unknown_4;      /* 0x003f      - 16 bit unknown */
395         uint16 unknown_5;      /* 0x003c      - 16 bit unknown */
396
397         uint8  padding_7[16];  /* 0 - padding 16 bytes */
398         uint32 padding_8;      /* 0 - padding 4 bytes */
399         
400         UNISTR2 uni_mach_acct; /* unicode string for machine account */
401
402         uint8  padding_9[48];  /* 0 - padding 48 bytes */
403
404 } SAM_USER_INFO_11;
405
406
407 /* SAM_USER_INFO_10 */
408 typedef struct sam_user_info_10
409 {
410         uint32 acb_info;
411
412 } SAM_USER_INFO_10;
413
414
415
416 /* SAMR_Q_CLOSE_HND - probably a policy handle close */
417 typedef struct q_samr_close_hnd_info
418 {
419     POLICY_HND pol;          /* policy handle */
420
421 } SAMR_Q_CLOSE_HND;
422
423
424 /* SAMR_R_CLOSE_HND - probably a policy handle close */
425 typedef struct r_samr_close_hnd_info
426 {
427         POLICY_HND pol;       /* policy handle */
428         NTSTATUS status;         /* return status */
429
430 } SAMR_R_CLOSE_HND;
431
432
433 /****************************************************************************
434 SAMR_Q_GET_USRDOM_PWINFO - a "set user info" occurs just after this
435 *****************************************************************************/
436
437 /* SAMR_Q_GET_USRDOM_PWINFO */
438 typedef struct q_samr_usrdom_pwinfo_info
439 {
440         POLICY_HND user_pol;          /* policy handle */
441
442 } SAMR_Q_GET_USRDOM_PWINFO;
443
444
445 /****************************************************************************
446 SAMR_R_GET_USRDOM_PWINFO - a "set user info" occurs just after this
447 *****************************************************************************/
448
449 /* SAMR_R_GET_USRDOM_PWINFO */
450 typedef struct r_samr_usrdom_pwinfo_info
451 {
452         uint16 unknown_0; /* 0000 */
453         uint16 unknown_1; /* 0x0016 or 0x0015 */
454         uint32 unknown_2; /* 0x0000 0000 */
455         NTSTATUS status; 
456
457 } SAMR_R_GET_USRDOM_PWINFO;
458
459 /****************************************************************************
460 SAMR_Q_SET_SEC_OBJ - info level 4.
461 *****************************************************************************/
462
463 /* SAMR_Q_SET_SEC_OBJ - */
464 typedef struct q_samr_set_sec_obj_info
465 {
466         POLICY_HND pol;          /* policy handle */
467         uint32 sec_info;         /* xxxx_SECURITY_INFORMATION 0x0000 0004 */
468         SEC_DESC_BUF *buf;
469
470 } SAMR_Q_SET_SEC_OBJ;
471
472 /* SAMR_R_SET_SEC_OBJ - */
473 typedef struct r_samr_set_sec_obj_info
474 {
475         NTSTATUS status;         /* return status */
476
477 } SAMR_R_SET_SEC_OBJ;
478
479
480 /****************************************************************************
481 SAMR_Q_QUERY_SEC_OBJ - info level 4.  returns SIDs.
482 *****************************************************************************/
483
484 /* SAMR_Q_QUERY_SEC_OBJ - probably get domain info... */
485 typedef struct q_samr_query_sec_obj_info
486 {
487         POLICY_HND user_pol;          /* policy handle */
488         uint32 sec_info;     /* xxxx_SECURITY_INFORMATION 0x0000 0004 */
489
490 } SAMR_Q_QUERY_SEC_OBJ;
491
492 /* SAMR_R_QUERY_SEC_OBJ - probably an open */
493 typedef struct r_samr_query_sec_obj_info
494 {
495         uint32 ptr;
496         SEC_DESC_BUF *buf;
497
498         NTSTATUS status;         /* return status */
499
500 } SAMR_R_QUERY_SEC_OBJ;
501
502
503 /****************************************************************************
504 SAMR_Q_QUERY_DOMAIN_INFO - probably a query on domain group info.
505 *****************************************************************************/
506
507 /* SAMR_Q_QUERY_DOMAIN_INFO - */
508 typedef struct q_samr_query_domain_info
509 {
510         POLICY_HND domain_pol;   /* policy handle */
511         uint16 switch_value;     /* 0x0002, 0x0001 */
512
513 } SAMR_Q_QUERY_DOMAIN_INFO;
514
515 typedef struct sam_unknown_info_3_info
516 {
517         NTTIME logout;  
518         /* 0x8000 0000 */ /* DON'T forcibly disconnect remote users from server when logon hours expire*/
519
520         /* 0x0000 0000 */ /* forcibly disconnect remote users from server when logon hours expire*/
521
522 } SAM_UNK_INFO_3;
523
524 typedef struct sam_unknown_info_6_info
525 {
526         uint32 unknown_0; /* 0x0000 0000 */
527
528         uint32 ptr_0;     /* pointer to unknown structure */
529         uint8  padding[12]; /* 12 bytes zeros */
530
531 } SAM_UNK_INFO_6;
532
533 typedef struct sam_unknown_info_7_info
534 {
535         uint16 unknown_0; /* 0x0003 */
536
537 } SAM_UNK_INFO_7;
538
539 typedef struct sam_unknown_info_12_inf
540 {
541         NTTIME duration;
542         NTTIME reset_count;
543         uint16 bad_attempt_lockout;
544
545 } SAM_UNK_INFO_12;
546
547 typedef struct sam_unknown_info_5_inf
548 {
549         UNIHDR hdr_server; /* server name unicode header */
550         UNISTR2 uni_server; /* server name unicode string */
551
552 } SAM_UNK_INFO_5;
553
554 typedef struct sam_unknown_info_2_inf
555 {
556         uint32 unknown_0; /* 0x0000 0000 */
557         uint32 unknown_1; /* 0x8000 0000 */
558         uint32 unknown_2; /* 0x0000 0000 */
559
560         uint32 ptr_0;     /* pointer to unknown structure */
561         UNIHDR hdr_domain; /* domain name unicode header */
562         UNIHDR hdr_server; /* server name unicode header */
563
564         /* put all the data in here, at the moment, including what the above
565            pointer is referring to
566          */
567
568         uint32 seq_num; /* some sort of incrementing sequence number? */
569         uint32 unknown_3; /* 0x0000 0000 */
570         
571         uint32 unknown_4; /* 0x0000 0001 */
572         uint32 unknown_5; /* 0x0000 0003 */
573         uint32 unknown_6; /* 0x0000 0001 */
574         uint32 num_domain_usrs; /* number of users in domain */
575         uint32 num_domain_grps; /* number of domain groups in domain */
576         uint32 num_local_grps; /* number of local groups in domain */
577
578         uint8 padding[12]; /* 12 bytes zeros */
579
580         UNISTR2 uni_domain; /* domain name unicode string */
581         UNISTR2 uni_server; /* server name unicode string */
582
583 } SAM_UNK_INFO_2;
584
585 typedef struct sam_unknown_info_1_inf
586 {
587         uint16 min_length_password;
588         uint16 password_history;
589         uint32 flag;
590         NTTIME expire;
591         NTTIME min_passwordage;
592
593 } SAM_UNK_INFO_1;
594
595
596 typedef struct sam_unknown_ctr_info
597 {
598         union
599         {
600                 SAM_UNK_INFO_1 inf1;
601                 SAM_UNK_INFO_2 inf2;
602                 SAM_UNK_INFO_3 inf3;
603                 SAM_UNK_INFO_5 inf5;
604                 SAM_UNK_INFO_6 inf6;
605                 SAM_UNK_INFO_7 inf7;
606                 SAM_UNK_INFO_12 inf12;
607
608         } info;
609
610 } SAM_UNK_CTR;
611
612
613 /* SAMR_R_QUERY_DOMAIN_INFO - */
614 typedef struct r_samr_query_domain_info
615 {
616         uint32 ptr_0;
617         uint16 switch_value; /* same as in query */
618
619         SAM_UNK_CTR *ctr;
620
621         NTSTATUS status;         /* return status */
622
623 } SAMR_R_QUERY_DOMAIN_INFO;
624
625
626 /* SAMR_Q_LOOKUP_DOMAIN - obtain SID for a local domain */
627 typedef struct q_samr_lookup_domain_info
628 {
629         POLICY_HND connect_pol;
630
631         UNIHDR  hdr_domain;
632         UNISTR2 uni_domain;
633
634 } SAMR_Q_LOOKUP_DOMAIN;
635
636
637 /* SAMR_R_LOOKUP_DOMAIN */
638 typedef struct r_samr_lookup_domain_info
639 {
640         uint32   ptr_sid;
641         DOM_SID2 dom_sid;
642
643         NTSTATUS status;
644
645 } SAMR_R_LOOKUP_DOMAIN;
646
647
648 /****************************************************************************
649 SAMR_Q_OPEN_DOMAIN - unknown_0 values seen associated with SIDs:
650
651 0x0000 03f1 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
652 0x0000 0200 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
653 *****************************************************************************/
654
655 /* SAMR_Q_OPEN_DOMAIN */
656 typedef struct q_samr_open_domain_info
657 {
658         POLICY_HND pol;   /* policy handle */
659         uint32 flags;               /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - flags? */
660         DOM_SID2 dom_sid;         /* domain SID */
661
662 } SAMR_Q_OPEN_DOMAIN;
663
664
665 /* SAMR_R_OPEN_DOMAIN - probably an open */
666 typedef struct r_samr_open_domain_info
667 {
668         POLICY_HND domain_pol; /* policy handle associated with the SID */
669         NTSTATUS status;         /* return status */
670
671 } SAMR_R_OPEN_DOMAIN;
672
673 #define MAX_SAM_ENTRIES_W2K 0x400
674 #define MAX_SAM_ENTRIES_W95 50
675 /* The following should be the greater of the preceeding two. */
676 #define MAX_SAM_ENTRIES MAX_SAM_ENTRIES_W2K
677
678 typedef struct samr_entry_info
679 {
680         uint32 rid;
681         UNIHDR hdr_name;
682
683 } SAM_ENTRY;
684
685
686 /* SAMR_Q_ENUM_DOMAINS - SAM rids and names */
687 typedef struct q_samr_enum_domains_info
688 {
689         POLICY_HND pol;     /* policy handle */
690
691         uint32 start_idx;   /* enumeration handle */
692         uint32 max_size;    /* 0x0000 ffff */
693
694 } SAMR_Q_ENUM_DOMAINS;
695
696 /* SAMR_R_ENUM_DOMAINS - SAM rids and Domain names */
697 typedef struct r_samr_enum_domains_info
698 {
699         uint32 next_idx;     /* next starting index required for enum */
700         uint32 ptr_entries1;  
701
702         uint32 num_entries2;
703         uint32 ptr_entries2;
704
705         uint32 num_entries3;
706
707         SAM_ENTRY *sam;
708         UNISTR2 *uni_dom_name;
709
710         uint32 num_entries4;
711
712         NTSTATUS status;
713
714 } SAMR_R_ENUM_DOMAINS;
715
716 /* SAMR_Q_ENUM_DOM_USERS - SAM rids and names */
717 typedef struct q_samr_enum_dom_users_info
718 {
719         POLICY_HND pol;          /* policy handle */
720
721         uint32 start_idx;   /* number of values (0 indicates unlimited?) */
722         uint16 acb_mask;          /* 0x0000 indicates all */
723         uint16 unknown_1;         /* 0x0000 */
724
725         uint32 max_size;              /* 0x0000 ffff */
726
727 } SAMR_Q_ENUM_DOM_USERS;
728
729
730 /* SAMR_R_ENUM_DOM_USERS - SAM rids and names */
731 typedef struct r_samr_enum_dom_users_info
732 {
733         uint32 next_idx;     /* next starting index required for enum */
734         uint32 ptr_entries1;  
735
736         uint32 num_entries2;
737         uint32 ptr_entries2;
738
739         uint32 num_entries3;
740
741         SAM_ENTRY *sam;
742         UNISTR2 *uni_acct_name;
743
744         uint32 num_entries4;
745
746         NTSTATUS status;
747
748 } SAMR_R_ENUM_DOM_USERS;
749
750
751 /* SAMR_Q_ENUM_DOM_GROUPS - SAM rids and names */
752 typedef struct q_samr_enum_dom_groups_info
753 {
754         POLICY_HND pol;          /* policy handle */
755
756         /* this is possibly an enumeration context handle... */
757         uint32 start_idx;         /* 0x0000 0000 */
758
759         uint32 max_size;              /* 0x0000 ffff */
760
761 } SAMR_Q_ENUM_DOM_GROUPS;
762
763
764 /* SAMR_R_ENUM_DOM_GROUPS - SAM rids and names */
765 typedef struct r_samr_enum_dom_groups_info
766 {
767         uint32 next_idx;
768         uint32 ptr_entries1;
769
770         uint32 num_entries2;
771         uint32 ptr_entries2;
772
773         uint32 num_entries3;
774
775         SAM_ENTRY *sam;
776         UNISTR2 *uni_grp_name;
777
778         uint32 num_entries4;
779
780         NTSTATUS status;
781
782 } SAMR_R_ENUM_DOM_GROUPS;
783
784
785 /* SAMR_Q_ENUM_DOM_ALIASES - SAM rids and names */
786 typedef struct q_samr_enum_dom_aliases_info
787 {
788         POLICY_HND pol;          /* policy handle */
789
790         /* this is possibly an enumeration context handle... */
791         uint32 start_idx;         /* 0x0000 0000 */
792
793         uint32 max_size;              /* 0x0000 ffff */
794
795 } SAMR_Q_ENUM_DOM_ALIASES;
796
797
798 /* SAMR_R_ENUM_DOM_ALIASES - SAM rids and names */
799 typedef struct r_samr_enum_dom_aliases_info
800 {
801         uint32 next_idx;
802         uint32 ptr_entries1;
803
804         uint32 num_entries2;
805         uint32 ptr_entries2;
806
807         uint32 num_entries3;
808
809         SAM_ENTRY *sam;
810         UNISTR2 *uni_grp_name;
811
812         uint32 num_entries4;
813
814         NTSTATUS status;
815
816 } SAMR_R_ENUM_DOM_ALIASES;
817
818
819 /* -- Level 1 Display Info - User Information -- */
820
821 typedef struct samr_entry_info1
822 {
823         uint32 user_idx;
824
825         uint32 rid_user;
826         uint16 acb_info;
827
828         UNIHDR hdr_acct_name;
829         UNIHDR hdr_user_name;
830         UNIHDR hdr_user_desc;
831
832 } SAM_ENTRY1;
833
834 typedef struct samr_str_entry_info1
835 {
836         UNISTR2 uni_acct_name;
837         UNISTR2 uni_full_name;
838         UNISTR2 uni_acct_desc;
839
840 } SAM_STR1;
841
842 typedef struct sam_entry_info_1
843 {
844         SAM_ENTRY1 *sam;
845         SAM_STR1   *str;
846
847 } SAM_DISPINFO_1;
848
849
850 /* -- Level 2 Display Info - Trust Account Information -- */
851
852 typedef struct samr_entry_info2
853 {
854         uint32 user_idx;
855
856         uint32 rid_user;
857         uint16 acb_info;
858
859         UNIHDR hdr_srv_name;
860         UNIHDR hdr_srv_desc;
861
862 } SAM_ENTRY2;
863
864 typedef struct samr_str_entry_info2
865 {
866         UNISTR2 uni_srv_name;
867         UNISTR2 uni_srv_desc;
868
869 } SAM_STR2;
870
871 typedef struct sam_entry_info_2
872 {
873         SAM_ENTRY2 *sam;
874         SAM_STR2   *str;
875
876 } SAM_DISPINFO_2;
877
878
879 /* -- Level 3 Display Info - Domain Group Information -- */
880
881 typedef struct samr_entry_info3
882 {
883         uint32 grp_idx;
884
885         uint32 rid_grp;
886         uint32 attr;     /* SE_GROUP_xxx, usually 7 */
887
888         UNIHDR hdr_grp_name;
889         UNIHDR hdr_grp_desc;
890
891 } SAM_ENTRY3;
892
893 typedef struct samr_str_entry_info3
894 {
895         UNISTR2 uni_grp_name;
896         UNISTR2 uni_grp_desc;
897
898 } SAM_STR3;
899
900 typedef struct sam_entry_info_3
901 {
902         SAM_ENTRY3 *sam;
903         SAM_STR3   *str;
904
905 } SAM_DISPINFO_3;
906
907
908 /* -- Level 4 Display Info - User List (ASCII) -- */
909
910 typedef struct samr_entry_info4
911 {
912         uint32 user_idx;
913         STRHDR hdr_acct_name;
914
915 } SAM_ENTRY4;
916
917 typedef struct samr_str_entry_info4
918 {
919         STRING2 acct_name;
920
921 } SAM_STR4;
922
923 typedef struct sam_entry_info_4
924 {
925         SAM_ENTRY4 *sam;
926         SAM_STR4   *str;
927
928 } SAM_DISPINFO_4;
929
930
931 /* -- Level 5 Display Info - Group List (ASCII) -- */
932
933 typedef struct samr_entry_info5
934 {
935         uint32 grp_idx;
936         STRHDR hdr_grp_name;
937
938 } SAM_ENTRY5;
939
940 typedef struct samr_str_entry_info5
941 {
942         STRING2 grp_name;
943
944 } SAM_STR5;
945
946 typedef struct sam_entry_info_5
947 {
948         SAM_ENTRY5 *sam;
949         SAM_STR5   *str;
950
951 } SAM_DISPINFO_5;
952
953
954 typedef struct sam_dispinfo_ctr_info
955 {
956         union
957         {
958                 SAM_DISPINFO_1 *info1; /* users/names/descriptions */
959                 SAM_DISPINFO_2 *info2; /* trust accounts */
960                 SAM_DISPINFO_3 *info3; /* domain groups/descriptions */
961                 SAM_DISPINFO_4 *info4; /* user list (ASCII) - used by Win95 */
962                 SAM_DISPINFO_5 *info5; /* group list (ASCII) */
963                 void       *info; /* allows assignment without typecasting, */
964
965         } sam;
966
967 } SAM_DISPINFO_CTR;
968
969
970 /* SAMR_Q_QUERY_DISPINFO - SAM rids, names and descriptions */
971 typedef struct q_samr_query_disp_info
972 {
973         POLICY_HND domain_pol;
974
975         uint16 switch_level;    /* see SAM_DISPINFO_CTR above */
976         /* align */
977
978         uint32 start_idx;       /* start enumeration index */
979         uint32 max_entries;     /* maximum number of entries to return */
980         uint32 max_size;        /* recommended data size; if exceeded server
981                                    should return STATUS_MORE_ENTRIES */
982
983 } SAMR_Q_QUERY_DISPINFO;
984
985
986 /* SAMR_R_QUERY_DISPINFO  */
987 typedef struct r_samr_query_dispinfo_info
988 {
989         uint32 total_size;     /* total data size for all matching entries
990                                   (0 = uncalculated) */
991         uint32 data_size;      /* actual data size returned = size of SAM_ENTRY
992                                   structures + total length of strings */
993
994         uint16 switch_level;   /* see SAM_DISPINFO_CTR above */
995         /* align */
996
997         uint32 num_entries;    /* number of entries returned */
998         uint32 ptr_entries;
999         uint32 num_entries2;
1000
1001         SAM_DISPINFO_CTR *ctr;
1002
1003         NTSTATUS status;
1004
1005 } SAMR_R_QUERY_DISPINFO;
1006
1007
1008 /* SAMR_Q_DELETE_DOM_GROUP - delete domain group */
1009 typedef struct q_samr_delete_dom_group_info
1010 {
1011     POLICY_HND group_pol;          /* policy handle */
1012
1013 } SAMR_Q_DELETE_DOM_GROUP;
1014
1015
1016 /* SAMR_R_DELETE_DOM_GROUP - delete domain group */
1017 typedef struct r_samr_delete_dom_group_info
1018 {
1019         POLICY_HND pol;       /* policy handle */
1020         NTSTATUS status;        /* return status */
1021
1022 } SAMR_R_DELETE_DOM_GROUP;
1023
1024
1025 /* SAMR_Q_CREATE_DOM_GROUP - SAM create group */
1026 typedef struct q_samr_create_dom_group_info
1027 {
1028         POLICY_HND pol;        /* policy handle */
1029
1030         UNIHDR hdr_acct_desc;
1031         UNISTR2 uni_acct_desc;
1032
1033         uint32 access_mask;    
1034
1035 } SAMR_Q_CREATE_DOM_GROUP;
1036
1037 /* SAMR_R_CREATE_DOM_GROUP - SAM create group */
1038 typedef struct r_samr_create_dom_group_info
1039 {
1040         POLICY_HND pol;        /* policy handle */
1041
1042         uint32 rid;    
1043         NTSTATUS status;    
1044
1045 } SAMR_R_CREATE_DOM_GROUP;
1046
1047 /* SAMR_Q_QUERY_GROUPINFO - SAM Group Info */
1048 typedef struct q_samr_query_group_info
1049 {
1050         POLICY_HND pol;        /* policy handle */
1051
1052         uint16 switch_level;    /* 0x0001 seen */
1053
1054 } SAMR_Q_QUERY_GROUPINFO;
1055
1056 typedef struct samr_group_info1
1057 {
1058         UNIHDR hdr_acct_name;
1059
1060         uint32 unknown_1; /* 0x0000 0003 - number of group members? */
1061         uint32 num_members; /* 0x0000 0001 - number of group members? */
1062
1063         UNIHDR hdr_acct_desc;
1064
1065         UNISTR2 uni_acct_name;
1066         UNISTR2 uni_acct_desc;
1067
1068 } GROUP_INFO1;
1069
1070 typedef struct samr_group_info3
1071 {
1072         uint32 unknown_1; /* 0x0000 0003 - number of group members? */
1073
1074 } GROUP_INFO3;
1075
1076 typedef struct samr_group_info4
1077 {
1078         UNIHDR hdr_acct_desc;
1079         UNISTR2 uni_acct_desc;
1080
1081 } GROUP_INFO4;
1082
1083 /* GROUP_INFO_CTR */
1084 typedef struct group_info_ctr
1085 {
1086         uint16 switch_value1;
1087
1088         union
1089         {
1090                 GROUP_INFO1 info1;
1091                 GROUP_INFO3 info3;
1092                 GROUP_INFO4 info4;
1093
1094         } group;
1095
1096 } GROUP_INFO_CTR;
1097
1098 /* SAMR_R_QUERY_GROUPINFO - SAM Group Info */
1099 typedef struct r_samr_query_groupinfo_info
1100 {
1101         uint32 ptr;        
1102         GROUP_INFO_CTR *ctr;
1103
1104         NTSTATUS status;
1105
1106 } SAMR_R_QUERY_GROUPINFO;
1107
1108
1109 /* SAMR_Q_SET_GROUPINFO - SAM Group Info */
1110 typedef struct q_samr_set_group_info
1111 {
1112         POLICY_HND pol;        /* policy handle */
1113         GROUP_INFO_CTR *ctr;
1114
1115 } SAMR_Q_SET_GROUPINFO;
1116
1117 /* SAMR_R_SET_GROUPINFO - SAM Group Info */
1118 typedef struct r_samr_set_group_info
1119 {
1120         NTSTATUS status;
1121
1122 } SAMR_R_SET_GROUPINFO;
1123
1124
1125 /* SAMR_Q_DELETE_DOM_ALIAS - delete domain alias */
1126 typedef struct q_samr_delete_dom_alias_info
1127 {
1128     POLICY_HND alias_pol;          /* policy handle */
1129
1130 } SAMR_Q_DELETE_DOM_ALIAS;
1131
1132
1133 /* SAMR_R_DELETE_DOM_ALIAS - delete domain alias */
1134 typedef struct r_samr_delete_dom_alias_info
1135 {
1136         POLICY_HND pol;       /* policy handle */
1137         NTSTATUS status;        /* return status */
1138
1139 } SAMR_R_DELETE_DOM_ALIAS;
1140
1141
1142 /* SAMR_Q_CREATE_DOM_ALIAS - SAM create alias */
1143 typedef struct q_samr_create_dom_alias_info
1144 {
1145         POLICY_HND dom_pol;        /* policy handle */
1146
1147         UNIHDR hdr_acct_desc;
1148         UNISTR2 uni_acct_desc;
1149
1150         uint32 access_mask;    /* 0x001f000f */
1151
1152 } SAMR_Q_CREATE_DOM_ALIAS;
1153
1154 /* SAMR_R_CREATE_DOM_ALIAS - SAM create alias */
1155 typedef struct r_samr_create_dom_alias_info
1156 {
1157         POLICY_HND alias_pol;        /* policy handle */
1158
1159         uint32 rid;    
1160         NTSTATUS status;    
1161
1162 } SAMR_R_CREATE_DOM_ALIAS;
1163
1164 /* SAMR_Q_QUERY_ALIASINFO - SAM Alias Info */
1165 typedef struct q_samr_query_alias_info
1166 {
1167         POLICY_HND pol;        /* policy handle */
1168
1169         uint16 switch_level;    /* 0x0003 seen */
1170
1171 } SAMR_Q_QUERY_ALIASINFO;
1172
1173 typedef struct samr_alias_info1
1174 {
1175         UNIHDR hdr_acct_name;
1176         UNIHDR hdr_acct_desc;
1177         uint32 num_member;
1178         UNISTR2 uni_acct_name;
1179         UNISTR2 uni_acct_desc;
1180
1181 } ALIAS_INFO1;
1182
1183 typedef struct samr_alias_info3
1184 {
1185         UNIHDR hdr_acct_desc;
1186         UNISTR2 uni_acct_desc;
1187
1188 } ALIAS_INFO3;
1189
1190 /* ALIAS_INFO_CTR */
1191 typedef struct alias_info_ctr
1192 {
1193         uint16 switch_value1;
1194         uint16 switch_value2;
1195
1196         union
1197         {
1198                 ALIAS_INFO1 info1;
1199                 ALIAS_INFO3 info3;
1200
1201         } alias;
1202
1203 } ALIAS_INFO_CTR;
1204
1205 /* SAMR_R_QUERY_ALIASINFO - SAM alias info */
1206 typedef struct r_samr_query_aliasinfo_info
1207 {
1208         uint32 ptr;        
1209         ALIAS_INFO_CTR ctr;
1210
1211         NTSTATUS status;
1212
1213 } SAMR_R_QUERY_ALIASINFO;
1214
1215
1216 /* SAMR_Q_SET_ALIASINFO - SAM Alias Info */
1217 typedef struct q_samr_set_alias_info
1218 {
1219         POLICY_HND alias_pol;        /* policy handle */
1220         ALIAS_INFO_CTR ctr;
1221
1222 } SAMR_Q_SET_ALIASINFO;
1223
1224 /* SAMR_R_SET_ALIASINFO - SAM alias info */
1225 typedef struct r_samr_set_aliasinfo_info
1226 {
1227         NTSTATUS status;
1228
1229 } SAMR_R_SET_ALIASINFO;
1230
1231
1232 /* SAMR_Q_QUERY_USERGROUPS - */
1233 typedef struct q_samr_query_usergroup_info
1234 {
1235         POLICY_HND pol;          /* policy handle associated with unknown id */
1236
1237 } SAMR_Q_QUERY_USERGROUPS;
1238
1239 /* SAMR_R_QUERY_USERGROUPS - probably a get sam info */
1240 typedef struct r_samr_query_usergroup_info
1241 {
1242         uint32 ptr_0;            /* pointer */
1243         uint32 num_entries;      /* number of RID groups */
1244         uint32 ptr_1;            /* pointer */
1245         uint32 num_entries2;     /* number of RID groups */
1246
1247         DOM_GID *gid; /* group info */
1248
1249         NTSTATUS status;         /* return status */
1250
1251 } SAMR_R_QUERY_USERGROUPS;
1252
1253 /* SAM_USERINFO_CTR - sam user info */
1254 typedef struct sam_userinfo_ctr_info
1255 {
1256         uint16 switch_value;      
1257
1258         union
1259         {
1260                 SAM_USER_INFO_10 *id10; /* auth-level 0x10 */
1261                 SAM_USER_INFO_11 *id11; /* auth-level 0x11 */
1262                 SAM_USER_INFO_12 *id12; /* auth-level 0x12 */
1263                 SAM_USER_INFO_20 *id20; /* auth-level 20 */
1264                 SAM_USER_INFO_21 *id21; /* auth-level 21 */
1265                 SAM_USER_INFO_23 *id23; /* auth-level 0x17 */
1266                 SAM_USER_INFO_24 *id24; /* auth-level 0x18 */
1267                 SAM_USER_INFO_25 *id25; /* auth-level 0x19 */
1268                 void* id; /* to make typecasting easy */
1269
1270         } info;
1271
1272 } SAM_USERINFO_CTR;
1273
1274
1275 /* SAMR_Q_SET_USERINFO2 - set sam info */
1276 typedef struct q_samr_set_user_info2
1277 {
1278         POLICY_HND pol;          /* policy handle associated with user */
1279         uint16 switch_value;      /* 0x0010 */
1280
1281         SAM_USERINFO_CTR *ctr;
1282
1283 } SAMR_Q_SET_USERINFO2;
1284
1285 /* SAMR_R_SET_USERINFO2 - set sam info */
1286 typedef struct r_samr_set_user_info2
1287 {
1288         NTSTATUS status;         /* return status */
1289
1290 } SAMR_R_SET_USERINFO2;
1291
1292 /* SAMR_Q_SET_USERINFO - set sam info */
1293 typedef struct q_samr_set_user_info
1294 {
1295         POLICY_HND pol;          /* policy handle associated with user */
1296         uint16 switch_value;
1297         SAM_USERINFO_CTR *ctr;
1298
1299 } SAMR_Q_SET_USERINFO;
1300
1301 /* SAMR_R_SET_USERINFO - set sam info */
1302 typedef struct r_samr_set_user_info
1303 {
1304         NTSTATUS status;         /* return status */
1305
1306 } SAMR_R_SET_USERINFO;
1307
1308
1309 /* SAMR_Q_QUERY_USERINFO - probably a get sam info */
1310 typedef struct q_samr_query_user_info
1311 {
1312         POLICY_HND pol;          /* policy handle associated with unknown id */
1313         uint16 switch_value;         /* 0x0015, 0x0011 or 0x0010 - 16 bit unknown */
1314
1315 } SAMR_Q_QUERY_USERINFO;
1316
1317 /* SAMR_R_QUERY_USERINFO - probably a get sam info */
1318 typedef struct r_samr_query_user_info
1319 {
1320         uint32 ptr;            /* pointer */
1321         SAM_USERINFO_CTR *ctr;
1322
1323         NTSTATUS status;         /* return status */
1324
1325 } SAMR_R_QUERY_USERINFO;
1326
1327
1328 /****************************************************************************
1329 SAMR_Q_QUERY_USERALIASES - do a conversion from name to RID.
1330
1331 the policy handle allocated by an "samr open secret" call is associated
1332 with a SID.  this policy handle is what is queried here, *not* the SID
1333 itself.  the response to the lookup rids is relative to this SID.
1334 *****************************************************************************/
1335 /* SAMR_Q_QUERY_USERALIASES */
1336 typedef struct q_samr_query_useraliases_info
1337 {
1338         POLICY_HND pol;       /* policy handle */
1339
1340         uint32 num_sids1;      /* number of rids being looked up */
1341         uint32 ptr;            /* buffer pointer */
1342         uint32 num_sids2;      /* number of rids being looked up */
1343
1344         uint32   *ptr_sid; /* pointers to sids to be looked up */
1345         DOM_SID2 *sid    ; /* sids to be looked up. */
1346
1347 } SAMR_Q_QUERY_USERALIASES;
1348
1349
1350 /* SAMR_R_QUERY_USERALIASES */
1351 typedef struct r_samr_query_useraliases_info
1352 {
1353         uint32 num_entries;
1354         uint32 ptr; /* undocumented buffer pointer */
1355
1356         uint32 num_entries2; 
1357         uint32 *rid; /* domain RIDs being looked up */
1358
1359         NTSTATUS status; /* return code */
1360
1361 } SAMR_R_QUERY_USERALIASES;
1362
1363
1364 /****************************************************************************
1365 SAMR_Q_LOOKUP_NAMES - do a conversion from Names to RIDs+types.
1366 *****************************************************************************/
1367 /* SAMR_Q_LOOKUP_NAMES */
1368 typedef struct q_samr_lookup_names_info
1369 {
1370         POLICY_HND pol;       /* policy handle */
1371
1372         uint32 num_names1;      /* number of names being looked up */
1373         uint32 flags;           /* 0x0000 03e8 - unknown */
1374         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
1375         uint32 num_names2;      /* number of names being looked up */
1376
1377         UNIHDR  *hdr_name; /* unicode account name header */
1378         UNISTR2 *uni_name; /* unicode account name string */
1379
1380 } SAMR_Q_LOOKUP_NAMES;
1381
1382
1383 /* SAMR_R_LOOKUP_NAMES */
1384 typedef struct r_samr_lookup_names_info
1385 {
1386         uint32 num_rids1;      /* number of aliases being looked up */
1387         uint32 ptr_rids;       /* pointer to aliases */
1388         uint32 num_rids2;      /* number of aliases being looked up */
1389
1390         uint32 *rids; /* rids */
1391
1392         uint32 num_types1;      /* number of users in aliases being looked up */
1393         uint32 ptr_types;       /* pointer to users in aliases */
1394         uint32 num_types2;      /* number of users in aliases being looked up */
1395
1396         uint32 *types; /* SID_ENUM type */
1397
1398         NTSTATUS status; /* return code */
1399
1400 } SAMR_R_LOOKUP_NAMES;
1401
1402
1403 /****************************************************************************
1404 SAMR_Q_LOOKUP_RIDS - do a conversion from RID groups to something.
1405
1406 called to resolve domain RID groups.
1407 *****************************************************************************/
1408 /* SAMR_Q_LOOKUP_RIDS */
1409 typedef struct q_samr_lookup_rids_info
1410 {
1411         POLICY_HND pol;       /* policy handle */
1412
1413         uint32 num_rids1;      /* number of rids being looked up */
1414         uint32 flags;          /* 0x0000 03e8 - unknown */
1415         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
1416         uint32 num_rids2;      /* number of rids being looked up */
1417
1418         uint32 *rid; /* domain RIDs being looked up */
1419
1420 } SAMR_Q_LOOKUP_RIDS;
1421
1422
1423 /****************************************************************************
1424 SAMR_R_LOOKUP_RIDS - do a conversion from group RID to names
1425
1426 *****************************************************************************/
1427 /* SAMR_R_LOOKUP_RIDS */
1428 typedef struct r_samr_lookup_rids_info
1429 {
1430         uint32 num_names1;      /* number of aliases being looked up */
1431         uint32 ptr_names;       /* pointer to aliases */
1432         uint32 num_names2;      /* number of aliases being looked up */
1433
1434         UNIHDR  *hdr_name; /* unicode account name header */
1435         UNISTR2 *uni_name; /* unicode account name string */
1436
1437         uint32 num_types1;      /* number of users in aliases being looked up */
1438         uint32 ptr_types;       /* pointer to users in aliases */
1439         uint32 num_types2;      /* number of users in aliases being looked up */
1440
1441         uint32 *type; /* SID_ENUM type */
1442
1443         NTSTATUS status;
1444
1445 } SAMR_R_LOOKUP_RIDS;
1446
1447
1448 /* SAMR_Q_OPEN_USER - probably an open */
1449 typedef struct q_samr_open_user_info
1450 {
1451         POLICY_HND domain_pol;       /* policy handle */
1452         uint32 access_mask;     /* 32 bit unknown - 0x02011b */
1453         uint32 user_rid;      /* user RID */
1454
1455 } SAMR_Q_OPEN_USER;
1456
1457
1458 /* SAMR_R_OPEN_USER - probably an open */
1459 typedef struct r_samr_open_user_info
1460 {
1461         POLICY_HND user_pol;       /* policy handle associated with unknown id */
1462         NTSTATUS status;         /* return status */
1463
1464 } SAMR_R_OPEN_USER;
1465
1466
1467 /* SAMR_Q_CREATE_USER - probably a create */
1468 typedef struct q_samr_create_user_info
1469 {
1470         POLICY_HND domain_pol;       /* policy handle */
1471
1472         UNIHDR  hdr_name;       /* unicode account name header */
1473         UNISTR2 uni_name;       /* unicode account name */
1474
1475         uint32 acb_info;      /* account control info */
1476         uint32 access_mask;     /* 0xe005 00b0 */
1477
1478 } SAMR_Q_CREATE_USER;
1479
1480
1481 /* SAMR_R_CREATE_USER - probably a create */
1482 typedef struct r_samr_create_user_info
1483 {
1484         POLICY_HND user_pol;       /* policy handle associated with user */
1485
1486         uint32 access_granted;
1487         uint32 user_rid;      /* user RID */
1488         NTSTATUS status;         /* return status */
1489
1490 } SAMR_R_CREATE_USER;
1491
1492
1493 /* SAMR_Q_DELETE_DOM_USER - delete domain user */
1494 typedef struct q_samr_delete_dom_user_info
1495 {
1496     POLICY_HND user_pol;          /* policy handle */
1497
1498 } SAMR_Q_DELETE_DOM_USER;
1499
1500
1501 /* SAMR_R_DELETE_DOM_USER - delete domain user */
1502 typedef struct r_samr_delete_dom_user_info
1503 {
1504         POLICY_HND pol;       /* policy handle */
1505         NTSTATUS status;        /* return status */
1506
1507 } SAMR_R_DELETE_DOM_USER;
1508
1509
1510 /* SAMR_Q_QUERY_GROUPMEM - query group members */
1511 typedef struct q_samr_query_groupmem_info
1512 {
1513         POLICY_HND group_pol;        /* policy handle */
1514
1515 } SAMR_Q_QUERY_GROUPMEM;
1516
1517
1518 /* SAMR_R_QUERY_GROUPMEM - query group members */
1519 typedef struct r_samr_query_groupmem_info
1520 {
1521         uint32 ptr;
1522         uint32 num_entries;
1523
1524         uint32 ptr_rids;
1525         uint32 ptr_attrs;
1526
1527         uint32 num_rids;
1528         uint32 *rid;
1529
1530         uint32 num_attrs;
1531         uint32 *attr;
1532
1533         NTSTATUS status;
1534
1535 } SAMR_R_QUERY_GROUPMEM;
1536
1537
1538 /* SAMR_Q_DEL_GROUPMEM - probably an del group member */
1539 typedef struct q_samr_del_group_mem_info
1540 {
1541         POLICY_HND pol;       /* policy handle */
1542         uint32 rid;         /* rid */
1543
1544 } SAMR_Q_DEL_GROUPMEM;
1545
1546
1547 /* SAMR_R_DEL_GROUPMEM - probably an del group member */
1548 typedef struct r_samr_del_group_mem_info
1549 {
1550         NTSTATUS status;         /* return status */
1551
1552 } SAMR_R_DEL_GROUPMEM;
1553
1554
1555 /* SAMR_Q_ADD_GROUPMEM - probably an add group member */
1556 typedef struct q_samr_add_group_mem_info
1557 {
1558         POLICY_HND pol;       /* policy handle */
1559
1560         uint32 rid;         /* rid */
1561         uint32 unknown;     /* 0x0000 0005 */
1562
1563 } SAMR_Q_ADD_GROUPMEM;
1564
1565
1566 /* SAMR_R_ADD_GROUPMEM - probably an add group member */
1567 typedef struct r_samr_add_group_mem_info
1568 {
1569         NTSTATUS status;         /* return status */
1570
1571 } SAMR_R_ADD_GROUPMEM;
1572
1573
1574 /* SAMR_Q_OPEN_GROUP - probably an open */
1575 typedef struct q_samr_open_group_info
1576 {
1577         POLICY_HND domain_pol;       /* policy handle */
1578         uint32 access_mask;         /* 0x0000 0001, 0x0000 0003, 0x0000 001f */
1579         uint32 rid_group;        /* rid */
1580
1581 } SAMR_Q_OPEN_GROUP;
1582
1583
1584 /* SAMR_R_OPEN_GROUP - probably an open */
1585 typedef struct r_samr_open_group_info
1586 {
1587         POLICY_HND pol;       /* policy handle */
1588         NTSTATUS status;         /* return status */
1589
1590 } SAMR_R_OPEN_GROUP;
1591
1592
1593 /* SAMR_Q_QUERY_ALIASMEM - query alias members */
1594 typedef struct q_samr_query_aliasmem_info
1595 {
1596         POLICY_HND alias_pol;        /* policy handle */
1597
1598 } SAMR_Q_QUERY_ALIASMEM;
1599
1600
1601 /* SAMR_R_QUERY_ALIASMEM - query alias members */
1602 typedef struct r_samr_query_aliasmem_info
1603 {
1604         uint32 num_sids;
1605         uint32 ptr;
1606         uint32 num_sids1;
1607
1608         DOM_SID2 *sid;
1609
1610         NTSTATUS status;
1611
1612 } SAMR_R_QUERY_ALIASMEM;
1613
1614
1615 /* SAMR_Q_ADD_ALIASMEM - add alias member */
1616 typedef struct q_samr_add_alias_mem_info
1617 {
1618         POLICY_HND alias_pol;       /* policy handle */
1619
1620         DOM_SID2 sid; /* member sid to be added to the alias */
1621
1622 } SAMR_Q_ADD_ALIASMEM;
1623
1624
1625 /* SAMR_R_ADD_ALIASMEM - add alias member */
1626 typedef struct r_samr_add_alias_mem_info
1627 {
1628         NTSTATUS status;         /* return status */
1629
1630 } SAMR_R_ADD_ALIASMEM;
1631
1632
1633 /* SAMR_Q_DEL_ALIASMEM - add an add alias member */
1634 typedef struct q_samr_del_alias_mem_info
1635 {
1636         POLICY_HND alias_pol;       /* policy handle */
1637
1638         DOM_SID2 sid; /* member sid to be added to alias */
1639
1640 } SAMR_Q_DEL_ALIASMEM;
1641
1642
1643 /* SAMR_R_DEL_ALIASMEM - delete alias member */
1644 typedef struct r_samr_del_alias_mem_info
1645 {
1646         NTSTATUS status;         /* return status */
1647
1648 } SAMR_R_DEL_ALIASMEM;
1649
1650
1651
1652 /* SAMR_Q_OPEN_ALIAS - probably an open */
1653 typedef struct q_samr_open_alias_info
1654 {
1655         POLICY_HND dom_pol;
1656
1657         uint32 access_mask;         
1658         uint32 rid_alias;
1659
1660 } SAMR_Q_OPEN_ALIAS;
1661
1662
1663 /* SAMR_R_OPEN_ALIAS - probably an open */
1664 typedef struct r_samr_open_alias_info
1665 {
1666         POLICY_HND pol;       /* policy handle */
1667         NTSTATUS status;         /* return status */
1668
1669 } SAMR_R_OPEN_ALIAS;
1670
1671
1672 /* SAMR_Q_CONNECT_ANON - probably an open */
1673 typedef struct q_samr_connect_anon_info
1674 {
1675         uint32 ptr;                  /* ptr? */
1676         uint16 unknown_0;            /* 0x005c */
1677         uint16 unknown_1;            /* 0x0001 */
1678         uint32 access_mask;
1679
1680 } SAMR_Q_CONNECT_ANON;
1681
1682 /* SAMR_R_CONNECT_ANON - probably an open */
1683 typedef struct r_samr_connect_anon_info
1684 {
1685         POLICY_HND connect_pol;       /* policy handle */
1686         NTSTATUS status;         /* return status */
1687
1688 } SAMR_R_CONNECT_ANON;
1689
1690 /* SAMR_Q_CONNECT - probably an open */
1691 typedef struct q_samr_connect_info
1692 {
1693         uint32 ptr_srv_name;         /* pointer (to server name?) */
1694         UNISTR2 uni_srv_name;        /* unicode server name starting with '\\' */
1695
1696         uint32 access_mask;            
1697
1698 } SAMR_Q_CONNECT;
1699
1700
1701 /* SAMR_R_CONNECT - probably an open */
1702 typedef struct r_samr_connect_info
1703 {
1704     POLICY_HND connect_pol;       /* policy handle */
1705         NTSTATUS status;         /* return status */
1706
1707 } SAMR_R_CONNECT;
1708
1709 /* SAMR_Q_CONNECT4 */
1710 typedef struct q_samr_connect4_info
1711 {
1712         uint32 ptr_srv_name; /* pointer to server name */
1713         UNISTR2 uni_srv_name;
1714
1715         uint32 unk_0; /* possible server name type, 1 for IP num, 2 for name */
1716         uint32 access_mask;
1717 } SAMR_Q_CONNECT4;
1718
1719 /* SAMR_R_CONNECT4 - same format as connect */
1720 typedef struct r_samr_connect_info SAMR_R_CONNECT4;       
1721
1722 /* SAMR_Q_GET_DOM_PWINFO */
1723 typedef struct q_samr_get_dom_pwinfo
1724 {
1725         uint32 ptr; 
1726         UNIHDR  hdr_srv_name;
1727         UNISTR2 uni_srv_name;
1728
1729 } SAMR_Q_GET_DOM_PWINFO;
1730
1731 /* SAMR_R_GET_DOM_PWINFO */
1732 typedef struct r_samr_get_dom_pwinfo
1733 {
1734         /*
1735          * Previously this was 3 uint16's.  However, after some tests
1736          * it appears that the data len for the signing needs to be 16.
1737          * Not sure how 3 unit16's ever worked since the length always
1738          * turned out to 12.  3 uint32's + NT_STATUS == 16 bytes.  Tested
1739          * using NT and 2k.  --jerry
1740          */
1741         uint32 unk_0;
1742         uint32 unk_1;
1743         uint32 unk_2;
1744         NTSTATUS status;
1745
1746 } SAMR_R_GET_DOM_PWINFO;
1747
1748 /* SAMR_ENC_PASSWD */
1749 typedef struct enc_passwd_info
1750 {
1751         uint32 ptr;
1752         uint8 pass[516];
1753
1754 } SAMR_ENC_PASSWD;
1755
1756 /* SAMR_ENC_HASH */
1757 typedef struct enc_hash_info
1758 {
1759         uint32 ptr;
1760         uint8 hash[16];
1761
1762 } SAMR_ENC_HASH;
1763
1764 /* SAMR_Q_CHGPASSWD_USER */
1765 typedef struct q_samr_chgpasswd_user_info
1766 {
1767         uint32 ptr_0;
1768
1769         UNIHDR hdr_dest_host; /* server name unicode header */
1770         UNISTR2 uni_dest_host; /* server name unicode string */
1771
1772         UNIHDR hdr_user_name;    /* username unicode string header */
1773         UNISTR2 uni_user_name;    /* username unicode string */
1774
1775         SAMR_ENC_PASSWD nt_newpass;
1776         SAMR_ENC_HASH nt_oldhash;
1777
1778         uint32 unknown; /* 0x0000 0001 */
1779
1780         SAMR_ENC_PASSWD lm_newpass;
1781         SAMR_ENC_HASH lm_oldhash;
1782
1783 } SAMR_Q_CHGPASSWD_USER;
1784
1785 /* SAMR_R_CHGPASSWD_USER */
1786 typedef struct r_samr_chgpasswd_user_info
1787 {
1788         NTSTATUS status; /* 0 == OK, C000006A (NT_STATUS_WRONG_PASSWORD) */
1789
1790 } SAMR_R_CHGPASSWD_USER;
1791
1792
1793 /* SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN */
1794 typedef struct q_samr_remove_sid_foreign_domain_info
1795 {
1796         POLICY_HND dom_pol;   /* policy handle */
1797         DOM_SID2 sid;         /* SID */
1798
1799 } SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN;
1800
1801
1802 /* SAMR_R_REMOVE_SID_FOREIGN_DOMAIN */
1803 typedef struct r_samr_remove_sid_foreign_domain_info
1804 {
1805         NTSTATUS status;         /* return status */
1806
1807 } SAMR_R_REMOVE_SID_FOREIGN_DOMAIN;
1808
1809
1810
1811 /* these are from the old rpc_samr.h - they are needed while the merge
1812    is still going on */
1813 #define MAX_SAM_SIDS 15
1814
1815 /* DOM_SID3 - security id */
1816 typedef struct sid_info_3
1817 {
1818         uint16 len; /* length, bytes, including length of len :-) */
1819         /* uint8  pad[2]; */
1820         
1821         DOM_SID sid;
1822
1823 } DOM_SID3;
1824
1825 /* SAMR_Q_UNKNOWN_2E */
1826 typedef struct q_samr_unknown_2e_info
1827 {
1828         POLICY_HND domain_pol;   /* policy handle */
1829         uint16 switch_value;
1830
1831 } SAMR_Q_UNKNOWN_2E;
1832
1833 /* SAMR_R_UNKNOWN_2E */
1834 typedef struct r_samr_unknown_2e_info
1835 {
1836         uint32 ptr_0;
1837         uint16 switch_value;
1838         SAM_UNK_CTR *ctr;
1839         NTSTATUS status;         /* return status */
1840
1841 } SAMR_R_UNKNOWN_2E;
1842
1843 /* SAMR_Q_SET_DOMAIN_INFO */
1844 typedef struct q_samr_set_domain_info
1845 {
1846         POLICY_HND domain_pol;   /* policy handle */
1847         uint16 switch_value0;
1848         uint16 switch_value;
1849         SAM_UNK_CTR *ctr;
1850
1851 } SAMR_Q_SET_DOMAIN_INFO;
1852
1853 /* SAMR_R_SET_DOMAIN_INFO */
1854 typedef struct r_samr_set_domain_info
1855 {
1856         NTSTATUS status;         /* return status */
1857
1858 } SAMR_R_SET_DOMAIN_INFO;
1859
1860 #endif /* _RPC_SAMR_H */