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