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