Changed the sec desc access checks to match the spec. Needs testing.
[sfrench/samba-autobuild/.git] / source / include / rpc_samr_old.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    SMB parameters and setup
5    Copyright (C) Andrew Tridgell 1992-1997
6    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
7    Copyright (C) Paul Ashton 1997
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #ifndef _RPC_SAMR_H /* _RPC_SAMR_H */
25 #define _RPC_SAMR_H 
26
27
28 #include "rpc_misc.h"
29
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 SamrAddMemberToAlias
36 SamrAddMemberToGroup
37 SamrAddMultipleMembersToAlias
38 SamrChangePasswordUser
39 x SamrCloseHandle
40 x SamrConnect
41 SamrCreateAliasInDomain
42 SamrCreateGroupInDomain
43 SamrCreateUserInDomain
44 SamrDeleteAlias
45 SamrDeleteGroup
46 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 SamrOpenGroup
58 x SamrOpenUser
59 x SamrQueryDisplayInformation
60 x SamrQueryInformationAlias
61 SamrQueryInformationDomain
62 ? SamrQueryInformationUser
63 SamrQuerySecurityObject
64 SamrRemoveMemberFromAlias
65 SamrRemoveMemberFromForiegnDomain
66 SamrRemoveMemberFromGroup
67 SamrRemoveMultipleMembersFromAlias
68 SamrSetInformationAlias
69 SamrSetInformationDomain
70 SamrSetInformationGroup
71 SamrSetInformationUser
72 SamrSetMemberAttributesOfGroup
73 SamrSetSecurityObject
74 SamrShutdownSamServer
75 SamrTestPrivateFunctionsDomain
76 SamrTestPrivateFunctionsUser
77
78 ********************************************************************/
79
80 #define SAMR_CLOSE_HND         0x01
81 #define SAMR_LOOKUP_DOMAIN     0x05
82 #define SAMR_ENUM_DOMAINS      0x06
83 #define SAMR_OPEN_DOMAIN       0x07
84 #define SAMR_QUERY_DOMAIN_INFO 0x08
85 #define SAMR_LOOKUP_IDS        0x10
86 #define SAMR_LOOKUP_NAMES      0x11
87 #define SAMR_UNKNOWN_3         0x03
88 #define SAMR_QUERY_DISPINFO    0x28
89 #define SAMR_OPEN_USER         0x22
90 #define SAMR_QUERY_USERINFO    0x24
91 #define SAMR_QUERY_USERGROUPS  0x27
92 #define SAMR_UNKNOWN_12        0x12
93 #define SAMR_UNKNOWN_21        0x21
94 #define SAMR_UNKNOWN_2C        0x2c
95 #define SAMR_UNKNOWN_32        0x32
96 #define SAMR_UNKNOWN_34        0x34
97 #define SAMR_CHGPASSWD_USER    0x37
98 #define SAMR_UNKNOWN_38        0x38
99 #define SAMR_CONNECT           0x39
100 #define SAMR_CONNECT_ANON      0x00
101 #define SAMR_OPEN_ALIAS        0x1b
102 #define SAMR_QUERY_ALIASINFO   0x1c
103 #define SAMR_ENUM_DOM_USERS    0x0d
104 #define SAMR_ENUM_DOM_ALIASES  0x0f
105 #define SAMR_ENUM_DOM_GROUPS   0x30
106
107
108 typedef struct logon_hours_info
109 {
110         uint32 len; /* normally 21 bytes */
111         uint8 hours[32];
112
113 } LOGON_HRS;
114
115 /* SAM_USER_INFO_21 */
116 typedef struct sam_user_info_21
117 {
118         NTTIME logon_time;            /* logon time */
119         NTTIME logoff_time;           /* logoff time */
120         NTTIME kickoff_time;          /* kickoff time */
121         NTTIME pass_last_set_time;    /* password last set time */
122         NTTIME pass_can_change_time;  /* password can change time */
123         NTTIME pass_must_change_time; /* password must change time */
124
125         UNIHDR hdr_user_name;    /* username unicode string header */
126         UNIHDR hdr_full_name;    /* user's full name unicode string header */
127         UNIHDR hdr_home_dir;     /* home directory unicode string header */
128         UNIHDR hdr_dir_drive;    /* home drive unicode string header */
129         UNIHDR hdr_logon_script; /* logon script unicode string header */
130         UNIHDR hdr_profile_path; /* profile path unicode string header */
131         UNIHDR hdr_acct_desc  ;  /* user description */
132         UNIHDR hdr_workstations; /* comma-separated workstations user can log in from */
133         UNIHDR hdr_unknown_str ; /* don't know what this is, yet. */
134         UNIHDR hdr_munged_dial ; /* munged path name and dial-back tel number */
135
136         uint8 lm_pwd[16];    /* lm user passwords */
137         uint8 nt_pwd[16];    /* nt user passwords */
138
139         uint32 user_rid;      /* Primary User ID */
140         uint32 group_rid;     /* Primary Group ID */
141
142         uint16 acb_info; /* account info (ACB_xxxx bit-mask) */
143         /* uint8 pad[2] */
144
145         uint32 unknown_3; /* 0x00ff ffff */
146
147         uint16 logon_divs; /* 0x0000 00a8 which is 168 which is num hrs in a week */
148         /* uint8 pad[2] */
149         uint32 ptr_logon_hrs; /* unknown pointer */
150
151         uint32 unknown_5;     /* 0x0002 0000 */
152
153         uint8 padding1[8];
154
155         UNISTR2 uni_user_name;    /* username unicode string */
156         UNISTR2 uni_full_name;    /* user's full name unicode string */
157         UNISTR2 uni_home_dir;     /* home directory unicode string */
158         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
159         UNISTR2 uni_logon_script; /* logon script unicode string */
160         UNISTR2 uni_profile_path; /* profile path unicode string */
161         UNISTR2 uni_acct_desc  ;  /* user description unicode string */
162         UNISTR2 uni_workstations; /* login from workstations unicode string */
163         UNISTR2 uni_unknown_str ; /* don't know what this is, yet. */
164         UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel number */
165
166         uint32 unknown_6; /* 0x0000 04ec */
167         uint32 padding4;
168
169         LOGON_HRS logon_hrs;
170
171 } SAM_USER_INFO_21;
172
173
174 /* SAM_USER_INFO_11 */
175 typedef struct sam_user_info_11
176 {
177         uint8  padding_0[16];  /* 0 - padding 16 bytes */
178         NTTIME expiry;         /* expiry time or something? */
179         uint8  padding_1[24];  /* 0 - padding 24 bytes */
180
181         UNIHDR hdr_mach_acct;  /* unicode header for machine account */
182         uint32 padding_2;      /* 0 - padding 4 bytes */
183
184         uint32 ptr_1;          /* pointer */
185         uint8  padding_3[32];  /* 0 - padding 32 bytes */
186         uint32 padding_4;      /* 0 - padding 4 bytes */
187
188         uint32 ptr_2;          /* pointer */
189         uint32 padding_5;      /* 0 - padding 4 bytes */
190
191         uint32 ptr_3;          /* pointer */
192         uint8  padding_6[32];  /* 0 - padding 32 bytes */
193
194         uint32 rid_user;       /* user RID */
195         uint32 rid_group;      /* group RID */
196
197         uint16 acct_ctrl;      /* 0080 - ACB_XXXX */
198         uint16 unknown_3;      /* 16 bit padding */
199
200         uint16 unknown_4;      /* 0x003f      - 16 bit unknown */
201         uint16 unknown_5;      /* 0x003c      - 16 bit unknown */
202
203         uint8  padding_7[16];  /* 0 - padding 16 bytes */
204         uint32 padding_8;      /* 0 - padding 4 bytes */
205         
206         UNISTR2 uni_mach_acct; /* unicode string for machine account */
207
208         uint8  padding_9[48];  /* 0 - padding 48 bytes */
209
210 } SAM_USER_INFO_11;
211
212
213 /* SAM_USER_INFO_10 */
214 typedef struct sam_user_info_10
215 {
216         uint32 acb_info;
217
218 } SAM_USER_INFO_10;
219
220
221
222 /* SAMR_Q_CLOSE_HND - probably a policy handle close */
223 typedef struct q_samr_close_hnd_info
224 {
225     POLICY_HND pol;          /* policy handle */
226
227 } SAMR_Q_CLOSE_HND;
228
229
230 /* SAMR_R_CLOSE_HND - probably a policy handle close */
231 typedef struct r_samr_close_hnd_info
232 {
233     POLICY_HND pol;       /* policy handle */
234         uint32 status;         /* return status */
235
236 } SAMR_R_CLOSE_HND;
237
238
239 /****************************************************************************
240 SAMR_Q_UNKNOWN_2C - a "set user info" occurs just after this
241 *****************************************************************************/
242
243 /* SAMR_Q_UNKNOWN_2C */
244 typedef struct q_samr_unknown_2c_info
245 {
246         POLICY_HND user_pol;          /* policy handle */
247
248 } SAMR_Q_UNKNOWN_2C;
249
250
251 /****************************************************************************
252 SAMR_R_UNKNOWN_2C - a "set user info" occurs just after this
253 *****************************************************************************/
254
255 /* SAMR_R_UNKNOWN_2C */
256 typedef struct r_samr_unknown_2c_info
257 {
258         uint32 unknown_0; /* 0x0016 0000 */
259         uint32 unknown_1; /* 0x0000 0000 */
260         uint32 status; 
261
262 } SAMR_R_UNKNOWN_2C;
263
264
265 /****************************************************************************
266 SAMR_Q_UNKNOWN_3 - info level 4.  returns SIDs.
267 *****************************************************************************/
268
269 /* SAMR_Q_UNKNOWN_3 - probably get domain info... */
270 typedef struct q_samr_unknown_3_info
271 {
272         POLICY_HND user_pol;          /* policy handle */
273         uint16 switch_value;     /* 0x0000 0004 */
274         /* uint8 pad[2] */
275
276 } SAMR_Q_UNKNOWN_3;
277
278 /* DOM_SID3 example:
279    0x14 0x035b 0x0002 S-1-1
280    0x18 0x07ff 0x000f S-1-5-20-DOMAIN_ALIAS_RID_ADMINS
281    0x18 0x07ff 0x000f S-1-5-20-DOMAIN_ALIAS_RID_ACCOUNT_OPS
282    0x24 0x0044 0x0002 S-1-5-21-nnn-nnn-nnn-0x03f1
283  */
284
285 /* DOM_SID3 example:
286    0x24 0x0044 0x0002 S-1-5-21-nnn-nnn-nnn-0x03ee
287    0x18 0x07ff 0x000f S-1-5-20-DOMAIN_ALIAS_RID_ADMINS
288    0x14 0x035b 0x0002 S-1-1
289  */
290
291 /* DOM_SID3 - security id */
292 typedef struct sid_info_3
293 {
294         uint16 len; /* length, bytes, including length of len :-) */
295         /* uint8  pad[2]; */
296         
297         DOM_SID sid;
298
299 } DOM_SID3;
300
301
302 #define MAX_SAM_SIDS 15
303
304 /* SAM_SID_STUFF */
305 typedef struct sid_stuff_info
306 {
307         uint16 unknown_2; /* 0x0001 */
308         uint16 unknown_3; /* 0x8004 */
309
310         uint8 padding1[8];
311
312         uint32 unknown_4; /* 0x0000 0014 */
313         uint32 unknown_5; /* 0x0000 0014 */
314
315         uint16 unknown_6; /* 0x0002 */
316         uint16 unknown_7; /* 0x5800 */
317
318         uint32 num_sids;
319
320         uint16 padding2;
321
322         DOM_SID3 sid[MAX_SAM_SIDS];
323
324 } SAM_SID_STUFF;
325
326 /* SAMR_R_UNKNOWN_3 - probably an open */
327 typedef struct r_samr_unknown_3_info
328 {
329         uint32 ptr_0;
330         uint32 sid_stuff_len0;
331
332         uint32 ptr_1;
333         uint32 sid_stuff_len1;
334
335         SAM_SID_STUFF sid_stuff;
336
337         uint32 status;         /* return status */
338
339 } SAMR_R_UNKNOWN_3;
340
341
342 /****************************************************************************
343 SAMR_Q_QUERY_DOMAIN_INFO - probably a query on domain group info.
344 *****************************************************************************/
345
346 /* SAMR_Q_QUERY_DOMAIN_INFO - */
347 typedef struct q_samr_query_domain_info
348 {
349         POLICY_HND domain_pol;   /* policy handle */
350         uint16 switch_value;     /* 0x0002 */
351
352 } SAMR_Q_QUERY_DOMAIN_INFO;
353
354 typedef struct sam_unkown_info_2_info
355 {
356         uint32 unknown_0; /* 0x0000 0000 */
357         uint32 unknown_1; /* 0x8000 0000 */
358         uint32 unknown_2; /* 0x0000 0000 */
359
360         uint32 ptr_0;     /* pointer to unknown structure */
361         UNIHDR hdr_domain; /* domain name unicode header */
362         UNIHDR hdr_server; /* server name unicode header */
363
364         /* put all the data in here, at the moment, including what the above
365            pointer is referring to
366          */
367
368         uint32 seq_num; /* some sort of incrementing sequence number? */
369         uint32 unknown_3; /* 0x0000 0000 */
370         
371         uint32 unknown_4; /* 0x0000 0001 */
372         uint32 unknown_5; /* 0x0000 0003 */
373         uint32 unknown_6; /* 0x0000 0001 */
374         uint32 num_domain_usrs; /* number of users in domain */
375         uint32 num_domain_grps; /* number of domain groups in domain */
376         uint32 num_local_grps; /* number of local groups in domain */
377
378         uint8 padding[12]; /* 12 bytes zeros */
379
380         UNISTR2 uni_domain; /* domain name unicode string */
381         UNISTR2 uni_server; /* server name unicode string */
382
383 } SAM_UNK_INFO_2;
384
385
386 typedef struct sam_unknown_ctr_info
387 {
388         union
389         {
390                 SAM_UNK_INFO_2 inf2;
391
392         } info;
393
394 } SAM_UNK_CTR;
395
396
397 /* SAMR_R_QUERY_DOMAIN_INFO - */
398 typedef struct r_samr_query_domain_info
399 {
400         uint32 ptr_0;
401         uint16 switch_value; /* same as in query */
402
403         SAM_UNK_CTR *ctr;
404
405         uint32 status;         /* return status */
406
407 } SAMR_R_QUERY_DOMAIN_INFO;
408
409  
410 /****************************************************************************
411 SAMR_Q_OPEN_DOMAIN - unknown_0 values seen associated with SIDs:
412
413 0x0000 03f1 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
414 0x0000 0200 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
415 *****************************************************************************/
416
417 /* SAMR_Q_OPEN_DOMAIN */
418 typedef struct q_samr_open_domain_info
419 {
420         POLICY_HND connect_pol;   /* policy handle */
421         uint32 rid;               /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - a RID? */
422         DOM_SID2 dom_sid;         /* domain SID */
423
424 } SAMR_Q_OPEN_DOMAIN;
425
426
427 /* SAMR_R_OPEN_DOMAIN - probably an open */
428 typedef struct r_samr_open_domain_info
429 {
430         POLICY_HND domain_pol; /* policy handle associated with the SID */
431         uint32 status;         /* return status */
432
433 } SAMR_R_OPEN_DOMAIN;
434
435
436 #define MAX_SAM_ENTRIES 600
437
438 typedef struct samr_entry_info
439 {
440         uint32 rid;
441         UNIHDR hdr_name;
442
443 } SAM_ENTRY;
444
445 /* SAMR_Q_ENUM_DOM_USERS - SAM rids and names */
446 typedef struct q_samr_enum_dom_users_info
447 {
448         POLICY_HND pol;          /* policy handle */
449
450         uint16 req_num_entries;   /* number of values (0 indicates unlimited?) */
451         uint16 unknown_0;         /* enumeration context? */
452         uint16 acb_mask;          /* 0x0000 indicates all */
453         uint16 unknown_1;         /* 0x0000 */
454
455         uint32 max_size;              /* 0x0000 ffff */
456
457 } SAMR_Q_ENUM_DOM_USERS;
458
459
460 /* SAMR_R_ENUM_DOM_USERS - SAM rids and names */
461 typedef struct r_samr_enum_dom_users_info
462 {
463         uint16 total_num_entries;  /* number of entries that match without the acb mask */
464         uint16 unknown_0;          /* same as unknown_0 (enum context?) in request */
465         uint32 ptr_entries1;       /* actual number of entries to follow, having masked some out */
466
467         uint32 num_entries2;
468         uint32 ptr_entries2;
469
470         uint32 num_entries3;
471
472         SAM_ENTRY sam[MAX_SAM_ENTRIES];
473         UNISTR2 uni_acct_name[MAX_SAM_ENTRIES];
474
475         uint32 num_entries4;
476
477         uint32 status;
478
479 } SAMR_R_ENUM_DOM_USERS;
480
481
482 typedef struct samr_entry_info3
483 {
484         uint32 grp_idx;
485
486         uint32 rid_grp;
487         uint32 attr;
488
489         UNIHDR hdr_grp_name;
490         UNIHDR hdr_grp_desc;
491
492 } SAM_ENTRY3;
493
494 typedef struct samr_str_entry_info3
495 {
496         UNISTR2 uni_grp_name;
497         UNISTR2 uni_grp_desc;
498
499 } SAM_STR3;
500
501 /* SAMR_Q_ENUM_DOM_GROUPS - SAM rids and names */
502 typedef struct q_samr_enum_dom_groups_info
503 {
504         POLICY_HND pol;          /* policy handle */
505
506         /* these are possibly an enumeration context handle... */
507         uint16 switch_level;      /* 0x0003 */
508         uint16 unknown_0;         /* 0x0000 */
509         uint32 start_idx;       /* presumably the start enumeration index */
510         uint32 unknown_1;       /* 0x0000 07d0 */
511
512         uint32 max_size;        /* 0x0000 7fff */
513
514 } SAMR_Q_ENUM_DOM_GROUPS;
515
516
517 /* SAMR_R_ENUM_DOM_GROUPS - SAM rids and names */
518 typedef struct r_samr_enum_dom_groups_info
519 {
520         uint32 unknown_0;        /* 0x0000 0492 or 0x0000 00be */
521         uint32 unknown_1;        /* 0x0000 049a or 0x0000 00be */
522         uint32 switch_level;     /* 0x0000 0003 */
523
524         uint32 num_entries;
525         uint32 ptr_entries;
526
527         uint32 num_entries2;
528
529         SAM_ENTRY3 sam[MAX_SAM_ENTRIES];
530         SAM_STR3   str[MAX_SAM_ENTRIES];
531
532         uint32 status;
533
534 } SAMR_R_ENUM_DOM_GROUPS;
535
536
537
538 /* SAMR_Q_ENUM_DOM_ALIASES - SAM rids and names */
539 typedef struct q_samr_enum_dom_aliases_info
540 {
541         POLICY_HND pol;          /* policy handle */
542
543         /* this is possibly an enumeration context handle... */
544         uint32 unknown_0;         /* 0x0000 0000 */
545
546         uint32 max_size;              /* 0x0000 ffff */
547
548 } SAMR_Q_ENUM_DOM_ALIASES;
549
550 /* SAMR_R_ENUM_DOM_ALIASES - SAM rids and names */
551 typedef struct r_samr_enum_dom_aliases_info
552 {
553         uint32 num_entries;
554         uint32 ptr_entries;
555
556         uint32 num_entries2;
557         uint32 ptr_entries2;
558
559         uint32 num_entries3;
560
561         SAM_ENTRY sam[MAX_SAM_ENTRIES];
562         UNISTR2 uni_grp_name[MAX_SAM_ENTRIES];
563
564         uint32 num_entries4;
565
566         uint32 status;
567
568 } SAMR_R_ENUM_DOM_ALIASES;
569
570 /***************************************************************************
571  SAMR_Q_LOOKUP_DOMAIN - obtain SID for a local domain
572  ***************************************************************************/
573 typedef struct q_samr_lookup_domain_info
574 {
575         POLICY_HND connect_pol;
576
577         UNIHDR  hdr_domain;
578         UNISTR2 uni_domain;
579
580 } SAMR_Q_LOOKUP_DOMAIN;
581
582 /* SAMR_R_LOOKUP_DOMAIN */
583 typedef struct r_samr_lookup_domain_info
584
585         uint32   ptr_sid;
586         DOM_SID2 dom_sid;
587
588         uint32 status;
589
590 } SAMR_R_LOOKUP_DOMAIN;
591  
592 /**********************************************************************
593  SAMR_Q_ENUM_DOMAINS - SAM rids and names 
594  **********************************************************************/
595 typedef struct q_samr_enum_domains_info
596 {
597         POLICY_HND pol;     /* policy handle */
598
599         uint32 start_idx;   /* enumeration handle */
600         uint32 max_size;    /* 0x0000 ffff */
601
602 } SAMR_Q_ENUM_DOMAINS;
603
604 /* SAMR_R_ENUM_DOMAINS - SAM rids and Domain names */
605 typedef struct r_samr_enum_domains_info
606 {                                   
607         uint32 next_idx;     /* next starting index required for enum */
608         uint32 ptr_entries1;
609
610         uint32 num_entries2;
611         uint32 ptr_entries2;
612
613         uint32 num_entries3;
614
615         SAM_ENTRY *sam;
616         UNISTR2 *uni_dom_name;
617
618         uint32 num_entries4;
619
620         uint32 status;
621
622 } SAMR_R_ENUM_DOMAINS;
623
624
625 /* SAMR_Q_QUERY_DISPINFO - SAM rids, names and descriptions */
626 typedef struct q_samr_query_disp_info
627 {
628         POLICY_HND pol;        /* policy handle */
629
630         uint16 switch_level;    /* 0x0001 and 0x0002 seen */
631         uint32 start_idx;       /* presumably the start enumeration index */
632         uint32 max_entries;       /* 0x0000 07d0, 0x0000 0400 and 0x0000 0200 seen */
633
634         uint32 max_size;        /* 0x0000 7fff, 0x0000 7ffe and 0x0000 3fff seen*/
635
636 } SAMR_Q_QUERY_DISPINFO;
637
638 typedef struct samr_entry_info1
639 {
640         uint32 user_idx;
641
642         uint32 rid_user;
643         uint16 acb_info;
644         uint16 pad;
645
646         UNIHDR hdr_acct_name;
647         UNIHDR hdr_user_name;
648         UNIHDR hdr_user_desc;
649
650 } SAM_ENTRY1;
651
652 typedef struct samr_str_entry_info1
653 {
654         UNISTR2 uni_acct_name;
655         UNISTR2 uni_full_name;
656         UNISTR2 uni_acct_desc;
657
658 } SAM_STR1;
659
660 typedef struct sam_entry_info_1
661 {
662         uint32 num_entries;
663         uint32 ptr_entries;
664         uint32 num_entries2;
665
666         SAM_ENTRY1 sam[MAX_SAM_ENTRIES];
667         SAM_STR1   str[MAX_SAM_ENTRIES];
668
669
670 } SAM_INFO_1;
671
672 typedef struct samr_entry_info2
673 {
674         uint32 user_idx;
675
676         uint32 rid_user;
677         uint16 acb_info;
678         uint16 pad;
679
680         UNIHDR hdr_srv_name;
681         UNIHDR hdr_srv_desc;
682
683 } SAM_ENTRY2;
684
685 typedef struct samr_str_entry_info2
686 {
687         UNISTR2 uni_srv_name;
688         UNISTR2 uni_srv_desc;
689
690 } SAM_STR2;
691
692 typedef struct sam_entry_info_2
693 {
694         uint32 num_entries;
695         uint32 ptr_entries;
696         uint32 num_entries2;
697
698         SAM_ENTRY2 sam[MAX_SAM_ENTRIES];
699         SAM_STR2   str[MAX_SAM_ENTRIES];
700
701 } SAM_INFO_2;
702
703 typedef struct sam_info_ctr_info
704 {
705         union
706         {
707                 SAM_INFO_1 *info1; /* server info */
708                 SAM_INFO_2 *info2; /* user info */
709                 void       *info; /* allows assignment without typecasting, */
710
711         } sam;
712
713 } SAM_INFO_CTR;
714
715 /* SAMR_R_QUERY_DISPINFO - SAM rids, names and descriptions */
716 typedef struct r_samr_query_dispinfo_info
717 {
718         uint32 unknown_0;        /* container length? 0x0000 0492 or 0x0000 00be */
719         uint32 unknown_1;        /* container length? 0x0000 049a or 0x0000 00be */
720         uint16 switch_level;     /* 0x0001 or 0x0002 */
721         /*uint8 pad[2] */
722
723         SAM_INFO_CTR *ctr;
724
725         uint32 status;
726
727 } SAMR_R_QUERY_DISPINFO;
728
729
730
731 /* SAMR_Q_QUERY_ALIASINFO - SAM Alias Info */
732 typedef struct q_samr_enum_alias_info
733 {
734         POLICY_HND pol;        /* policy handle */
735
736         uint16 switch_level;    /* 0x0003 seen  (0x0001 seen from NT5) */
737
738 } SAMR_Q_QUERY_ALIASINFO;
739
740 typedef struct samr_alias_info1
741 {
742   uint32 switch_value_1;
743   UNIHDR hdr_alias_name;
744   UNISTR2 uni_alias_name;
745   UNIHDR hdr_alias_desc;
746   UNISTR2 uni_alias_desc;
747 } ALIAS_INFO1;
748
749 typedef struct samr_alias_info3
750 {
751         UNIHDR hdr_acct_desc;
752         UNISTR2 uni_acct_desc;
753
754 } ALIAS_INFO3;
755
756 /* SAMR_R_QUERY_ALIASINFO - SAM rids, names and descriptions */
757 typedef struct r_samr_query_aliasinfo_info
758 {
759   uint32 ptr;        
760   uint16 switch_value;     /* 0x0003 */
761   /* uint8[2] padding */
762
763   union
764   {
765     ALIAS_INFO1 info1;
766     ALIAS_INFO3 info3;
767
768   } alias;
769
770   uint32 status;
771
772 } SAMR_R_QUERY_ALIASINFO;
773
774
775 /* SAMR_Q_QUERY_USERGROUPS - */
776 typedef struct q_samr_query_usergroup_info
777 {
778         POLICY_HND pol;          /* policy handle associated with unknown id */
779
780 } SAMR_Q_QUERY_USERGROUPS;
781
782 /* SAMR_R_QUERY_USERGROUPS - probably a get sam info */
783 typedef struct r_samr_query_usergroup_info
784 {
785         uint32 ptr_0;            /* pointer */
786         uint32 num_entries;      /* number of RID groups */
787         uint32 ptr_1;            /* pointer */
788         uint32 num_entries2;     /* number of RID groups */
789
790         DOM_GID *gid; /* group info */
791
792         uint32 status;         /* return status */
793
794 } SAMR_R_QUERY_USERGROUPS;
795
796
797 /* SAMR_Q_QUERY_USERINFO - probably a get sam info */
798 typedef struct q_samr_query_user_info
799 {
800         POLICY_HND pol;          /* policy handle associated with unknown id */
801         uint16 switch_value;         /* 0x0015, 0x0011 or 0x0010 - 16 bit unknown */
802
803 } SAMR_Q_QUERY_USERINFO;
804
805 /* SAMR_R_QUERY_USERINFO - probably a get sam info */
806 typedef struct r_samr_query_user_info
807 {
808         uint32 ptr;            /* pointer */
809         uint16 switch_value;      /* 0x0015, 0x0011 or 0x0010 - same as in query */
810         /* uint8[2] padding. */
811
812         union
813         {
814                 SAM_USER_INFO_10 *id10; /* auth-level 0x10 */
815                 SAM_USER_INFO_11 *id11; /* auth-level 0x11 */
816                 SAM_USER_INFO_21 *id21; /* auth-level 21 */
817                 void* id; /* to make typecasting easy */
818
819         } info;
820
821         uint32 status;         /* return status */
822
823 } SAMR_R_QUERY_USERINFO;
824
825
826 /****************************************************************************
827 SAMR_Q_LOOKUP_IDS - do a conversion from name to RID.
828
829 the policy handle allocated by an "samr open secret" call is associated
830 with a SID.  this policy handle is what is queried here, *not* the SID
831 itself.  the response to the lookup rids is relative to this SID.
832 *****************************************************************************/
833 /* SAMR_Q_LOOKUP_IDS */
834 typedef struct q_samr_lookup_ids_info
835 {
836     POLICY_HND pol;       /* policy handle */
837
838         uint32 num_sids1;      /* number of rids being looked up */
839         uint32 ptr;            /* buffer pointer */
840         uint32 num_sids2;      /* number of rids being looked up */
841
842         uint32   ptr_sid[MAX_LOOKUP_SIDS]; /* pointers to sids to be looked up */
843         DOM_SID2 sid    [MAX_LOOKUP_SIDS]; /* sids to be looked up. */
844
845 } SAMR_Q_LOOKUP_IDS;
846
847
848 /* SAMR_R_LOOKUP_IDS */
849 typedef struct r_samr_lookup_ids_info
850 {
851         uint32 num_entries;
852         uint32 ptr; /* undocumented buffer pointer */
853
854         uint32 num_entries2; 
855         uint32 rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
856
857         uint32 status; /* return code */
858
859 } SAMR_R_LOOKUP_IDS;
860
861 /****************************************************************************
862 SAMR_Q_LOOKUP_NAMES - do a conversion from Names to RIDs+types.
863 *****************************************************************************/
864 /* SAMR_Q_LOOKUP_NAMES */
865 typedef struct q_samr_lookup_names_info
866 {
867         POLICY_HND pol;       /* policy handle */
868
869         uint32 num_names1;      /* number of names being looked up */
870         uint32 flags;           /* 0x0000 03e8 - unknown */
871         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
872         uint32 num_names2;      /* number of names being looked up */
873
874         UNIHDR  hdr_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
875         UNISTR2 uni_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
876
877 } SAMR_Q_LOOKUP_NAMES;
878
879 /* SAMR_R_LOOKUP_NAMES */
880 typedef struct r_samr_lookup_names_info
881 {
882         uint32 num_rids1;      /* number of aliases being looked up */
883         uint32 ptr_rids;       /* pointer to aliases */
884         uint32 num_rids2;      /* number of aliases being looked up */
885
886         uint32 rid[MAX_LOOKUP_SIDS]; /* rids */
887
888         uint32 num_types1;      /* number of users in aliases being looked up */
889         uint32 ptr_types;       /* pointer to users in aliases */
890         uint32 num_types2;      /* number of users in aliases being looked up */
891
892         uint32 type[MAX_LOOKUP_SIDS]; /* SID_ENUM type */
893
894         uint32 status; /* return code */
895
896 } SAMR_R_LOOKUP_NAMES;
897
898 /****************************************************************************
899 SAMR_Q_UNKNOWN_12 - do a conversion from RID groups to something.
900
901 called to resolve domain RID groups.
902 *****************************************************************************/
903 /* SAMR_Q_UNKNOWN_12 */
904 typedef struct q_samr_unknown_12_info
905 {
906     POLICY_HND pol;       /* policy handle */
907
908         uint32 num_gids1;      /* number of rids being looked up */
909         uint32 rid;            /* 0x0000 03e8 - RID of the server doing the query? */
910         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
911         uint32 num_gids2;      /* number of rids being looked up */
912
913         uint32 gid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
914
915 } SAMR_Q_UNKNOWN_12;
916
917
918 /****************************************************************************
919 SAMR_R_UNKNOWN_12 - do a conversion from group RID to names
920
921 *****************************************************************************/
922 /* SAMR_R_UNKNOWN_12 */
923 typedef struct r_samr_unknown_12_info
924 {
925     POLICY_HND pol;       /* policy handle */
926
927         uint32 num_aliases1;      /* number of aliases being looked up */
928         uint32 ptr_aliases;       /* pointer to aliases */
929         uint32 num_aliases2;      /* number of aliases being looked up */
930
931         UNIHDR  hdr_als_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
932         UNISTR2 uni_als_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
933
934         uint32 num_als_usrs1;      /* number of users in aliases being looked up */
935         uint32 ptr_als_usrs;       /* pointer to users in aliases */
936         uint32 num_als_usrs2;      /* number of users in aliases being looked up */
937
938         uint32 num_als_usrs[MAX_LOOKUP_SIDS]; /* number of users per group */
939
940         uint32 status;
941
942 } SAMR_R_UNKNOWN_12;
943
944
945 /* SAMR_Q_OPEN_USER - probably an open */
946 typedef struct q_samr_open_user_info
947 {
948     POLICY_HND domain_pol;       /* policy handle */
949         uint32 unknown_0;     /* 32 bit unknown - 0x02011b */
950         uint32 user_rid;      /* user RID */
951
952 } SAMR_Q_OPEN_USER;
953
954
955 /* SAMR_R_OPEN_USER - probably an open */
956 typedef struct r_samr_open_user_info
957 {
958     POLICY_HND user_pol;       /* policy handle associated with unknown id */
959         uint32 status;         /* return status */
960
961 } SAMR_R_OPEN_USER;
962
963
964 /* SAMR_Q_UNKNOWN_13 - probably an open alias in domain */
965 typedef struct q_samr_unknown_13_info
966 {
967     POLICY_HND alias_pol;        /* policy handle */
968
969         uint16 unknown_1;            /* 16 bit unknown - 0x0200 */
970         uint16 unknown_2;            /* 16 bit unknown - 0x0000 */
971
972 } SAMR_Q_UNKNOWN_13;
973
974
975 /* SAMR_Q_UNKNOWN_21 - probably an open group in domain */
976 typedef struct q_samr_unknown_21_info
977 {
978     POLICY_HND group_pol;        /* policy handle */
979
980         uint16 unknown_1;            /* 16 bit unknown - 0x0477 */
981         uint16 unknown_2;            /* 16 bit unknown - 0x0000 */
982
983 } SAMR_Q_UNKNOWN_21;
984
985
986 /* SAMR_Q_UNKNOWN_32 - probably a "create SAM entry" */
987 typedef struct q_samr_unknown_32_info
988 {
989     POLICY_HND pol;             /* policy handle */
990
991         UNIHDR  hdr_mach_acct;       /* unicode machine account name header */
992         UNISTR2 uni_mach_acct;       /* unicode machine account name */
993
994         uint32 acct_ctrl;            /* 32 bit ACB_XXXX */
995         uint16 unknown_1;            /* 16 bit unknown - 0x00B0 */
996         uint16 unknown_2;            /* 16 bit unknown - 0xe005 */
997
998 } SAMR_Q_UNKNOWN_32;
999
1000
1001 /* SAMR_R_UNKNOWN_32 - probably a "create SAM entry" */
1002 typedef struct r_samr_unknown_32_info
1003 {
1004     POLICY_HND pol;       /* policy handle */
1005
1006         /* rid4.unknown - fail: 0030 success: 0x03ff */
1007         DOM_RID4 rid4;         /* rid and attributes */
1008
1009         uint32 status;         /* return status - fail: 0xC000 0099: user exists */
1010
1011 } SAMR_R_UNKNOWN_32;
1012
1013 /* SAMR_Q_OPEN_ALIAS - probably an open */
1014 typedef struct q_samr_open_alias_info
1015 {
1016         uint32 unknown_0;         /* 0x0000 0008 */
1017         uint32 rid_alias;        /* rid */
1018
1019 } SAMR_Q_OPEN_ALIAS;
1020
1021
1022 /* SAMR_R_OPEN_ALIAS - probably an open */
1023 typedef struct r_samr_open_alias_info
1024 {
1025         POLICY_HND pol;       /* policy handle */
1026         uint32 status;         /* return status */
1027
1028 } SAMR_R_OPEN_ALIAS;
1029
1030
1031 /* SAMR_Q_CONNECT_ANON - probably an open */
1032 typedef struct q_samr_connect_anon_info
1033 {
1034         uint32 ptr;                  /* ptr? */
1035         uint16 unknown_0;            /* 0x005c */
1036         uint16 unknown_1;            /* 0x0001 */
1037         uint32 unknown_2;            /* 0x0000 0020 */
1038
1039 } SAMR_Q_CONNECT_ANON;
1040
1041 /* SAMR_R_CONNECT_ANON - probably an open */
1042 typedef struct r_samr_connect_anon_info
1043 {
1044         POLICY_HND connect_pol;       /* policy handle */
1045         uint32 status;         /* return status */
1046
1047 } SAMR_R_CONNECT_ANON;
1048
1049 /* SAMR_Q_CONNECT - probably an open */
1050 typedef struct q_samr_connect_info
1051 {
1052         uint32 ptr_srv_name;         /* pointer (to server name?) */
1053         UNISTR2 uni_srv_name;        /* unicode server name starting with '\\' */
1054
1055         uint32 unknown_0;            /* 32 bit unknown */
1056
1057 } SAMR_Q_CONNECT;
1058
1059
1060 /* SAMR_R_CONNECT - probably an open */
1061 typedef struct r_samr_connect_info
1062 {
1063     POLICY_HND connect_pol;       /* policy handle */
1064         uint32 status;         /* return status */
1065
1066 } SAMR_R_CONNECT;
1067
1068 /* SAMR_Q_UNKNOWN_38 */
1069 typedef struct q_samr_unknown_38
1070 {
1071         uint32 ptr; 
1072         UNIHDR  hdr_srv_name;
1073         UNISTR2 uni_srv_name;
1074
1075 } SAMR_Q_UNKNOWN_38;
1076
1077 /* SAMR_R_UNKNOWN_38 */
1078 typedef struct r_samr_unknown_38
1079 {
1080         uint16 unk_0;
1081         uint16 unk_1;
1082         uint16 unk_2;
1083         uint16 unk_3;
1084         uint32 status;         /* return status */
1085
1086 } SAMR_R_UNKNOWN_38;
1087
1088 /* SAMR_ENC_PASSWD */
1089 typedef struct enc_passwd_info
1090 {
1091         uint32 ptr;
1092         uint8 pass[516];
1093
1094 } SAMR_ENC_PASSWD;
1095
1096 /* SAMR_ENC_HASH */
1097 typedef struct enc_hash_info
1098 {
1099         uint32 ptr;
1100         uint8 hash[16];
1101
1102 } SAMR_ENC_HASH;
1103
1104 /* SAMR_Q_CHGPASSWD_USER */
1105 typedef struct q_samr_chgpasswd_user_info
1106 {
1107         uint32 ptr_0;
1108
1109         UNIHDR hdr_dest_host; /* server name unicode header */
1110         UNISTR2 uni_dest_host; /* server name unicode string */
1111
1112         UNIHDR hdr_user_name;    /* username unicode string header */
1113         UNISTR2 uni_user_name;    /* username unicode string */
1114
1115         SAMR_ENC_PASSWD nt_newpass;
1116         SAMR_ENC_HASH nt_oldhash;
1117
1118         uint32 unknown; /* 0x0000 0001 */
1119
1120         SAMR_ENC_PASSWD lm_newpass;
1121         SAMR_ENC_HASH lm_oldhash;
1122
1123 } SAMR_Q_CHGPASSWD_USER;
1124
1125 /* SAMR_R_CHGPASSWD_USER */
1126 typedef struct r_samr_chgpasswd_user_info
1127 {
1128         uint32 status; /* 0 == OK, C000006A (NT_STATUS_WRONG_PASSWORD) */
1129
1130 } SAMR_R_CHGPASSWD_USER;
1131
1132 #endif /* _RPC_SAMR_H */
1133