- renamed do_samr_xxx to samr_xxx
[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-1998
6    Copyright (C) Luke Kenneth Casson Leighton 1996-1998
7    Copyright (C) Paul Ashton 1997-1998
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_LOOKUP_RIDS       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 flags;               /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - flags? */
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 /* SAMR_Q_CREATE_DOM_GROUP - SAM create group */
699 typedef struct q_samr_create_dom_group_info
700 {
701         POLICY_HND pol;        /* policy handle */
702
703         UNIHDR hdr_acct_desc;
704         UNISTR2 uni_acct_desc;
705
706         uint16 unknown_1;    /* 0x0002 */
707         uint16 unknown_2;    /* 0x0001 */
708
709 } SAMR_Q_CREATE_DOM_GROUP;
710
711 /* SAMR_R_CREATE_DOM_GROUP - SAM create group */
712 typedef struct r_samr_create_dom_group_info
713 {
714         POLICY_HND pol;        /* policy handle */
715
716         uint32 rid;    
717         uint32 status;    
718
719 } SAMR_R_CREATE_DOM_GROUP;
720
721 /* SAMR_Q_QUERY_GROUPINFO - SAM Group Info */
722 typedef struct q_samr_query_group_info
723 {
724         POLICY_HND pol;        /* policy handle */
725
726         uint16 switch_level;    /* 0x0001 seen */
727
728 } SAMR_Q_QUERY_GROUPINFO;
729
730 typedef struct samr_group_info1
731 {
732         UNIHDR hdr_acct_name;
733
734         uint32 unknown_1; /* 0x0000 0003 - number of group members? */
735         uint32 unknown_2; /* 0x0000 0001 - number of group members? */
736
737         UNIHDR hdr_acct_desc;
738
739         UNISTR2 uni_acct_name;
740         UNISTR2 uni_acct_desc;
741
742 } GROUP_INFO1;
743
744 typedef struct samr_group_info4
745 {
746         UNIHDR hdr_acct_desc;
747         UNISTR2 uni_acct_desc;
748
749 } GROUP_INFO4;
750
751 /* GROUP_INFO_CTR */
752 typedef struct group_info_ctr
753 {
754         uint16 switch_value1;
755         uint16 switch_value2;
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_value1;
853         uint16 switch_value2;
854
855         union
856         {
857                 ALIAS_INFO3 info3;
858
859         } alias;
860
861 } ALIAS_INFO_CTR;
862
863 /* SAMR_R_QUERY_ALIASINFO - SAM alias info */
864 typedef struct r_samr_query_aliasinfo_info
865 {
866         uint32 ptr;        
867         ALIAS_INFO_CTR *ctr;
868
869         uint32 status;
870
871 } SAMR_R_QUERY_ALIASINFO;
872
873
874 /* SAMR_Q_SET_ALIASINFO - SAM Alias Info */
875 typedef struct q_samr_set_alias_info
876 {
877         POLICY_HND alias_pol;        /* policy handle */
878         ALIAS_INFO_CTR *ctr;
879
880 } SAMR_Q_SET_ALIASINFO;
881
882 /* SAMR_R_SET_ALIASINFO - SAM alias info */
883 typedef struct r_samr_set_aliasinfo_info
884 {
885         uint32 status;
886
887 } SAMR_R_SET_ALIASINFO;
888
889
890 /* SAMR_Q_QUERY_USERGROUPS - */
891 typedef struct q_samr_query_usergroup_info
892 {
893         POLICY_HND pol;          /* policy handle associated with unknown id */
894
895 } SAMR_Q_QUERY_USERGROUPS;
896
897 /* SAMR_R_QUERY_USERGROUPS - probably a get sam info */
898 typedef struct r_samr_query_usergroup_info
899 {
900         uint32 ptr_0;            /* pointer */
901         uint32 num_entries;      /* number of RID groups */
902         uint32 ptr_1;            /* pointer */
903         uint32 num_entries2;     /* number of RID groups */
904
905         DOM_GID *gid; /* group info */
906
907         uint32 status;         /* return status */
908
909 } SAMR_R_QUERY_USERGROUPS;
910
911
912 /* SAMR_Q_QUERY_USERINFO - probably a get sam info */
913 typedef struct q_samr_query_user_info
914 {
915         POLICY_HND pol;          /* policy handle associated with unknown id */
916         uint16 switch_value;         /* 0x0015, 0x0011 or 0x0010 - 16 bit unknown */
917
918 } SAMR_Q_QUERY_USERINFO;
919
920 /* SAMR_R_QUERY_USERINFO - probably a get sam info */
921 typedef struct r_samr_query_user_info
922 {
923         uint32 ptr;            /* pointer */
924         uint16 switch_value;      /* 0x0015, 0x0011 or 0x0010 - same as in query */
925         /* uint8[2] padding. */
926
927         union
928         {
929                 SAM_USER_INFO_10 *id10; /* auth-level 0x10 */
930                 SAM_USER_INFO_11 *id11; /* auth-level 0x11 */
931                 SAM_USER_INFO_21 *id21; /* auth-level 21 */
932                 void* id; /* to make typecasting easy */
933
934         } info;
935
936         uint32 status;         /* return status */
937
938 } SAMR_R_QUERY_USERINFO;
939
940
941 /****************************************************************************
942 SAMR_Q_QUERY_USERALIASES - do a conversion from name to RID.
943
944 the policy handle allocated by an "samr open secret" call is associated
945 with a SID.  this policy handle is what is queried here, *not* the SID
946 itself.  the response to the lookup rids is relative to this SID.
947 *****************************************************************************/
948 /* SAMR_Q_QUERY_USERALIASES */
949 typedef struct q_samr_query_useraliases_info
950 {
951         POLICY_HND pol;       /* policy handle */
952
953         uint32 num_sids1;      /* number of rids being looked up */
954         uint32 ptr;            /* buffer pointer */
955         uint32 num_sids2;      /* number of rids being looked up */
956
957         uint32   ptr_sid[MAX_LOOKUP_SIDS]; /* pointers to sids to be looked up */
958         DOM_SID2 sid    [MAX_LOOKUP_SIDS]; /* sids to be looked up. */
959
960 } SAMR_Q_QUERY_USERALIASES;
961
962
963 /* SAMR_R_QUERY_USERALIASES */
964 typedef struct r_samr_query_useraliases_info
965 {
966         uint32 num_entries;
967         uint32 ptr; /* undocumented buffer pointer */
968
969         uint32 num_entries2; 
970         uint32 *rid; /* domain RIDs being looked up */
971
972         uint32 status; /* return code */
973
974 } SAMR_R_QUERY_USERALIASES;
975
976
977 /****************************************************************************
978 SAMR_Q_LOOKUP_NAMES - do a conversion from SID to RID.
979
980 the policy handle allocated by an "samr open secret" call is associated
981 with a SID.  this policy handle is what is queried here, *not* the SID
982 itself.  the response to the lookup rids is relative to this SID.
983 *****************************************************************************/
984 /* SAMR_Q_LOOKUP_NAMES */
985 typedef struct q_samr_lookup_names_info
986 {
987     POLICY_HND pol;       /* policy handle */
988
989         uint32 num_rids1;      /* number of rids being looked up */
990         uint32 rid;            /* 0x0000 03e8 - RID of the server doing the query? */
991         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
992         uint32 num_rids2;      /* number of rids being looked up */
993
994         UNIHDR  hdr_user_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
995         UNISTR2 uni_user_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
996
997 } SAMR_Q_LOOKUP_NAMES;
998
999
1000 /* SAMR_R_LOOKUP_NAMES */
1001 typedef struct r_samr_lookup_names_info
1002 {
1003         uint32 num_entries;
1004         uint32 undoc_buffer; /* undocumented buffer pointer */
1005
1006         uint32 num_entries2; 
1007         DOM_RID3 dom_rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
1008
1009         uint32 status; /* return code */
1010
1011 } SAMR_R_LOOKUP_NAMES;
1012
1013
1014 /****************************************************************************
1015 SAMR_Q_LOOKUP_RIDS - do a conversion from RID groups to something.
1016
1017 called to resolve domain RID groups.
1018 *****************************************************************************/
1019 /* SAMR_Q_LOOKUP_RIDS */
1020 typedef struct q_samr_lookup_rids_info
1021 {
1022         POLICY_HND pol;       /* policy handle */
1023
1024         uint32 num_rids1;      /* number of rids being looked up */
1025         uint32 flags;          /* 0x0000 03e8 - RID of the server doing the query? */
1026         uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
1027         uint32 num_rids2;      /* number of rids being looked up */
1028
1029         uint32 rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
1030
1031 } SAMR_Q_LOOKUP_RIDS;
1032
1033
1034 /****************************************************************************
1035 SAMR_R_LOOKUP_RIDS - do a conversion from group RID to names
1036
1037 *****************************************************************************/
1038 /* SAMR_R_LOOKUP_RIDS */
1039 typedef struct r_samr_lookup_rids_info
1040 {
1041         uint32 num_names1;      /* number of aliases being looked up */
1042         uint32 ptr_names;       /* pointer to aliases */
1043         uint32 num_names2;      /* number of aliases being looked up */
1044
1045         UNIHDR  hdr_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
1046         UNISTR2 uni_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
1047
1048         uint32 num_types1;      /* number of users in aliases being looked up */
1049         uint32 ptr_types;       /* pointer to users in aliases */
1050         uint32 num_types2;      /* number of users in aliases being looked up */
1051
1052         uint32 type[MAX_LOOKUP_SIDS]; /* SID_ENUM type */
1053
1054         uint32 status;
1055
1056 } SAMR_R_LOOKUP_RIDS;
1057
1058
1059 /* SAMR_Q_OPEN_USER - probably an open */
1060 typedef struct q_samr_open_user_info
1061 {
1062         POLICY_HND domain_pol;       /* policy handle */
1063         uint32 unknown_0;     /* 32 bit unknown - 0x02011b */
1064         uint32 user_rid;      /* user RID */
1065
1066 } SAMR_Q_OPEN_USER;
1067
1068
1069 /* SAMR_R_OPEN_USER - probably an open */
1070 typedef struct r_samr_open_user_info
1071 {
1072         POLICY_HND user_pol;       /* policy handle associated with unknown id */
1073         uint32 status;         /* return status */
1074
1075 } SAMR_R_OPEN_USER;
1076
1077
1078
1079 /* SAMR_Q_UNKNOWN_32 - probably a "create SAM entry" */
1080 typedef struct q_samr_unknown_32_info
1081 {
1082     POLICY_HND pol;             /* policy handle */
1083
1084         UNIHDR  hdr_mach_acct;       /* unicode machine account name header */
1085         UNISTR2 uni_mach_acct;       /* unicode machine account name */
1086
1087         uint32 acct_ctrl;            /* 32 bit ACB_XXXX */
1088         uint16 unknown_1;            /* 16 bit unknown - 0x00B0 */
1089         uint16 unknown_2;            /* 16 bit unknown - 0xe005 */
1090
1091 } SAMR_Q_UNKNOWN_32;
1092
1093
1094 /* SAMR_R_UNKNOWN_32 - probably a "create SAM entry" */
1095 typedef struct r_samr_unknown_32_info
1096 {
1097     POLICY_HND pol;       /* policy handle */
1098
1099         /* rid4.unknown - fail: 0030 success: 0x03ff */
1100         DOM_RID4 rid4;         /* rid and attributes */
1101
1102         uint32 status;         /* return status - fail: 0xC000 0099: user exists */
1103
1104 } SAMR_R_UNKNOWN_32;
1105
1106 /* SAMR_Q_QUERY_GROUPMEM - query group members */
1107 typedef struct q_samr_query_groupmem_info
1108 {
1109         POLICY_HND group_pol;        /* policy handle */
1110
1111 } SAMR_Q_QUERY_GROUPMEM;
1112
1113
1114 /* SAMR_R_QUERY_GROUPMEM - query group members */
1115 typedef struct r_samr_query_groupmem_info
1116 {
1117         uint32 ptr;
1118         uint32 num_entries;
1119
1120         uint32 ptr_rids;
1121         uint32 ptr_attrs;
1122
1123         uint32 num_rids;
1124         uint32 *rid;
1125
1126         uint32 num_attrs;
1127         uint32 *attr;
1128
1129         uint32 status;
1130
1131 } SAMR_R_QUERY_GROUPMEM;
1132
1133
1134 /* SAMR_Q_ADD_GROUPMEM - probably an add group member */
1135 typedef struct q_samr_add_group_mem_info
1136 {
1137         POLICY_HND pol;       /* policy handle */
1138
1139         uint32 rid;         /* rid */
1140         uint32 unknown;     /* 0x0000 0005 */
1141
1142 } SAMR_Q_ADD_GROUPMEM;
1143
1144
1145 /* SAMR_R_ADD_GROUPMEM - probably an add group member */
1146 typedef struct r_samr_add_group_mem_info
1147 {
1148         uint32 status;         /* return status */
1149
1150 } SAMR_R_ADD_GROUPMEM;
1151
1152
1153 /* SAMR_Q_OPEN_GROUP - probably an open */
1154 typedef struct q_samr_open_group_info
1155 {
1156         POLICY_HND domain_pol;       /* policy handle */
1157         uint32 unknown;         /* 0x0000 0001, 0x0000 0003, 0x0000 001f */
1158         uint32 rid_group;        /* rid */
1159
1160 } SAMR_Q_OPEN_GROUP;
1161
1162
1163 /* SAMR_R_OPEN_GROUP - probably an open */
1164 typedef struct r_samr_open_group_info
1165 {
1166         POLICY_HND pol;       /* policy handle */
1167         uint32 status;         /* return status */
1168
1169 } SAMR_R_OPEN_GROUP;
1170
1171
1172 /* SAMR_Q_QUERY_ALIASMEM - query alias members */
1173 typedef struct q_samr_query_aliasmem_info
1174 {
1175         POLICY_HND alias_pol;        /* policy handle */
1176
1177 } SAMR_Q_QUERY_ALIASMEM;
1178
1179
1180 /* SAMR_R_QUERY_ALIASMEM - query alias members */
1181 typedef struct r_samr_query_aliasmem_info
1182 {
1183         uint32 num_sids;
1184         uint32 ptr;
1185         uint32 num_sids1;
1186
1187         DOM_SID2 *sid;
1188
1189         uint32 status;
1190
1191 } SAMR_R_QUERY_ALIASMEM;
1192
1193
1194 /* SAMR_Q_UNK_ALIASMEM - don't know! */
1195 typedef struct q_samr_unk_alias_mem_info
1196 {
1197         POLICY_HND alias_pol;       /* policy handle */
1198
1199         DOM_SID sid; /* member sid to be "something"ed to do with the alias */
1200
1201 } SAMR_Q_UNK_ALIASMEM;
1202
1203
1204 /* SAMR_R_UNK_ALIASMEM - probably an open */
1205 typedef struct r_samr_unk_alias_mem_info
1206 {
1207         uint32 status;         /* return status */
1208
1209 } SAMR_R_UNK_ALIASMEM;
1210
1211
1212 /* SAMR_Q_ADD_ALIASMEM - probably an add member */
1213 typedef struct q_samr_add_alias_mem_info
1214 {
1215         POLICY_HND alias_pol;       /* policy handle */
1216
1217         DOM_SID2 sid; /* member sid to be added to alias */
1218
1219 } SAMR_Q_ADD_ALIASMEM;
1220
1221
1222 /* SAMR_R_ADD_ALIASMEM - probably an open */
1223 typedef struct r_samr_add_alias_mem_info
1224 {
1225         uint32 status;         /* return status */
1226
1227 } SAMR_R_ADD_ALIASMEM;
1228
1229
1230
1231 /* SAMR_Q_OPEN_ALIAS - probably an open */
1232 typedef struct q_samr_open_alias_info
1233 {
1234         POLICY_HND dom_pol;
1235
1236         uint32 unknown_0;         /* 0x0000 0008 */
1237         uint32 rid_alias;        /* rid */
1238
1239 } SAMR_Q_OPEN_ALIAS;
1240
1241
1242 /* SAMR_R_OPEN_ALIAS - probably an open */
1243 typedef struct r_samr_open_alias_info
1244 {
1245         POLICY_HND pol;       /* policy handle */
1246         uint32 status;         /* return status */
1247
1248 } SAMR_R_OPEN_ALIAS;
1249
1250
1251 /* SAMR_Q_CONNECT_ANON - probably an open */
1252 typedef struct q_samr_connect_anon_info
1253 {
1254         uint32 ptr;                  /* ptr? */
1255         uint16 unknown_0;            /* 0x005c */
1256         uint16 unknown_1;            /* 0x0001 */
1257         uint32 unknown_2;            /* 0x0000 0020 */
1258
1259 } SAMR_Q_CONNECT_ANON;
1260
1261 /* SAMR_R_CONNECT_ANON - probably an open */
1262 typedef struct r_samr_connect_anon_info
1263 {
1264         POLICY_HND connect_pol;       /* policy handle */
1265         uint32 status;         /* return status */
1266
1267 } SAMR_R_CONNECT_ANON;
1268
1269 /* SAMR_Q_CONNECT - probably an open */
1270 typedef struct q_samr_connect_info
1271 {
1272         uint32 ptr_srv_name;         /* pointer (to server name?) */
1273         UNISTR2 uni_srv_name;        /* unicode server name starting with '\\' */
1274
1275         uint32 unknown_0;            /* 32 bit unknown */
1276
1277 } SAMR_Q_CONNECT;
1278
1279
1280 /* SAMR_R_CONNECT - probably an open */
1281 typedef struct r_samr_connect_info
1282 {
1283     POLICY_HND connect_pol;       /* policy handle */
1284         uint32 status;         /* return status */
1285
1286 } SAMR_R_CONNECT;
1287
1288 /* SAMR_Q_UNKNOWN_38 */
1289 typedef struct q_samr_unknown_38
1290 {
1291         uint32 ptr; 
1292         UNIHDR  hdr_srv_name;
1293         UNISTR2 uni_srv_name;
1294
1295 } SAMR_Q_UNKNOWN_38;
1296
1297 /* SAMR_R_UNKNOWN_38 */
1298 typedef struct r_samr_unknown_38
1299 {
1300         uint16 unk_0;
1301         uint16 unk_1;
1302         uint16 unk_2;
1303         uint16 unk_3;
1304
1305 } SAMR_R_UNKNOWN_38;
1306
1307 /* SAMR_ENC_PASSWD */
1308 typedef struct enc_passwd_info
1309 {
1310         uint32 ptr;
1311         uint8 pass[516];
1312
1313 } SAMR_ENC_PASSWD;
1314
1315 /* SAMR_ENC_HASH */
1316 typedef struct enc_hash_info
1317 {
1318         uint32 ptr;
1319         uint8 hash[16];
1320
1321 } SAMR_ENC_HASH;
1322
1323 /* SAMR_Q_CHGPASSWD_USER */
1324 typedef struct q_samr_chgpasswd_user_info
1325 {
1326         uint32 ptr_0;
1327
1328         UNIHDR hdr_dest_host; /* server name unicode header */
1329         UNISTR2 uni_dest_host; /* server name unicode string */
1330
1331         UNIHDR hdr_user_name;    /* username unicode string header */
1332         UNISTR2 uni_user_name;    /* username unicode string */
1333
1334         SAMR_ENC_PASSWD nt_newpass;
1335         SAMR_ENC_HASH nt_oldhash;
1336
1337         uint32 unknown; /* 0x0000 0001 */
1338
1339         SAMR_ENC_PASSWD lm_newpass;
1340         SAMR_ENC_HASH lm_oldhash;
1341
1342 } SAMR_Q_CHGPASSWD_USER;
1343
1344 /* SAMR_R_CHGPASSWD_USER */
1345 typedef struct r_samr_chgpasswd_user_info
1346 {
1347         uint32 status; /* 0 == OK, C000006A (NT_STATUS_WRONG_PASSWORD) */
1348
1349 } SAMR_R_CHGPASSWD_USER;
1350
1351 #endif /* _RPC_SAMR_H */
1352