adding group member code, made a start. found that the group members'
[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 x SamrAddMemberToAlias
36 x SamrAddMemberToGroup
37 SamrAddMultipleMembersToAlias
38 x SamrChangePasswordUser
39 x SamrCloseHandle
40 x SamrConnect
41 x SamrCreateAliasInDomain
42 x 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 x 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 x SamrSetInformationAlias
69 SamrSetInformationDomain
70 x SamrSetInformationGroup
71 SamrSetInformationUser
72 SamrSetMemberAttributesOfGroup
73 SamrSetSecurityObject
74 SamrShutdownSamServer
75 SamrTestPrivateFunctionsDomain
76 SamrTestPrivateFunctionsUser
77
78 ********************************************************************/
79
80 #define SAMR_CONNECT_ANON      0x00
81 #define SAMR_CLOSE_HND         0x01
82
83 #define SAMR_UNKNOWN_3         0x03
84 #define SAMR_OPEN_DOMAIN       0x07
85
86 #define SAMR_QUERY_DOMAIN_INFO 0x08
87
88 #define SAMR_CREATE_DOM_GROUP  0x0a
89 #define SAMR_ENUM_DOM_USERS    0x0d
90 #define SAMR_CREATE_DOM_ALIAS  0x0e
91 #define SAMR_ENUM_DOM_ALIASES  0x0f
92 #define SAMR_QUERY_USERALIASES 0x10
93
94 #define SAMR_LOOKUP_NAMES      0x11
95 #define SAMR_UNKNOWN_12        0x12
96
97 #define SAMR_OPEN_GROUP        0x13
98 #define SAMR_QUERY_GROUPINFO   0x14
99 #define SAMR_SET_GROUPINFO     0x15
100 #define SAMR_ADD_GROUPMEM      0x16
101 #define SAMR_QUERY_GROUPMEM    0x19
102
103 #define SAMR_OPEN_ALIAS        0x1b
104 #define SAMR_QUERY_ALIASINFO   0x1c
105 #define SAMR_SET_ALIASINFO     0x1d
106 #define SAMR_DELETE_DOM_ALIAS  0x1e
107 #define SAMR_UNK_ALIAS         0x1f
108 #define SAMR_ADD_ALIASMEM      0x20
109 #define SAMR_QUERY_ALIASMEM    0x21
110
111 #define SAMR_OPEN_USER         0x22
112
113 #define SAMR_QUERY_USERINFO    0x24
114 #define SAMR_QUERY_USERGROUPS  0x27
115 #define SAMR_QUERY_DISPINFO    0x28
116
117 #define SAMR_UNKNOWN_2C        0x2c
118 #define SAMR_ENUM_DOM_GROUPS   0x30
119 #define SAMR_UNKNOWN_32        0x32
120 #define SAMR_UNKNOWN_34        0x34
121
122 #define SAMR_CHGPASSWD_USER    0x37
123 #define SAMR_UNKNOWN_38        0x38
124
125 #define SAMR_CONNECT           0x39
126
127
128 typedef struct logon_hours_info
129 {
130         uint32 len; /* normally 21 bytes */
131         uint8 hours[32];
132
133 } LOGON_HRS;
134
135 /* SAM_USER_INFO_21 */
136 typedef struct sam_user_info_21
137 {
138         NTTIME logon_time;            /* logon time */
139         NTTIME logoff_time;           /* logoff time */
140         NTTIME kickoff_time;          /* kickoff time */
141         NTTIME pass_last_set_time;    /* password last set time */
142         NTTIME pass_can_change_time;  /* password can change time */
143         NTTIME pass_must_change_time; /* password must change time */
144
145         UNIHDR hdr_user_name;    /* username unicode string header */
146         UNIHDR hdr_full_name;    /* user's full name unicode string header */
147         UNIHDR hdr_home_dir;     /* home directory unicode string header */
148         UNIHDR hdr_dir_drive;    /* home drive unicode string header */
149         UNIHDR hdr_logon_script; /* logon script unicode string header */
150         UNIHDR hdr_profile_path; /* profile path unicode string header */
151         UNIHDR hdr_acct_desc  ;  /* user description */
152         UNIHDR hdr_workstations; /* comma-separated workstations user can log in from */
153         UNIHDR hdr_unknown_str ; /* don't know what this is, yet. */
154         UNIHDR hdr_munged_dial ; /* munged path name and dial-back tel number */
155
156         uint8 lm_pwd[16];    /* lm user passwords */
157         uint8 nt_pwd[16];    /* nt user passwords */
158
159         uint32 user_rid;      /* Primary User ID */
160         uint32 group_rid;     /* Primary Group ID */
161
162         uint16 acb_info; /* account info (ACB_xxxx bit-mask) */
163         /* uint8 pad[2] */
164
165         uint32 unknown_3; /* 0x00ff ffff */
166
167         uint16 logon_divs; /* 0x0000 00a8 which is 168 which is num hrs in a week */
168         /* uint8 pad[2] */
169         uint32 ptr_logon_hrs; /* unknown pointer */
170
171         uint32 unknown_5;     /* 0x0002 0000 */
172
173         uint8 padding1[8];
174
175         UNISTR2 uni_user_name;    /* username unicode string */
176         UNISTR2 uni_full_name;    /* user's full name unicode string */
177         UNISTR2 uni_home_dir;     /* home directory unicode string */
178         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
179         UNISTR2 uni_logon_script; /* logon script unicode string */
180         UNISTR2 uni_profile_path; /* profile path unicode string */
181         UNISTR2 uni_acct_desc  ;  /* user description unicode string */
182         UNISTR2 uni_workstations; /* login from workstations unicode string */
183         UNISTR2 uni_unknown_str ; /* don't know what this is, yet. */
184         UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel number */
185
186         uint32 unknown_6; /* 0x0000 04ec */
187         uint32 padding4;
188
189         LOGON_HRS logon_hrs;
190
191 } SAM_USER_INFO_21;
192
193
194 /* SAM_USER_INFO_11 */
195 typedef struct sam_user_info_11
196 {
197         uint8  padding_0[16];  /* 0 - padding 16 bytes */
198         NTTIME expiry;         /* expiry time or something? */
199         uint8  padding_1[24];  /* 0 - padding 24 bytes */
200
201         UNIHDR hdr_mach_acct;  /* unicode header for machine account */
202         uint32 padding_2;      /* 0 - padding 4 bytes */
203
204         uint32 ptr_1;          /* pointer */
205         uint8  padding_3[32];  /* 0 - padding 32 bytes */
206         uint32 padding_4;      /* 0 - padding 4 bytes */
207
208         uint32 ptr_2;          /* pointer */
209         uint32 padding_5;      /* 0 - padding 4 bytes */
210
211         uint32 ptr_3;          /* pointer */
212         uint8  padding_6[32];  /* 0 - padding 32 bytes */
213
214         uint32 rid_user;       /* user RID */
215         uint32 rid_group;      /* group RID */
216
217         uint16 acct_ctrl;      /* 0080 - ACB_XXXX */
218         uint16 unknown_3;      /* 16 bit padding */
219
220         uint16 unknown_4;      /* 0x003f      - 16 bit unknown */
221         uint16 unknown_5;      /* 0x003c      - 16 bit unknown */
222
223         uint8  padding_7[16];  /* 0 - padding 16 bytes */
224         uint32 padding_8;      /* 0 - padding 4 bytes */
225         
226         UNISTR2 uni_mach_acct; /* unicode string for machine account */
227
228         uint8  padding_9[48];  /* 0 - padding 48 bytes */
229
230 } SAM_USER_INFO_11;
231
232
233 /* SAM_USER_INFO_10 */
234 typedef struct sam_user_info_10
235 {
236         uint32 acb_info;
237
238 } SAM_USER_INFO_10;
239
240
241
242 /* SAMR_Q_CLOSE_HND - probably a policy handle close */
243 typedef struct q_samr_close_hnd_info
244 {
245     POLICY_HND pol;          /* policy handle */
246
247 } SAMR_Q_CLOSE_HND;
248
249
250 /* SAMR_R_CLOSE_HND - probably a policy handle close */
251 typedef struct r_samr_close_hnd_info
252 {
253         POLICY_HND pol;       /* policy handle */
254         uint32 status;         /* return status */
255
256 } SAMR_R_CLOSE_HND;
257
258
259 /****************************************************************************
260 SAMR_Q_UNKNOWN_2C - a "set user info" occurs just after this
261 *****************************************************************************/
262
263 /* SAMR_Q_UNKNOWN_2C */
264 typedef struct q_samr_unknown_2c_info
265 {
266         POLICY_HND user_pol;          /* policy handle */
267
268 } SAMR_Q_UNKNOWN_2C;
269
270
271 /****************************************************************************
272 SAMR_R_UNKNOWN_2C - a "set user info" occurs just after this
273 *****************************************************************************/
274
275 /* SAMR_R_UNKNOWN_2C */
276 typedef struct r_samr_unknown_2c_info
277 {
278         uint32 unknown_0; /* 0x0016 0000 */
279         uint32 unknown_1; /* 0x0000 0000 */
280         uint32 status; 
281
282 } SAMR_R_UNKNOWN_2C;
283
284
285 /****************************************************************************
286 SAMR_Q_UNKNOWN_3 - info level 4.  returns SIDs.
287 *****************************************************************************/
288
289 /* SAMR_Q_UNKNOWN_3 - probably get domain info... */
290 typedef struct q_samr_unknown_3_info
291 {
292         POLICY_HND user_pol;          /* policy handle */
293         uint16 switch_value;     /* 0x0000 0004 */
294         /* uint8 pad[2] */
295
296 } SAMR_Q_UNKNOWN_3;
297
298 /* DOM_SID3 example:
299    0x14 0x035b 0x0002 S-1-1
300    0x18 0x07ff 0x000f S-1-5-20-DOMAIN_ALIAS_RID_ADMINS
301    0x18 0x07ff 0x000f S-1-5-20-DOMAIN_ALIAS_RID_ACCOUNT_OPS
302    0x24 0x0044 0x0002 S-1-5-21-nnn-nnn-nnn-0x03f1
303  */
304
305 /* DOM_SID3 example:
306    0x24 0x0044 0x0002 S-1-5-21-nnn-nnn-nnn-0x03ee
307    0x18 0x07ff 0x000f S-1-5-20-DOMAIN_ALIAS_RID_ADMINS
308    0x14 0x035b 0x0002 S-1-1
309  */
310
311 /* DOM_SID3 - security id */
312 typedef struct sid_info_3
313 {
314         uint16 len; /* length, bytes, including length of len :-) */
315         /* uint8  pad[2]; */
316         
317         DOM_SID sid;
318
319 } DOM_SID3;
320
321
322 #define MAX_SAM_SIDS 15
323
324 /* SAM_SID_STUFF */
325 typedef struct sid_stuff_info
326 {
327         uint16 unknown_2; /* 0x0001 */
328         uint16 unknown_3; /* 0x8004 */
329
330         uint8 padding1[8];
331
332         uint32 unknown_4; /* 0x0000 0014 */
333         uint32 unknown_5; /* 0x0000 0014 */
334
335         uint16 unknown_6; /* 0x0002 */
336         uint16 unknown_7; /* 0x5800 */
337
338         uint32 num_sids;
339
340         uint16 padding2;
341
342         DOM_SID3 sid[MAX_SAM_SIDS];
343
344 } SAM_SID_STUFF;
345
346 /* SAMR_R_UNKNOWN_3 - probably an open */
347 typedef struct r_samr_unknown_3_info
348 {
349         uint32 ptr_0;
350         uint32 sid_stuff_len0;
351
352         uint32 ptr_1;
353         uint32 sid_stuff_len1;
354
355         SAM_SID_STUFF sid_stuff;
356
357         uint32 status;         /* return status */
358
359 } SAMR_R_UNKNOWN_3;
360
361
362 /****************************************************************************
363 SAMR_Q_QUERY_DOMAIN_INFO - probably a query on domain group info.
364 *****************************************************************************/
365
366 /* SAMR_Q_QUERY_DOMAIN_INFO - */
367 typedef struct q_samr_query_domain_info
368 {
369         POLICY_HND domain_pol;   /* policy handle */
370         uint16 switch_value;     /* 0x0002 */
371
372 } SAMR_Q_QUERY_DOMAIN_INFO;
373
374 typedef struct sam_unkown_info_2_info
375 {
376         uint32 unknown_0; /* 0x0000 0000 */
377         uint32 unknown_1; /* 0x8000 0000 */
378         uint32 unknown_2; /* 0x0000 0000 */
379
380         uint32 ptr_0;     /* pointer to unknown structure */
381         UNIHDR hdr_domain; /* domain name unicode header */
382         UNIHDR hdr_server; /* server name unicode header */
383
384         /* put all the data in here, at the moment, including what the above
385            pointer is referring to
386          */
387
388         uint32 seq_num; /* some sort of incrementing sequence number? */
389         uint32 unknown_3; /* 0x0000 0000 */
390         
391         uint32 unknown_4; /* 0x0000 0001 */
392         uint32 unknown_5; /* 0x0000 0003 */
393         uint32 unknown_6; /* 0x0000 0001 */
394         uint32 num_domain_usrs; /* number of users in domain */
395         uint32 num_domain_grps; /* number of domain groups in domain */
396         uint32 num_local_grps; /* number of local groups in domain */
397
398         uint8 padding[12]; /* 12 bytes zeros */
399
400         UNISTR2 uni_domain; /* domain name unicode string */
401         UNISTR2 uni_server; /* server name unicode string */
402
403 } SAM_UNK_INFO_2;
404
405
406 typedef struct sam_unknown_ctr_info
407 {
408         union
409         {
410                 SAM_UNK_INFO_2 inf2;
411
412         } info;
413
414 } SAM_UNK_CTR;
415
416
417 /* SAMR_R_QUERY_DOMAIN_INFO - */
418 typedef struct r_samr_query_domain_info
419 {
420         uint32 ptr_0;
421         uint16 switch_value; /* same as in query */
422
423         SAM_UNK_CTR *ctr;
424
425         uint32 status;         /* return status */
426
427 } SAMR_R_QUERY_DOMAIN_INFO;
428
429
430 /****************************************************************************
431 SAMR_Q_OPEN_DOMAIN - unknown_0 values seen associated with SIDs:
432
433 0x0000 03f1 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
434 0x0000 0200 and a specific   domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
435 *****************************************************************************/
436
437 /* SAMR_Q_OPEN_DOMAIN */
438 typedef struct q_samr_open_domain_info
439 {
440         POLICY_HND connect_pol;   /* policy handle */
441         uint32 rid;               /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - a RID? */
442         DOM_SID2 dom_sid;         /* domain SID */
443
444 } SAMR_Q_OPEN_DOMAIN;
445
446
447 /* SAMR_R_OPEN_DOMAIN - probably an open */
448 typedef struct r_samr_open_domain_info
449 {
450         POLICY_HND domain_pol; /* policy handle associated with the SID */
451         uint32 status;         /* return status */
452
453 } SAMR_R_OPEN_DOMAIN;
454
455
456 #define MAX_SAM_ENTRIES 250
457
458 typedef struct samr_entry_info
459 {
460         uint32 rid;
461         UNIHDR hdr_name;
462
463 } SAM_ENTRY;
464
465 /* SAMR_Q_ENUM_DOM_USERS - SAM rids and names */
466 typedef struct q_samr_enum_dom_users_info
467 {
468         POLICY_HND pol;          /* policy handle */
469
470         uint16 req_num_entries;   /* number of values (0 indicates unlimited?) */
471         uint16 unknown_0;         /* enumeration context? */
472         uint16 acb_mask;          /* 0x0000 indicates all */
473         uint16 unknown_1;         /* 0x0000 */
474
475         uint32 max_size;              /* 0x0000 ffff */
476
477 } SAMR_Q_ENUM_DOM_USERS;
478
479
480 /* SAMR_R_ENUM_DOM_USERS - SAM rids and names */
481 typedef struct r_samr_enum_dom_users_info
482 {
483         uint16 total_num_entries;  /* number of entries that match without the acb mask */
484         uint16 unknown_0;          /* same as unknown_0 (enum context?) in request */
485         uint32 ptr_entries1;       /* actual number of entries to follow, having masked some out */
486
487         uint32 num_entries2;
488         uint32 ptr_entries2;
489
490         uint32 num_entries3;
491
492         SAM_ENTRY sam[MAX_SAM_ENTRIES];
493         UNISTR2 uni_acct_name[MAX_SAM_ENTRIES];
494
495         uint32 num_entries4;
496
497         uint32 status;
498
499 } SAMR_R_ENUM_DOM_USERS;
500
501
502 typedef struct samr_entry_info3
503 {
504         uint32 grp_idx;
505
506         uint32 rid_grp;
507         uint32 attr;
508
509         UNIHDR hdr_grp_name;
510         UNIHDR hdr_grp_desc;
511
512 } SAM_ENTRY3;
513
514 typedef struct samr_str_entry_info3
515 {
516         UNISTR2 uni_grp_name;
517         UNISTR2 uni_grp_desc;
518
519 } SAM_STR3;
520
521 /* SAMR_Q_ENUM_DOM_GROUPS - SAM rids and names */
522 typedef struct q_samr_enum_dom_groups_info
523 {
524         POLICY_HND pol;          /* policy handle */
525
526         /* these are possibly an enumeration context handle... */
527         uint16 switch_level;      /* 0x0003 */
528         uint16 unknown_0;         /* 0x0000 */
529         uint32 start_idx;       /* presumably the start enumeration index */
530         uint32 unknown_1;       /* 0x0000 07d0 */
531
532         uint32 max_size;        /* 0x0000 7fff */
533
534 } SAMR_Q_ENUM_DOM_GROUPS;
535
536
537 /* SAMR_R_ENUM_DOM_GROUPS - SAM rids and names */
538 typedef struct r_samr_enum_dom_groups_info
539 {
540         uint32 unknown_0;        /* 0x0000 0492 or 0x0000 00be */
541         uint32 unknown_1;        /* 0x0000 049a or 0x0000 00be */
542         uint32 switch_level;     /* 0x0000 0003 */
543
544         uint32 num_entries;
545         uint32 ptr_entries;
546
547         uint32 num_entries2;
548
549         SAM_ENTRY3 sam[MAX_SAM_ENTRIES];
550         SAM_STR3   str[MAX_SAM_ENTRIES];
551
552         uint32 status;
553
554 } SAMR_R_ENUM_DOM_GROUPS;
555
556
557
558 /* SAMR_Q_ENUM_DOM_ALIASES - SAM rids and names */
559 typedef struct q_samr_enum_dom_aliases_info
560 {
561         POLICY_HND pol;          /* policy handle */
562
563         /* this is possibly an enumeration context handle... */
564         uint32 unknown_0;         /* 0x0000 0000 */
565
566         uint32 max_size;              /* 0x0000 ffff */
567
568 } SAMR_Q_ENUM_DOM_ALIASES;
569
570 /* SAMR_R_ENUM_DOM_ALIASES - SAM rids and names */
571 typedef struct r_samr_enum_dom_aliases_info
572 {
573         uint32 num_entries;
574         uint32 ptr_entries;
575
576         uint32 num_entries2;
577         uint32 ptr_entries2;
578
579         uint32 num_entries3;
580
581         SAM_ENTRY sam[MAX_SAM_ENTRIES];
582         UNISTR2 uni_grp_name[MAX_SAM_ENTRIES];
583
584         uint32 num_entries4;
585
586         uint32 status;
587
588 } SAMR_R_ENUM_DOM_ALIASES;
589
590
591
592 /* SAMR_Q_QUERY_DISPINFO - SAM rids, names and descriptions */
593 typedef struct q_samr_query_disp_info
594 {
595         POLICY_HND pol;        /* policy handle */
596
597         uint16 switch_level;    /* 0x0001 and 0x0002 seen */
598         uint16 unknown_0;       /* 0x0000 and 0x2000 seen */
599         uint32 start_idx;       /* presumably the start enumeration index */
600         uint32 unknown_1;       /* 0x0000 07d0, 0x0000 0400 and 0x0000 0200 seen */
601
602         uint32 max_size;        /* 0x0000 7fff, 0x0000 7ffe and 0x0000 3fff seen*/
603
604 } SAMR_Q_QUERY_DISPINFO;
605
606 typedef struct samr_entry_info1
607 {
608         uint32 user_idx;
609
610         uint32 rid_user;
611         uint16 acb_info;
612         uint16 pad;
613
614         UNIHDR hdr_acct_name;
615         UNIHDR hdr_user_name;
616         UNIHDR hdr_user_desc;
617
618 } SAM_ENTRY1;
619
620 typedef struct samr_str_entry_info1
621 {
622         UNISTR2 uni_acct_name;
623         UNISTR2 uni_full_name;
624         UNISTR2 uni_acct_desc;
625
626 } SAM_STR1;
627
628 typedef struct sam_entry_info_1
629 {
630         uint32 num_entries;
631         uint32 ptr_entries;
632         uint32 num_entries2;
633
634         SAM_ENTRY1 sam[MAX_SAM_ENTRIES];
635         SAM_STR1   str[MAX_SAM_ENTRIES];
636
637
638 } SAM_INFO_1;
639
640 typedef struct samr_entry_info2
641 {
642         uint32 user_idx;
643
644         uint32 rid_user;
645         uint16 acb_info;
646         uint16 pad;
647
648         UNIHDR hdr_srv_name;
649         UNIHDR hdr_srv_desc;
650
651 } SAM_ENTRY2;
652
653 typedef struct samr_str_entry_info2
654 {
655         UNISTR2 uni_srv_name;
656         UNISTR2 uni_srv_desc;
657
658 } SAM_STR2;
659
660 typedef struct sam_entry_info_2
661 {
662         uint32 num_entries;
663         uint32 ptr_entries;
664         uint32 num_entries2;
665
666         SAM_ENTRY2 sam[MAX_SAM_ENTRIES];
667         SAM_STR2   str[MAX_SAM_ENTRIES];
668
669 } SAM_INFO_2;
670
671 typedef struct sam_info_ctr_info
672 {
673         union
674         {
675                 SAM_INFO_1 *info1; /* server info */
676                 SAM_INFO_2 *info2; /* user info */
677                 void       *info; /* allows assignment without typecasting, */
678
679         } sam;
680
681 } SAM_INFO_CTR;
682
683 /* SAMR_R_QUERY_DISPINFO - SAM rids, names and descriptions */
684 typedef struct r_samr_query_dispinfo_info
685 {
686         uint32 unknown_0;        /* container length? 0x0000 0492 or 0x0000 00be */
687         uint32 unknown_1;        /* container length? 0x0000 049a or 0x0000 00be */
688         uint16 switch_level;     /* 0x0001 or 0x0002 */
689         /*uint8 pad[2] */
690
691         SAM_INFO_CTR *ctr;
692
693         uint32 status;
694
695 } SAMR_R_QUERY_DISPINFO;
696
697
698 #define SAMR_CREATE_DOM_GROUP  0x0a
699
700 /* SAMR_Q_CREATE_DOM_GROUP - SAM create group */
701 typedef struct q_samr_create_dom_group_info
702 {
703         POLICY_HND pol;        /* policy handle */
704
705         UNIHDR hdr_acct_desc;
706         UNISTR2 uni_acct_desc;
707
708         uint16 unknown_1;    /* 0x0002 */
709         uint16 unknown_2;    /* 0x0001 */
710
711 } SAMR_Q_CREATE_DOM_GROUP;
712
713 /* SAMR_R_CREATE_DOM_GROUP - SAM create group */
714 typedef struct r_samr_create_dom_group_info
715 {
716         POLICY_HND pol;        /* policy handle */
717
718         uint32 rid;    
719         uint32 status;    
720
721 } SAMR_R_CREATE_DOM_GROUP;
722
723 /* SAMR_Q_QUERY_GROUPINFO - SAM Group Info */
724 typedef struct q_samr_query_group_info
725 {
726         POLICY_HND pol;        /* policy handle */
727
728         uint16 switch_level;    /* 0x0001 seen */
729
730 } SAMR_Q_QUERY_GROUPINFO;
731
732 typedef struct samr_group_info1
733 {
734         UNIHDR hdr_acct_name;
735         UNIHDR hdr_acct_desc;
736
737         uint32 unknown_1; /* 0x0000 0003 - number of group members? */
738         uint32 unknown_2; /* 0x0000 0001 - number of group members? */
739
740         UNISTR2 uni_acct_name;
741         UNISTR2 uni_acct_desc;
742
743 } GROUP_INFO1;
744
745 typedef struct samr_group_info4
746 {
747         UNIHDR hdr_acct_desc;
748         UNISTR2 uni_acct_desc;
749
750 } GROUP_INFO4;
751
752 /* GROUP_INFO_CTR */
753 typedef struct group_info_ctr
754 {
755         uint16 switch_value;
756
757         union
758         {
759                 GROUP_INFO4 info4;
760                 GROUP_INFO1 info1;
761
762         } group;
763
764 } GROUP_INFO_CTR;
765
766 /* SAMR_R_QUERY_GROUPINFO - SAM Group Info */
767 typedef struct r_samr_query_groupinfo_info
768 {
769         uint32 ptr;        
770         GROUP_INFO_CTR *ctr;
771
772         uint32 status;
773
774 } SAMR_R_QUERY_GROUPINFO;
775
776
777 /* SAMR_Q_SET_GROUPINFO - SAM Group Info */
778 typedef struct q_samr_set_group_info
779 {
780         POLICY_HND pol;        /* policy handle */
781         GROUP_INFO_CTR *ctr;
782
783 } SAMR_Q_SET_GROUPINFO;
784
785 /* SAMR_R_SET_GROUPINFO - SAM Group Info */
786 typedef struct r_samr_set_group_info
787 {
788         uint32 status;
789
790 } SAMR_R_SET_GROUPINFO;
791
792
793 /* SAMR_Q_DELETE_DOM_ALIAS - delete domain alias */
794 typedef struct q_samr_delete_dom_alias_info
795 {
796     POLICY_HND alias_pol;          /* policy handle */
797
798 } SAMR_Q_DELETE_DOM_ALIAS;
799
800
801 /* SAMR_R_DELETE_DOM_ALIAS - delete domain alias */
802 typedef struct r_samr_delete_dom_alias_info
803 {
804         POLICY_HND pol;       /* policy handle */
805         uint32 status;        /* return status */
806
807 } SAMR_R_DELETE_DOM_ALIAS;
808
809
810 /* SAMR_Q_CREATE_DOM_ALIAS - SAM create alias */
811 typedef struct q_samr_create_dom_alias_info
812 {
813         POLICY_HND dom_pol;        /* policy handle */
814
815         UNIHDR hdr_acct_desc;
816         UNISTR2 uni_acct_desc;
817
818         uint16 unknown_1;    /* 0x001f */
819         uint16 unknown_2;    /* 0x000f */
820
821 } SAMR_Q_CREATE_DOM_ALIAS;
822
823 /* SAMR_R_CREATE_DOM_ALIAS - SAM create alias */
824 typedef struct r_samr_create_dom_alias_info
825 {
826         POLICY_HND alias_pol;        /* policy handle */
827
828         uint32 rid;    
829         uint32 status;    
830
831 } SAMR_R_CREATE_DOM_ALIAS;
832
833 /* SAMR_Q_QUERY_ALIASINFO - SAM Alias Info */
834 typedef struct q_samr_query_alias_info
835 {
836         POLICY_HND pol;        /* policy handle */
837
838         uint16 switch_level;    /* 0x0003 seen */
839
840 } SAMR_Q_QUERY_ALIASINFO;
841
842 typedef struct samr_alias_info3
843 {
844         UNIHDR hdr_acct_desc;
845         UNISTR2 uni_acct_desc;
846
847 } ALIAS_INFO3;
848
849 /* ALIAS_INFO_CTR */
850 typedef struct alias_info_ctr
851 {
852         uint16 switch_value;
853
854         union
855         {
856                 ALIAS_INFO3 info3;
857
858         } alias;
859
860 } ALIAS_INFO_CTR;
861
862 /* SAMR_R_QUERY_ALIASINFO - SAM alias info */
863 typedef struct r_samr_query_aliasinfo_info
864 {
865         uint32 ptr;        
866         ALIAS_INFO_CTR *ctr;
867
868         uint32 status;
869
870 } SAMR_R_QUERY_ALIASINFO;
871
872
873 /* SAMR_Q_SET_ALIASINFO - SAM Alias Info */
874 typedef struct q_samr_set_alias_info
875 {
876         POLICY_HND alias_pol;        /* policy handle */
877         ALIAS_INFO_CTR *ctr;
878
879 } SAMR_Q_SET_ALIASINFO;
880
881 /* SAMR_R_SET_ALIASINFO - SAM alias info */
882 typedef struct r_samr_set_aliasinfo_info
883 {
884         uint32 status;
885
886 } SAMR_R_SET_ALIASINFO;
887
888
889 /* SAMR_Q_QUERY_USERGROUPS - */
890 typedef struct q_samr_query_usergroup_info
891 {
892         POLICY_HND pol;          /* policy handle associated with unknown id */
893
894 } SAMR_Q_QUERY_USERGROUPS;
895
896 /* SAMR_R_QUERY_USERGROUPS - probably a get sam info */
897 typedef struct r_samr_query_usergroup_info
898 {
899         uint32 ptr_0;            /* pointer */
900         uint32 num_entries;      /* number of RID groups */
901         uint32 ptr_1;            /* pointer */
902         uint32 num_entries2;     /* number of RID groups */
903
904         DOM_GID *gid; /* group info */
905
906         uint32 status;         /* return status */
907
908 } SAMR_R_QUERY_USERGROUPS;
909
910
911 /* SAMR_Q_QUERY_USERINFO - probably a get sam info */
912 typedef struct q_samr_query_user_info
913 {
914         POLICY_HND pol;          /* policy handle associated with unknown id */
915         uint16 switch_value;         /* 0x0015, 0x0011 or 0x0010 - 16 bit unknown */
916
917 } SAMR_Q_QUERY_USERINFO;
918
919 /* SAMR_R_QUERY_USERINFO - probably a get sam info */
920 typedef struct r_samr_query_user_info
921 {
922         uint32 ptr;            /* pointer */
923         uint16 switch_value;      /* 0x0015, 0x0011 or 0x0010 - same as in query */
924         /* uint8[2] padding. */
925
926         union
927         {
928                 SAM_USER_INFO_10 *id10; /* auth-level 0x10 */
929                 SAM_USER_INFO_11 *id11; /* auth-level 0x11 */
930                 SAM_USER_INFO_21 *id21; /* auth-level 21 */
931                 void* id; /* to make typecasting easy */
932
933         } info;
934
935         uint32 status;         /* return status */
936
937 } SAMR_R_QUERY_USERINFO;
938
939
940 /****************************************************************************
941 SAMR_Q_QUERY_USERALIASES - do a conversion from name to RID.
942
943 the policy handle allocated by an "samr open secret" call is associated
944 with a SID.  this policy handle is what is queried here, *not* the SID
945 itself.  the response to the lookup rids is relative to this SID.
946 *****************************************************************************/
947 /* SAMR_Q_QUERY_USERALIASES */
948 typedef struct q_samr_query_useraliases_info
949 {
950         POLICY_HND pol;       /* policy handle */
951
952         uint32 num_sids1;      /* number of rids being looked up */
953         uint32 ptr;            /* buffer pointer */
954         uint32 num_sids2;      /* number of rids being looked up */
955
956         uint32   ptr_sid[MAX_LOOKUP_SIDS]; /* pointers to sids to be looked up */
957         DOM_SID2 sid    [MAX_LOOKUP_SIDS]; /* sids to be looked up. */
958
959 } SAMR_Q_QUERY_USERALIASES;
960
961
962 /* SAMR_R_QUERY_USERALIASES */
963 typedef struct r_samr_query_useraliases_info
964 {
965         uint32 num_entries;
966         uint32 ptr; /* undocumented buffer pointer */
967
968         uint32 num_entries2; 
969         uint32 *rid; /* domain RIDs being looked up */
970
971         uint32 status; /* return code */
972
973 } SAMR_R_QUERY_USERALIASES;
974
975
976 /****************************************************************************
977 SAMR_Q_LOOKUP_NAMES - do a conversion from SID to RID.
978
979 the policy handle allocated by an "samr open secret" call is associated
980 with a SID.  this policy handle is what is queried here, *not* the SID
981 itself.  the response to the lookup rids is relative to this SID.
982 *****************************************************************************/
983 /* SAMR_Q_LOOKUP_NAMES */
984 typedef struct q_samr_lookup_names_info
985 {
986     POLICY_HND pol;       /* policy handle */
987
988         uint32 num_rids1;      /* number of rids being looked up */
989         uint32 rid;            /* 0x0000 03e8 - RID of the server doing the query? */
990         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
991         uint32 num_rids2;      /* number of rids being looked up */
992
993         UNIHDR  hdr_user_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
994         UNISTR2 uni_user_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
995
996 } SAMR_Q_LOOKUP_NAMES;
997
998
999 /* SAMR_R_LOOKUP_NAMES */
1000 typedef struct r_samr_lookup_names_info
1001 {
1002         uint32 num_entries;
1003         uint32 undoc_buffer; /* undocumented buffer pointer */
1004
1005         uint32 num_entries2; 
1006         DOM_RID3 dom_rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
1007
1008         uint32 status; /* return code */
1009
1010 } SAMR_R_LOOKUP_NAMES;
1011
1012
1013 /****************************************************************************
1014 SAMR_Q_UNKNOWN_12 - do a conversion from RID groups to something.
1015
1016 called to resolve domain RID groups.
1017 *****************************************************************************/
1018 /* SAMR_Q_UNKNOWN_12 */
1019 typedef struct q_samr_unknown_12_info
1020 {
1021         POLICY_HND pol;       /* policy handle */
1022
1023         uint32 num_gids1;      /* number of rids being looked up */
1024         uint32 rid;            /* 0x0000 03e8 - RID of the server doing the query? */
1025         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
1026         uint32 num_gids2;      /* number of rids being looked up */
1027
1028         uint32 gid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
1029
1030 } SAMR_Q_UNKNOWN_12;
1031
1032
1033 /****************************************************************************
1034 SAMR_R_UNKNOWN_12 - do a conversion from group RID to names
1035
1036 *****************************************************************************/
1037 /* SAMR_R_UNKNOWN_12 */
1038 typedef struct r_samr_unknown_12_info
1039 {
1040     POLICY_HND pol;       /* policy handle */
1041
1042         uint32 num_aliases1;      /* number of aliases being looked up */
1043         uint32 ptr_aliases;       /* pointer to aliases */
1044         uint32 num_aliases2;      /* number of aliases being looked up */
1045
1046         UNIHDR  hdr_als_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
1047         UNISTR2 uni_als_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
1048
1049         uint32 num_als_usrs1;      /* number of users in aliases being looked up */
1050         uint32 ptr_als_usrs;       /* pointer to users in aliases */
1051         uint32 num_als_usrs2;      /* number of users in aliases being looked up */
1052
1053         uint32 num_als_usrs[MAX_LOOKUP_SIDS]; /* number of users per group */
1054
1055         uint32 status;
1056
1057 } SAMR_R_UNKNOWN_12;
1058
1059
1060 /* SAMR_Q_OPEN_USER - probably an open */
1061 typedef struct q_samr_open_user_info
1062 {
1063         POLICY_HND domain_pol;       /* policy handle */
1064         uint32 unknown_0;     /* 32 bit unknown - 0x02011b */
1065         uint32 user_rid;      /* user RID */
1066
1067 } SAMR_Q_OPEN_USER;
1068
1069
1070 /* SAMR_R_OPEN_USER - probably an open */
1071 typedef struct r_samr_open_user_info
1072 {
1073         POLICY_HND user_pol;       /* policy handle associated with unknown id */
1074         uint32 status;         /* return status */
1075
1076 } SAMR_R_OPEN_USER;
1077
1078
1079
1080 /* SAMR_Q_UNKNOWN_32 - probably a "create SAM entry" */
1081 typedef struct q_samr_unknown_32_info
1082 {
1083     POLICY_HND pol;             /* policy handle */
1084
1085         UNIHDR  hdr_mach_acct;       /* unicode machine account name header */
1086         UNISTR2 uni_mach_acct;       /* unicode machine account name */
1087
1088         uint32 acct_ctrl;            /* 32 bit ACB_XXXX */
1089         uint16 unknown_1;            /* 16 bit unknown - 0x00B0 */
1090         uint16 unknown_2;            /* 16 bit unknown - 0xe005 */
1091
1092 } SAMR_Q_UNKNOWN_32;
1093
1094
1095 /* SAMR_R_UNKNOWN_32 - probably a "create SAM entry" */
1096 typedef struct r_samr_unknown_32_info
1097 {
1098     POLICY_HND pol;       /* policy handle */
1099
1100         /* rid4.unknown - fail: 0030 success: 0x03ff */
1101         DOM_RID4 rid4;         /* rid and attributes */
1102
1103         uint32 status;         /* return status - fail: 0xC000 0099: user exists */
1104
1105 } SAMR_R_UNKNOWN_32;
1106
1107 /* SAMR_Q_QUERY_GROUPMEM - query group members */
1108 typedef struct q_samr_query_groupmem_info
1109 {
1110         POLICY_HND group_pol;        /* policy handle */
1111
1112 } SAMR_Q_QUERY_GROUPMEM;
1113
1114
1115 /* SAMR_R_QUERY_GROUPMEM - query group members */
1116 typedef struct r_samr_query_groupmem_info
1117 {
1118         uint32 ptr;
1119         uint32 num_entries;
1120
1121         uint32 ptr_rids;
1122         uint32 ptr_attrs;
1123
1124         uint32 num_rids;
1125         uint32 *rid;
1126
1127         uint32 num_attrs;
1128         uint32 *attr;
1129
1130         uint32 status;
1131
1132 } SAMR_R_QUERY_GROUPMEM;
1133
1134
1135 /* SAMR_Q_ADD_GROUPMEM - probably an add group member */
1136 typedef struct q_samr_add_group_mem_info
1137 {
1138         POLICY_HND pol;       /* policy handle */
1139
1140         uint32 rid;         /* rid */
1141         uint32 unknown;     /* 0x0000 0005 */
1142
1143 } SAMR_Q_ADD_GROUPMEM;
1144
1145
1146 /* SAMR_R_ADD_GROUPMEM - probably an add group member */
1147 typedef struct r_samr_add_group_mem_info
1148 {
1149         uint32 status;         /* return status */
1150
1151 } SAMR_R_ADD_GROUPMEM;
1152
1153
1154 /* SAMR_Q_OPEN_GROUP - probably an open */
1155 typedef struct q_samr_open_group_info
1156 {
1157         POLICY_HND domain_pol;       /* policy handle */
1158         uint32 unknown;         /* 0x0000 0001, 0x0000 0003, 0x0000 001f */
1159         uint32 rid_group;        /* rid */
1160
1161 } SAMR_Q_OPEN_GROUP;
1162
1163
1164 /* SAMR_R_OPEN_GROUP - probably an open */
1165 typedef struct r_samr_open_group_info
1166 {
1167         POLICY_HND pol;       /* policy handle */
1168         uint32 status;         /* return status */
1169
1170 } SAMR_R_OPEN_GROUP;
1171
1172
1173 /* SAMR_Q_QUERY_ALIASMEM - query alias members */
1174 typedef struct q_samr_query_aliasmem_info
1175 {
1176         POLICY_HND alias_pol;        /* policy handle */
1177
1178 } SAMR_Q_QUERY_ALIASMEM;
1179
1180
1181 /* SAMR_R_QUERY_ALIASMEM - query alias members */
1182 typedef struct r_samr_query_aliasmem_info
1183 {
1184         uint32 num_sids;
1185         uint32 ptr;
1186         uint32 num_sids1;
1187
1188         DOM_SID2 *sid;
1189
1190         uint32 status;
1191
1192 } SAMR_R_QUERY_ALIASMEM;
1193
1194
1195 /* SAMR_Q_UNK_ALIASMEM - don't know! */
1196 typedef struct q_samr_unk_alias_mem_info
1197 {
1198         POLICY_HND alias_pol;       /* policy handle */
1199
1200         DOM_SID sid; /* member sid to be "something"ed to do with the alias */
1201
1202 } SAMR_Q_UNK_ALIASMEM;
1203
1204
1205 /* SAMR_R_UNK_ALIASMEM - probably an open */
1206 typedef struct r_samr_unk_alias_mem_info
1207 {
1208         uint32 status;         /* return status */
1209
1210 } SAMR_R_UNK_ALIASMEM;
1211
1212
1213 /* SAMR_Q_ADD_ALIASMEM - probably an add member */
1214 typedef struct q_samr_add_alias_mem_info
1215 {
1216         POLICY_HND alias_pol;       /* policy handle */
1217
1218         DOM_SID sid; /* member sid to be added to alias */
1219
1220 } SAMR_Q_ADD_ALIASMEM;
1221
1222
1223 /* SAMR_R_ADD_ALIASMEM - probably an open */
1224 typedef struct r_samr_add_alias_mem_info
1225 {
1226         uint32 status;         /* return status */
1227
1228 } SAMR_R_ADD_ALIASMEM;
1229
1230
1231
1232 /* SAMR_Q_OPEN_ALIAS - probably an open */
1233 typedef struct q_samr_open_alias_info
1234 {
1235         POLICY_HND dom_pol;
1236
1237         uint32 unknown_0;         /* 0x0000 0008 */
1238         uint32 rid_alias;        /* rid */
1239
1240 } SAMR_Q_OPEN_ALIAS;
1241
1242
1243 /* SAMR_R_OPEN_ALIAS - probably an open */
1244 typedef struct r_samr_open_alias_info
1245 {
1246         POLICY_HND pol;       /* policy handle */
1247         uint32 status;         /* return status */
1248
1249 } SAMR_R_OPEN_ALIAS;
1250
1251
1252 /* SAMR_Q_CONNECT_ANON - probably an open */
1253 typedef struct q_samr_connect_anon_info
1254 {
1255         uint32 ptr;                  /* ptr? */
1256         uint16 unknown_0;            /* 0x005c */
1257         uint16 unknown_1;            /* 0x0001 */
1258         uint32 unknown_2;            /* 0x0000 0020 */
1259
1260 } SAMR_Q_CONNECT_ANON;
1261
1262 /* SAMR_R_CONNECT_ANON - probably an open */
1263 typedef struct r_samr_connect_anon_info
1264 {
1265         POLICY_HND connect_pol;       /* policy handle */
1266         uint32 status;         /* return status */
1267
1268 } SAMR_R_CONNECT_ANON;
1269
1270 /* SAMR_Q_CONNECT - probably an open */
1271 typedef struct q_samr_connect_info
1272 {
1273         uint32 ptr_srv_name;         /* pointer (to server name?) */
1274         UNISTR2 uni_srv_name;        /* unicode server name starting with '\\' */
1275
1276         uint32 unknown_0;            /* 32 bit unknown */
1277
1278 } SAMR_Q_CONNECT;
1279
1280
1281 /* SAMR_R_CONNECT - probably an open */
1282 typedef struct r_samr_connect_info
1283 {
1284     POLICY_HND connect_pol;       /* policy handle */
1285         uint32 status;         /* return status */
1286
1287 } SAMR_R_CONNECT;
1288
1289 /* SAMR_Q_UNKNOWN_38 */
1290 typedef struct q_samr_unknown_38
1291 {
1292         uint32 ptr; 
1293         UNIHDR  hdr_srv_name;
1294         UNISTR2 uni_srv_name;
1295
1296 } SAMR_Q_UNKNOWN_38;
1297
1298 /* SAMR_R_UNKNOWN_38 */
1299 typedef struct r_samr_unknown_38
1300 {
1301         uint16 unk_0;
1302         uint16 unk_1;
1303         uint16 unk_2;
1304         uint16 unk_3;
1305
1306 } SAMR_R_UNKNOWN_38;
1307
1308 /* SAMR_ENC_PASSWD */
1309 typedef struct enc_passwd_info
1310 {
1311         uint32 ptr;
1312         uint8 pass[516];
1313
1314 } SAMR_ENC_PASSWD;
1315
1316 /* SAMR_ENC_HASH */
1317 typedef struct enc_hash_info
1318 {
1319         uint32 ptr;
1320         uint8 hash[16];
1321
1322 } SAMR_ENC_HASH;
1323
1324 /* SAMR_Q_CHGPASSWD_USER */
1325 typedef struct q_samr_chgpasswd_user_info
1326 {
1327         uint32 ptr_0;
1328
1329         UNIHDR hdr_dest_host; /* server name unicode header */
1330         UNISTR2 uni_dest_host; /* server name unicode string */
1331
1332         UNIHDR hdr_user_name;    /* username unicode string header */
1333         UNISTR2 uni_user_name;    /* username unicode string */
1334
1335         SAMR_ENC_PASSWD nt_newpass;
1336         SAMR_ENC_HASH nt_oldhash;
1337
1338         uint32 unknown; /* 0x0000 0001 */
1339
1340         SAMR_ENC_PASSWD lm_newpass;
1341         SAMR_ENC_HASH lm_oldhash;
1342
1343 } SAMR_Q_CHGPASSWD_USER;
1344
1345 /* SAMR_R_CHGPASSWD_USER */
1346 typedef struct r_samr_chgpasswd_user_info
1347 {
1348         uint32 status; /* 0 == OK, C000006A (NT_STATUS_WRONG_PASSWORD) */
1349
1350 } SAMR_R_CHGPASSWD_USER;
1351
1352 #endif /* _RPC_SAMR_H */
1353