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