"For I have laboured mightily on Luke's code, and hath broken
[tprouty/samba.git] / source / include / rpc_samr.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_OPEN_DOMAIN       0x07
82 #define SAMR_UNKNOWN_8         0x08
83 #define SAMR_LOOKUP_IDS        0x10
84 #define SAMR_LOOKUP_NAMES      0x11
85 #define SAMR_UNKNOWN_3         0x03
86 #define SAMR_QUERY_DISPINFO    0x28
87 #define SAMR_OPEN_USER         0x22
88 #define SAMR_QUERY_USERINFO    0x24
89 #define SAMR_QUERY_USERGROUPS  0x27
90 #define SAMR_UNKNOWN_12        0x12
91 #define SAMR_UNKNOWN_21        0x21
92 #define SAMR_UNKNOWN_32        0x32
93 #define SAMR_UNKNOWN_34        0x34
94 #define SAMR_CONNECT           0x39
95 #define SAMR_OPEN_ALIAS        0x1b
96 #define SAMR_QUERY_ALIASINFO   0x1c
97 #define SAMR_ENUM_DOM_USERS    0x0d
98 #define SAMR_ENUM_DOM_ALIASES  0x0f
99 #define SAMR_ENUM_DOM_GROUPS   0x30
100
101
102 typedef struct logon_hours_info
103 {
104         uint32 len; /* normally 21 bytes */
105         uint8 hours[32];
106
107 } LOGON_HRS;
108
109 /* SAM_USER_INFO_21 */
110 typedef struct sam_user_info_21
111 {
112         NTTIME logon_time;            /* logon time */
113         NTTIME logoff_time;           /* logoff time */
114         NTTIME kickoff_time;          /* kickoff time */
115         NTTIME pass_last_set_time;    /* password last set time */
116         NTTIME pass_can_change_time;  /* password can change time */
117         NTTIME pass_must_change_time; /* password must change time */
118
119         UNIHDR hdr_user_name;    /* username unicode string header */
120         UNIHDR hdr_full_name;    /* user's full name unicode string header */
121         UNIHDR hdr_home_dir;     /* home directory unicode string header */
122         UNIHDR hdr_dir_drive;    /* home drive unicode string header */
123         UNIHDR hdr_logon_script; /* logon script unicode string header */
124         UNIHDR hdr_profile_path; /* profile path unicode string header */
125         UNIHDR hdr_acct_desc  ;  /* user description */
126         UNIHDR hdr_workstations; /* comma-separated workstations user can log in from */
127         UNIHDR hdr_unknown_str ; /* don't know what this is, yet. */
128         UNIHDR hdr_munged_dial ; /* munged path name and dial-back tel number */
129
130         uint8 lm_pwd[16];    /* lm user passwords */
131         uint8 nt_pwd[16];    /* nt user passwords */
132
133         uint32 user_rid;      /* Primary User ID */
134         uint32 group_rid;     /* Primary Group ID */
135
136         uint16 acb_info; /* account info (ACB_xxxx bit-mask) */
137         /* uint8 pad[2] */
138
139         uint32 unknown_3; /* 0x00ff ffff */
140
141         uint16 logon_divs; /* 0x0000 00a8 which is 168 which is num hrs in a week */
142         /* uint8 pad[2] */
143         uint32 ptr_logon_hrs; /* unknown pointer */
144
145         uint32 unknown_5;     /* 0x0002 0000 */
146
147         uint8 padding1[8];
148
149         UNISTR2 uni_user_name;    /* username unicode string */
150         UNISTR2 uni_full_name;    /* user's full name unicode string */
151         UNISTR2 uni_home_dir;     /* home directory unicode string */
152         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
153         UNISTR2 uni_logon_script; /* logon script unicode string */
154         UNISTR2 uni_profile_path; /* profile path unicode string */
155         UNISTR2 uni_acct_desc  ;  /* user description unicode string */
156         UNISTR2 uni_workstations; /* login from workstations unicode string */
157         UNISTR2 uni_unknown_str ; /* don't know what this is, yet. */
158         UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel number */
159
160         uint32 unknown_6; /* 0x0000 04ec */
161         uint32 padding4;
162
163         LOGON_HRS logon_hrs;
164
165 } SAM_USER_INFO_21;
166
167
168 /* SAM_USER_INFO_11 */
169 typedef struct sam_user_info_11
170 {
171         uint8  padding_0[16];  /* 0 - padding 16 bytes */
172         NTTIME expiry;         /* expiry time or something? */
173         uint8  padding_1[24];  /* 0 - padding 24 bytes */
174
175         UNIHDR hdr_mach_acct;  /* unicode header for machine account */
176         uint32 padding_2;      /* 0 - padding 4 bytes */
177
178         uint32 ptr_1;          /* pointer */
179         uint8  padding_3[32];  /* 0 - padding 32 bytes */
180         uint32 padding_4;      /* 0 - padding 4 bytes */
181
182         uint32 ptr_2;          /* pointer */
183         uint32 padding_5;      /* 0 - padding 4 bytes */
184
185         uint32 ptr_3;          /* pointer */
186         uint8  padding_6[32];  /* 0 - padding 32 bytes */
187
188         uint32 rid_user;       /* user RID */
189         uint32 rid_group;      /* group RID */
190
191         uint16 acct_ctrl;      /* 0080 - ACB_XXXX */
192         uint16 unknown_3;      /* 16 bit padding */
193
194         uint16 unknown_4;      /* 0x003f      - 16 bit unknown */
195         uint16 unknown_5;      /* 0x003c      - 16 bit unknown */
196
197         uint8  padding_7[16];  /* 0 - padding 16 bytes */
198         uint32 padding_8;      /* 0 - padding 4 bytes */
199         
200         UNISTR2 uni_mach_acct; /* unicode string for machine account */
201
202         uint8  padding_9[48];  /* 0 - padding 48 bytes */
203
204 } SAM_USER_INFO_11;
205
206
207 /* SAM_USER_INFO_10 */
208 typedef struct sam_user_info_10
209 {
210         uint32 rid_group;
211
212 } SAM_USER_INFO_10;
213
214
215
216 /* SAMR_Q_CLOSE_HND - probably a policy handle close */
217 typedef struct q_samr_close_hnd_info
218 {
219     POLICY_HND pol;          /* policy handle */
220
221 } SAMR_Q_CLOSE_HND;
222
223
224 /* SAMR_R_CLOSE_HND - probably a policy handle close */
225 typedef struct r_samr_close_hnd_info
226 {
227     POLICY_HND pol;       /* policy handle */
228         uint32 status;         /* return status */
229
230 } SAMR_R_CLOSE_HND;
231
232
233 /****************************************************************************
234 SAMR_Q_UNKNOWN_3 - info level 4.  returns SIDs.
235 *****************************************************************************/
236
237 /* SAMR_Q_UNKNOWN_3 - probably get domain info... */
238 typedef struct q_samr_unknown_3_info
239 {
240     POLICY_HND user_pol;          /* policy handle */
241         uint16 switch_value;     /* 0x0000 0004 */
242         /* uint8 pad[2] */
243
244 } SAMR_Q_UNKNOWN_3;
245
246 /* DOM_SID3 example:
247    0x14 0x035b 0x0002 S-1-1
248    0x18 0x07ff 0x000f S-1-5-20-DOMAIN_ALIAS_RID_ADMINS
249    0x18 0x07ff 0x000f S-1-5-20-DOMAIN_ALIAS_RID_ACCOUNT_OPS
250    0x24 0x0044 0x0002 S-1-5-21-nnn-nnn-nnn-0x03f1
251  */
252
253 /* DOM_SID3 example:
254    0x24 0x0044 0x0002 S-1-5-21-nnn-nnn-nnn-0x03ee
255    0x18 0x07ff 0x000f S-1-5-20-DOMAIN_ALIAS_RID_ADMINS
256    0x14 0x035b 0x0002 S-1-1
257  */
258
259 /* DOM_SID3 - security id */
260 typedef struct sid_info_3
261 {
262         uint16 len; /* length, bytes, including length of len :-) */
263         /* uint8  pad[2]; */
264         
265         DOM_SID sid;
266
267 } DOM_SID3;
268
269
270 #define MAX_SAM_SIDS 15
271
272 /* SAM_SID_STUFF */
273 typedef struct sid_stuff_info
274 {
275         uint16 unknown_2; /* 0x0001 */
276         uint16 unknown_3; /* 0x8004 */
277
278         uint8 padding1[8];
279
280         uint32 unknown_4; /* 0x0000 0014 */
281         uint32 unknown_5; /* 0x0000 0014 */
282
283         uint16 unknown_6; /* 0x0002 */
284         uint16 unknown_7; /* 0x5800 */
285
286         uint32 num_sids;
287
288         uint16 padding2;
289
290         DOM_SID3 sid[MAX_SAM_SIDS];
291
292 } SAM_SID_STUFF;
293
294 /* SAMR_R_UNKNOWN_3 - probably an open */
295 typedef struct r_samr_unknown_3_info
296 {
297         uint32 ptr_0;
298         uint32 sid_stuff_len0;
299
300         uint32 ptr_1;
301         uint32 sid_stuff_len1;
302
303         SAM_SID_STUFF sid_stuff;
304
305         uint32 status;         /* return status */
306
307 } SAMR_R_UNKNOWN_3;
308
309
310 /****************************************************************************
311 SAMR_Q_UNKNOWN_8 - probably a query on domain group info.
312 *****************************************************************************/
313
314 /* SAMR_Q_UNKNOWN_8 - */
315 typedef struct q_samr_unknown_8_info
316 {
317     POLICY_HND domain_pol;   /* policy handle */
318         uint16 switch_value;     /* 0x0002 */
319
320 } SAMR_Q_UNKNOWN_8;
321
322 typedef struct sam_unkown_info_2_info
323 {
324         uint32 unknown_0; /* 0x0000 0000 */
325         uint32 unknown_1; /* 0x0000 0000 */
326         uint32 unknown_2; /* 0x8000 0000 */
327         uint32 unknown_3; /* 0x0000 0000 */
328
329         uint32 ptr_0;     /* pointer to unknown structure */
330         UNIHDR hdr_domain; /* domain name unicode header */
331         UNIHDR hdr_server; /* server name unicode header */
332
333         /* put all the data in here, at the moment, including what the above
334            pointer is referring to
335          */
336
337         uint32 unknown_4; /* 0x0000 0099 */
338         uint32 unknown_5; /* 0x0000 0000 */
339         
340         uint32 unknown_6 ; /* 0x0000 0001 */
341         uint32 unknown_7 ; /* 0x0000 0003 */
342         uint32 unknown_8 ; /* 0x0000 0001 */
343         uint32 unknown_9 ; /* 0x0000 0008 */
344         uint32 unknown_10; /* 0x0000 0003 */
345
346         uint8 padding[16]; /* 16 bytes zeros */
347
348         UNISTR2 uni_domain; /* domain name unicode string */
349         UNISTR2 uni_server; /* server name unicode string */
350
351 } SAM_UNK_INFO_2;
352
353
354 typedef struct sam_unknown_ctr_info
355 {
356         union
357         {
358                 SAM_UNK_INFO_2 inf2;
359
360         } info;
361
362 } SAM_UNK_CTR;
363
364
365 /* SAMR_R_UNKNOWN_8 - */
366 typedef struct r_samr_unknown_8_info
367 {
368         uint32 ptr_1;
369         uint16 switch_value; /* same as in query */
370
371         SAM_UNK_CTR *ctr;
372
373         uint32 status;         /* return status */
374
375 } SAMR_R_UNKNOWN_8;
376
377
378 /****************************************************************************
379 SAMR_Q_OPEN_DOMAIN - unknown_0 values seen associated with SIDs:
380
381 0x0000 03f1 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
382 0x0000 0200 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
383 *****************************************************************************/
384
385 /* SAMR_Q_OPEN_DOMAIN */
386 typedef struct q_samr_open_domain_info
387 {
388     POLICY_HND connect_pol;   /* policy handle */
389         uint32 rid;               /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - a RID? */
390         DOM_SID2 dom_sid;         /* domain SID */
391
392 } SAMR_Q_OPEN_DOMAIN;
393
394
395 /* SAMR_R_OPEN_DOMAIN - probably an open */
396 typedef struct r_samr_open_domain_info
397 {
398     POLICY_HND domain_pol; /* policy handle associated with the SID */
399         uint32 status;         /* return status */
400
401 } SAMR_R_OPEN_DOMAIN;
402
403
404 #define MAX_SAM_ENTRIES 250
405
406 typedef struct samr_entry_info
407 {
408         uint32 rid;
409         UNIHDR hdr_name;
410
411 } SAM_ENTRY;
412
413 /* SAMR_Q_ENUM_DOM_USERS - SAM rids and names */
414 typedef struct q_samr_enum_dom_users_info
415 {
416         POLICY_HND pol;          /* policy handle */
417
418         uint16 req_num_entries;   /* number of values (0 indicates unlimited?) */
419         uint16 unknown_0;         /* enumeration context? */
420         uint16 acb_mask;          /* 0x0000 indicates all */
421         uint16 unknown_1;         /* 0x0000 */
422
423         uint32 max_size;              /* 0x0000 ffff */
424
425 } SAMR_Q_ENUM_DOM_USERS;
426
427
428 /* SAMR_R_ENUM_DOM_USERS - SAM rids and names */
429 typedef struct r_samr_enum_dom_users_info
430 {
431         uint16 total_num_entries;  /* number of entries that match without the acb mask */
432         uint16 unknown_0;          /* same as unknown_0 (enum context?) in request */
433         uint32 ptr_entries1;       /* actual number of entries to follow, having masked some out */
434
435         uint32 num_entries2;
436         uint32 ptr_entries2;
437
438         uint32 num_entries3;
439
440         SAM_ENTRY sam[MAX_SAM_ENTRIES];
441         UNISTR2 uni_acct_name[MAX_SAM_ENTRIES];
442
443         uint32 num_entries4;
444
445         uint32 status;
446
447 } SAMR_R_ENUM_DOM_USERS;
448
449
450 typedef struct samr_entry_info3
451 {
452         uint32 grp_idx;
453
454         uint32 rid_grp;
455         uint32 attr;
456
457         UNIHDR hdr_grp_name;
458         UNIHDR hdr_grp_desc;
459
460 } SAM_ENTRY3;
461
462 typedef struct samr_str_entry_info3
463 {
464         UNISTR2 uni_grp_name;
465         UNISTR2 uni_grp_desc;
466
467 } SAM_STR3;
468
469 /* SAMR_Q_ENUM_DOM_GROUPS - SAM rids and names */
470 typedef struct q_samr_enum_dom_groups_info
471 {
472         POLICY_HND pol;          /* policy handle */
473
474         /* these are possibly an enumeration context handle... */
475         uint16 switch_level;      /* 0x0003 */
476         uint16 unknown_0;         /* 0x0000 */
477         uint32 start_idx;       /* presumably the start enumeration index */
478         uint32 unknown_1;       /* 0x0000 07d0 */
479
480         uint32 max_size;        /* 0x0000 7fff */
481
482 } SAMR_Q_ENUM_DOM_GROUPS;
483
484
485 /* SAMR_R_ENUM_DOM_GROUPS - SAM rids and names */
486 typedef struct r_samr_enum_dom_groups_info
487 {
488         uint32 unknown_0;        /* 0x0000 0492 or 0x0000 00be */
489         uint32 unknown_1;        /* 0x0000 049a or 0x0000 00be */
490         uint32 switch_level;     /* 0x0000 0003 */
491
492         uint32 num_entries;
493         uint32 ptr_entries;
494
495         uint32 num_entries2;
496
497         SAM_ENTRY3 sam[MAX_SAM_ENTRIES];
498         SAM_STR3   str[MAX_SAM_ENTRIES];
499
500         uint32 status;
501
502 } SAMR_R_ENUM_DOM_GROUPS;
503
504
505
506 /* SAMR_Q_ENUM_DOM_ALIASES - SAM rids and names */
507 typedef struct q_samr_enum_dom_aliases_info
508 {
509         POLICY_HND pol;          /* policy handle */
510
511         /* this is possibly an enumeration context handle... */
512         uint32 unknown_0;         /* 0x0000 0000 */
513
514         uint32 max_size;              /* 0x0000 ffff */
515
516 } SAMR_Q_ENUM_DOM_ALIASES;
517
518 /* SAMR_R_ENUM_DOM_ALIASES - SAM rids and names */
519 typedef struct r_samr_enum_dom_aliases_info
520 {
521         uint32 num_entries;
522         uint32 ptr_entries;
523
524         uint32 num_entries2;
525         uint32 ptr_entries2;
526
527         uint32 num_entries3;
528
529         SAM_ENTRY sam[MAX_SAM_ENTRIES];
530         UNISTR2 uni_grp_name[MAX_SAM_ENTRIES];
531
532         uint32 num_entries4;
533
534         uint32 status;
535
536 } SAMR_R_ENUM_DOM_ALIASES;
537
538
539
540 /* SAMR_Q_QUERY_DISPINFO - SAM rids, names and descriptions */
541 typedef struct q_samr_query_disp_info
542 {
543         POLICY_HND pol;        /* policy handle */
544
545         uint16 switch_level;    /* 0x0001 and 0x0002 seen */
546         uint16 unknown_0;       /* 0x0000 and 0x2000 seen */
547         uint32 start_idx;       /* presumably the start enumeration index */
548         uint32 unknown_1;       /* 0x0000 07d0, 0x0000 0400 and 0x0000 0200 seen */
549
550         uint32 max_size;        /* 0x0000 7fff, 0x0000 7ffe and 0x0000 3fff seen*/
551
552 } SAMR_Q_QUERY_DISPINFO;
553
554 typedef struct samr_entry_info1
555 {
556         uint32 user_idx;
557
558         uint32 rid_user;
559         uint16 acb_info;
560         uint16 pad;
561
562         UNIHDR hdr_acct_name;
563         UNIHDR hdr_user_name;
564         UNIHDR hdr_user_desc;
565
566 } SAM_ENTRY1;
567
568 typedef struct samr_str_entry_info1
569 {
570         UNISTR2 uni_acct_name;
571         UNISTR2 uni_full_name;
572         UNISTR2 uni_acct_desc;
573
574 } SAM_STR1;
575
576 typedef struct sam_entry_info_1
577 {
578         uint32 num_entries;
579         uint32 ptr_entries;
580         uint32 num_entries2;
581
582         SAM_ENTRY1 sam[MAX_SAM_ENTRIES];
583         SAM_STR1   str[MAX_SAM_ENTRIES];
584
585
586 } SAM_INFO_1;
587
588 typedef struct samr_entry_info2
589 {
590         uint32 user_idx;
591
592         uint32 rid_user;
593         uint16 acb_info;
594         uint16 pad;
595
596         UNIHDR hdr_srv_name;
597         UNIHDR hdr_srv_desc;
598
599 } SAM_ENTRY2;
600
601 typedef struct samr_str_entry_info2
602 {
603         UNISTR2 uni_srv_name;
604         UNISTR2 uni_srv_desc;
605
606 } SAM_STR2;
607
608 typedef struct sam_entry_info_2
609 {
610         uint32 num_entries;
611         uint32 ptr_entries;
612         uint32 num_entries2;
613
614         SAM_ENTRY2 sam[MAX_SAM_ENTRIES];
615         SAM_STR2   str[MAX_SAM_ENTRIES];
616
617 } SAM_INFO_2;
618
619 typedef struct sam_info_ctr_info
620 {
621         union
622         {
623                 SAM_INFO_1 *info1; /* server info */
624                 SAM_INFO_2 *info2; /* user info */
625                 void       *info; /* allows assignment without typecasting, */
626
627         } sam;
628
629 } SAM_INFO_CTR;
630
631 /* SAMR_R_QUERY_DISPINFO - SAM rids, names and descriptions */
632 typedef struct r_samr_query_dispinfo_info
633 {
634         uint32 unknown_0;        /* container length? 0x0000 0492 or 0x0000 00be */
635         uint32 unknown_1;        /* container length? 0x0000 049a or 0x0000 00be */
636         uint16 switch_level;     /* 0x0001 or 0x0002 */
637         /*uint8 pad[2] */
638
639         SAM_INFO_CTR *ctr;
640
641         uint32 status;
642
643 } SAMR_R_QUERY_DISPINFO;
644
645
646
647 /* SAMR_Q_QUERY_ALIASINFO - SAM Alias Info */
648 typedef struct q_samr_enum_alias_info
649 {
650         POLICY_HND pol;        /* policy handle */
651
652         uint16 switch_level;    /* 0x0003 seen */
653
654 } SAMR_Q_QUERY_ALIASINFO;
655
656 typedef struct samr_alias_info3
657 {
658         UNIHDR hdr_acct_desc;
659         UNISTR2 uni_acct_desc;
660
661 } ALIAS_INFO3;
662
663 /* SAMR_R_QUERY_ALIASINFO - SAM rids, names and descriptions */
664 typedef struct r_samr_query_aliasinfo_info
665 {
666         uint32 ptr;        
667         uint16 switch_value;     /* 0x0003 */
668         /* uint8[2] padding */
669
670         union
671     {
672                 ALIAS_INFO3 info3;
673
674     } alias;
675
676         uint32 status;
677
678 } SAMR_R_QUERY_ALIASINFO;
679
680
681 /* SAMR_Q_QUERY_USERGROUPS - */
682 typedef struct q_samr_query_usergroup_info
683 {
684     POLICY_HND pol;          /* policy handle associated with unknown id */
685
686 } SAMR_Q_QUERY_USERGROUPS;
687
688 /* SAMR_R_QUERY_USERGROUPS - probably a get sam info */
689 typedef struct r_samr_query_usergroup_info
690 {
691         uint32 ptr_0;            /* pointer */
692         uint32 num_entries;      /* number of RID groups */
693         uint32 ptr_1;            /* pointer */
694         uint32 num_entries2;     /* number of RID groups */
695
696         DOM_GID *gid; /* group info */
697
698         uint32 status;         /* return status */
699
700 } SAMR_R_QUERY_USERGROUPS;
701
702
703 /* SAMR_Q_QUERY_USERINFO - probably a get sam info */
704 typedef struct q_samr_query_user_info
705 {
706     POLICY_HND pol;          /* policy handle associated with unknown id */
707         uint16 switch_value;         /* 0x0015, 0x0011 or 0x0010 - 16 bit unknown */
708
709 } SAMR_Q_QUERY_USERINFO;
710
711 /* SAMR_R_QUERY_USERINFO - probably a get sam info */
712 typedef struct r_samr_query_user_info
713 {
714         uint32 ptr;            /* pointer */
715         uint16 switch_value;      /* 0x0015, 0x0011 or 0x0010 - same as in query */
716         /* uint8[2] padding. */
717
718         union
719         {
720                 SAM_USER_INFO_10 *id10; /* auth-level 0x10 */
721                 SAM_USER_INFO_11 *id11; /* auth-level 0x11 */
722                 SAM_USER_INFO_21 *id21; /* auth-level 21 */
723                 void* id; /* to make typecasting easy */
724
725         } info;
726
727         uint32 status;         /* return status */
728
729 } SAMR_R_QUERY_USERINFO;
730
731
732 /****************************************************************************
733 SAMR_Q_LOOKUP_IDS - do a conversion from name to RID.
734
735 the policy handle allocated by an "samr open secret" call is associated
736 with a SID.  this policy handle is what is queried here, *not* the SID
737 itself.  the response to the lookup rids is relative to this SID.
738 *****************************************************************************/
739 /* SAMR_Q_LOOKUP_IDS */
740 typedef struct q_samr_lookup_ids_info
741 {
742     POLICY_HND pol;       /* policy handle */
743
744         uint32 num_sids1;      /* number of rids being looked up */
745         uint32 ptr;            /* buffer pointer */
746         uint32 num_sids2;      /* number of rids being looked up */
747
748         uint32   ptr_sid[MAX_LOOKUP_SIDS]; /* pointers to sids to be looked up */
749         DOM_SID2 sid    [MAX_LOOKUP_SIDS]; /* sids to be looked up. */
750
751 } SAMR_Q_LOOKUP_IDS;
752
753
754 /* SAMR_R_LOOKUP_IDS */
755 typedef struct r_samr_lookup_ids_info
756 {
757         uint32 num_entries;
758         uint32 ptr; /* undocumented buffer pointer */
759
760         uint32 num_entries2; 
761         uint32 rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
762
763         uint32 status; /* return code */
764
765 } SAMR_R_LOOKUP_IDS;
766
767
768 /****************************************************************************
769 SAMR_Q_LOOKUP_NAMES - do a conversion from SID to RID.
770
771 the policy handle allocated by an "samr open secret" call is associated
772 with a SID.  this policy handle is what is queried here, *not* the SID
773 itself.  the response to the lookup rids is relative to this SID.
774 *****************************************************************************/
775 /* SAMR_Q_LOOKUP_NAMES */
776 typedef struct q_samr_lookup_names_info
777 {
778     POLICY_HND pol;       /* policy handle */
779
780         uint32 num_rids1;      /* number of rids being looked up */
781         uint32 rid;            /* 0x0000 03e8 - RID of the server doing the query? */
782         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
783         uint32 num_rids2;      /* number of rids being looked up */
784
785         UNIHDR  hdr_user_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
786         UNISTR2 uni_user_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
787
788 } SAMR_Q_LOOKUP_NAMES;
789
790
791 /* SAMR_R_LOOKUP_NAMES */
792 typedef struct r_samr_lookup_names_info
793 {
794         uint32 num_entries;
795         uint32 undoc_buffer; /* undocumented buffer pointer */
796
797         uint32 num_entries2; 
798         DOM_RID3 dom_rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
799
800         uint32 num_entries3; 
801
802         uint32 status; /* return code */
803
804 } SAMR_R_LOOKUP_NAMES;
805
806
807 /****************************************************************************
808 SAMR_Q_UNKNOWN_12 - do a conversion from RID groups to something.
809
810 called to resolve domain RID groups.
811 *****************************************************************************/
812 /* SAMR_Q_UNKNOWN_12 */
813 typedef struct q_samr_unknown_12_info
814 {
815     POLICY_HND pol;       /* policy handle */
816
817         uint32 num_gids1;      /* number of rids being looked up */
818         uint32 rid;            /* 0x0000 03e8 - RID of the server doing the query? */
819         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
820         uint32 num_gids2;      /* number of rids being looked up */
821
822         uint32 gid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
823
824 } SAMR_Q_UNKNOWN_12;
825
826
827 /****************************************************************************
828 SAMR_R_UNKNOWN_12 - do a conversion from group RID to names
829
830 *****************************************************************************/
831 /* SAMR_R_UNKNOWN_12 */
832 typedef struct r_samr_unknown_12_info
833 {
834     POLICY_HND pol;       /* policy handle */
835
836         uint32 num_aliases1;      /* number of aliases being looked up */
837         uint32 ptr_aliases;       /* pointer to aliases */
838         uint32 num_aliases2;      /* number of aliases being looked up */
839
840         UNIHDR  hdr_als_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
841         UNISTR2 uni_als_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
842
843         uint32 num_als_usrs1;      /* number of users in aliases being looked up */
844         uint32 ptr_als_usrs;       /* pointer to users in aliases */
845         uint32 num_als_usrs2;      /* number of users in aliases being looked up */
846
847         uint32 num_als_usrs[MAX_LOOKUP_SIDS]; /* number of users per group */
848
849         uint32 status;
850
851 } SAMR_R_UNKNOWN_12;
852
853
854 /* SAMR_Q_OPEN_USER - probably an open */
855 typedef struct q_samr_open_user_info
856 {
857     POLICY_HND domain_pol;       /* policy handle */
858         uint32 unknown_0;     /* 32 bit unknown - 0x02011b */
859         uint32 user_rid;      /* user RID */
860
861 } SAMR_Q_OPEN_USER;
862
863
864 /* SAMR_R_OPEN_USER - probably an open */
865 typedef struct r_samr_open_user_info
866 {
867     POLICY_HND user_pol;       /* policy handle associated with unknown id */
868         uint32 status;         /* return status */
869
870 } SAMR_R_OPEN_USER;
871
872
873 /* SAMR_Q_UNKNOWN_13 - probably an open alias in domain */
874 typedef struct q_samr_unknown_13_info
875 {
876     POLICY_HND alias_pol;        /* policy handle */
877
878         uint16 unknown_1;            /* 16 bit unknown - 0x0200 */
879         uint16 unknown_2;            /* 16 bit unknown - 0x0000 */
880
881 } SAMR_Q_UNKNOWN_13;
882
883
884 /* SAMR_Q_UNKNOWN_21 - probably an open group in domain */
885 typedef struct q_samr_unknown_21_info
886 {
887     POLICY_HND group_pol;        /* policy handle */
888
889         uint16 unknown_1;            /* 16 bit unknown - 0x0477 */
890         uint16 unknown_2;            /* 16 bit unknown - 0x0000 */
891
892 } SAMR_Q_UNKNOWN_21;
893
894
895 /* SAMR_Q_UNKNOWN_32 - probably a "create SAM entry" */
896 typedef struct q_samr_unknown_32_info
897 {
898     POLICY_HND pol;             /* policy handle */
899
900         UNIHDR  hdr_mach_acct;       /* unicode machine account name header */
901         UNISTR2 uni_mach_acct;       /* unicode machine account name */
902
903         uint32 acct_ctrl;            /* 32 bit ACB_XXXX */
904         uint16 unknown_1;            /* 16 bit unknown - 0x00B0 */
905         uint16 unknown_2;            /* 16 bit unknown - 0xe005 */
906
907 } SAMR_Q_UNKNOWN_32;
908
909
910 /* SAMR_R_UNKNOWN_32 - probably a "create SAM entry" */
911 typedef struct r_samr_unknown_32_info
912 {
913     POLICY_HND pol;       /* policy handle */
914
915         /* rid4.unknown - fail: 0030 success: 0x03ff */
916         DOM_RID4 rid4;         /* rid and attributes */
917
918         uint32 status;         /* return status - fail: 0xC000 0099: user exists */
919
920 } SAMR_R_UNKNOWN_32;
921
922
923 /* SAMR_Q_OPEN_ALIAS - probably an open */
924 typedef struct q_samr_open_alias_info
925 {
926         uint32 unknown_0;         /* 0x0000 0008 */
927         uint32 rid_alias;        /* rid */
928
929 } SAMR_Q_OPEN_ALIAS;
930
931
932 /* SAMR_R_OPEN_ALIAS - probably an open */
933 typedef struct r_samr_open_alias_info
934 {
935     POLICY_HND pol;       /* policy handle */
936         uint32 status;         /* return status */
937
938 } SAMR_R_OPEN_ALIAS;
939
940
941 /* SAMR_Q_CONNECT - probably an open */
942 typedef struct q_samr_connect_info
943 {
944         uint32 ptr_srv_name;         /* pointer (to server name?) */
945         UNISTR2 uni_srv_name;        /* unicode server name starting with '\\' */
946
947         uint32 unknown_0;            /* 32 bit unknown */
948
949 } SAMR_Q_CONNECT;
950
951
952 /* SAMR_R_CONNECT - probably an open */
953 typedef struct r_samr_connect_info
954 {
955     POLICY_HND connect_pol;       /* policy handle */
956         uint32 status;         /* return status */
957
958 } SAMR_R_CONNECT;
959
960 /* SAMR_Q_UNKNOWN_38 */
961 typedef struct q_samr_unknown_38
962 {
963         uint32 ptr; 
964         UNIHDR  hdr_srv_name;
965         UNISTR2 uni_srv_name;
966
967 } SAMR_Q_UNKNOWN_38;
968
969 /* SAMR_R_UNKNOWN_38 */
970 typedef struct r_samr_unknown_38
971 {
972         LOOKUP_LEVEL level; /* 0x0006 */
973         uint32 ptr_0; /* 0x0000 0000 */
974         uint32 status;
975
976 } SAMR_R_UNKNOWN_38;
977
978 /* SAMR_ENC_PASSWD */
979 typedef struct enc_passwd_info
980 {
981         uint32 ptr;
982         uint8 pass[516];
983
984 } SAMR_ENC_PASSWD;
985
986 /* SAMR_ENC_HASH */
987 typedef struct enc_hash_info
988 {
989         uint32 ptr;
990         uint8 hash[16];
991
992 } SAMR_ENC_HASH;
993
994 /* SAMR_Q_CHGPASSWD_USER */
995 typedef struct q_samr_chgpasswd_user_info
996 {
997         uint32 ptr_0;
998
999         UNIHDR hdr_server; /* server name unicode header */
1000         UNISTR2 uni_server; /* server name unicode string */
1001
1002         UNIHDR hdr_user_name;    /* username unicode string header */
1003         UNISTR2 uni_user_name;    /* username unicode string */
1004
1005         SAMR_ENC_PASSWD nt_newpass;
1006         SAMR_ENC_HASH nt_oldhash;
1007
1008         uint32 unknown_1; /* seems to always contain 0001 */
1009
1010         SAMR_ENC_PASSWD lm_newpass;
1011         SAMR_ENC_HASH lm_oldhash;
1012
1013 } SAMR_Q_CHGPASSWD_USER;
1014
1015 /* SAMR_R_CHGPASSWD_USER */
1016 typedef struct r_samr_chgpasswd_user_info
1017 {
1018         uint32 result; /* 0 == OK, C000006A (NT_STATUS_WRONG_PASSWORD) */
1019
1020 } SAMR_R_CHGPASSWD_USER;
1021
1022 #endif /* _RPC_SAMR_H */
1023