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