r2458: Rename policy handle parameters for the SAMR pipe. Parameters now
[jelmer/samba4-debian.git] / source / librpc / idl / samr.idl
1 #include "idl_types.h"
2
3 /*
4   samr interface definition
5 */
6
7 /*
8   Thanks to Todd Sabin for some information from his samr.idl in acltools
9 */
10
11 [ uuid(12345778-1234-abcd-ef00-0123456789ac),
12   version(1.0),
13   endpoints(samr,TCP-0),
14   pointer_default(unique)
15 ] interface samr
16 {
17         /* account control (acct_flags) bits */
18         const int ACB_DISABLED  = 0x0001;  /* 1 = User account disabled */
19         const int ACB_HOMDIRREQ = 0x0002;  /* 1 = Home directory required */
20         const int ACB_PWNOTREQ  = 0x0004;  /* 1 = User password not required */
21         const int ACB_TEMPDUP   = 0x0008;  /* 1 = Temporary duplicate account */
22         const int ACB_NORMAL    = 0x0010;  /* 1 = Normal user account */
23         const int ACB_MNS       = 0x0020;  /* 1 = MNS logon user account */
24         const int ACB_DOMTRUST  = 0x0040;  /* 1 = Interdomain trust account */
25         const int ACB_WSTRUST   = 0x0080;  /* 1 = Workstation trust account */
26         const int ACB_SVRTRUST  = 0x0100;  /* 1 = Server trust account */
27         const int ACB_PWNOEXP   = 0x0200;  /* 1 = User password does not expire */
28         const int ACB_AUTOLOCK  = 0x0400;  /* 1 = Account auto locked */
29
30
31         /******************/
32         /* Function: 0x00 */
33         NTSTATUS samr_Connect (
34                 /* notice the lack of [string] */
35                 [in]       uint16 *system_name,
36                 [in]       uint32 access_mask,
37                 [out,ref]  policy_handle *connect_handle
38                 );
39
40
41         /******************/
42         /* Function: 0x01 */
43         NTSTATUS samr_Close (
44                 [in,out,ref]  policy_handle *handle
45                 );
46
47         /******************/
48         /* Function: 0x02 */
49
50         typedef struct {
51                 [value(ndr_size_security_descriptor(r->sd))] uint32 sd_size;
52                 [subcontext(4)] security_descriptor *sd;
53         } samr_SdBuf;
54
55         NTSTATUS samr_SetSecurity (
56                 [in,ref]          policy_handle *handle,
57                 [in]              uint32 sec_info,
58                 [in,ref]          samr_SdBuf *sdbuf
59                 );
60
61         /******************/
62         /* Function: 0x03 */
63
64         NTSTATUS samr_QuerySecurity (
65                 [in,ref]          policy_handle *handle,
66                 [in]              uint32 sec_info,
67                 [out]             samr_SdBuf *sdbuf
68                 );
69
70         /******************/
71         /* Function: 0x04 */
72
73         /*
74           shutdown the SAM - once you call this the SAM will be dead
75         */
76         NTSTATUS samr_Shutdown (
77                 [in,ref]   policy_handle *connect_handle
78                 );
79
80         /******************/
81         /* Function: 0x05 */
82         typedef struct {
83                 [value(2*strlen_m(r->name))] uint16 name_len;
84                 [value(r->name_len)] uint16 name_size;
85                 unistr_noterm *name;
86         } samr_Name;    
87
88         NTSTATUS samr_LookupDomain (
89                 [in,ref]  policy_handle *connect_handle,                
90                 [in,ref]  samr_Name *domain,
91                 [out]     dom_sid2 *sid
92                 );
93
94
95         /******************/
96         /* Function: 0x06 */
97
98         typedef struct {
99                 uint32 idx;
100                 samr_Name name;
101         } samr_SamEntry;
102
103         typedef struct {
104                 uint32 count;
105                 [size_is(count)] samr_SamEntry *entries;
106         } samr_SamArray;
107
108         NTSTATUS samr_EnumDomains (
109                 [in,ref]      policy_handle *connect_handle,
110                 [in,out,ref]  uint32 *resume_handle,
111                 [in]          uint32 buf_size,
112                 [out]         samr_SamArray *sam,
113                 [out]         uint32 num_entries
114                 );
115
116
117         /************************/
118         /* Function    0x07     */
119         NTSTATUS samr_OpenDomain(
120                 [in,ref]      policy_handle *connect_handle,
121                 [in]          uint32 access_mask,
122                 [in,ref]      dom_sid2 *sid,
123                 [out,ref]     policy_handle *domain_handle
124                 );
125
126         /************************/
127         /* Function    0x08     */
128
129         /* server roles */
130         typedef enum {
131                 ROLE_STANDALONE    = 0,
132                 ROLE_DOMAIN_MEMBER = 1,
133                 ROLE_DOMAIN_BDC    = 2,
134                 ROLE_DOMAIN_PDC    = 3
135         } samr_Role;
136
137         typedef struct {
138                 uint16 min_password_len;
139                 uint16 password_history;
140                 uint32 password_properties;
141                 /* yes, these are signed. They are in negative 100ns */
142                 int64  max_password_age;
143                 int64  min_password_age;
144         } samr_DomInfo1;
145
146         typedef struct {
147                 uint64 force_logoff_time;
148                 samr_Name comment;
149                 samr_Name domain;  /* domain name */
150                 samr_Name primary; /* PDC name if this is a BDC */
151                 HYPER_T sequence_num;
152                 uint32 unknown2;
153                 uint32 role;
154                 uint32 unknown3;
155                 uint32 num_users;
156                 uint32 num_groups;
157                 uint32 num_aliases;
158         } samr_DomInfo2;
159
160         typedef struct {
161                 uint64 force_logoff_time;
162         } samr_DomInfo3;
163
164         typedef struct {
165                 /* I'm not entirely sure this is a comment. win2003
166                    allows it to be set, and it seems harmless (like a
167                    comment) but I haven't seen it show up anywhere */
168                 samr_Name comment;
169         } samr_DomInfo4;
170
171         typedef struct {
172                 samr_Name domain;
173         } samr_DomInfo5;
174
175         typedef struct {
176                 samr_Name primary;
177         } samr_DomInfo6;
178
179         typedef struct {
180                 uint32 role;
181         } samr_DomInfo7;
182
183         typedef struct {
184                 HYPER_T sequence_num;
185                 NTTIME last_xxx_time;
186         } samr_DomInfo8;
187
188         typedef struct {
189                 uint32 unknown; /* w2k3 returns 1 */
190         } samr_DomInfo9;
191
192         typedef struct {
193                 uint64 force_logoff_time;
194                 samr_Name comment;
195                 samr_Name domain;
196                 samr_Name primary;
197                 HYPER_T sequence_num;
198                 uint32 unknown2;  /* w2k3 returns 1 */
199                 uint32 role;
200                 uint32 unknown3;  /* w2k3 returns 1 */
201                 uint32 num_users;
202                 uint32 num_groups;
203                 uint32 num_aliases;
204                 HYPER_T lockout_duration;
205                 HYPER_T lockout_window;
206                 uint16 lockout_threshold;
207         } samr_DomInfo11;
208
209         typedef struct {
210                 HYPER_T lockout_duration;
211                 HYPER_T lockout_window;
212                 uint16 lockout_threshold;
213         } samr_DomInfo12;
214
215         typedef struct {
216                 HYPER_T sequence_num;
217                 NTTIME last_xxx_time;
218                 uint32 unknown1;
219                 uint32 unknown2;
220         } samr_DomInfo13;
221
222         typedef union {
223                 [case(1)] samr_DomInfo1 info1;
224                 [case(2)] samr_DomInfo2 info2;
225                 [case(3)] samr_DomInfo3 info3;
226                 [case(4)] samr_DomInfo4 info4;
227                 [case(5)] samr_DomInfo5 info5;
228                 [case(6)] samr_DomInfo6 info6;
229                 [case(7)] samr_DomInfo7 info7;
230                 [case(8)] samr_DomInfo8 info8;
231                 [case(9)] samr_DomInfo9 info9;
232                 [case(11)] samr_DomInfo11 info11;
233                 [case(12)] samr_DomInfo12 info12;
234                 [case(13)] samr_DomInfo13 info13;
235         } samr_DomainInfo;
236
237         NTSTATUS samr_QueryDomainInfo(
238                 [in,ref]      policy_handle *domain_handle,
239                 [in]          uint16 level,
240                 [out,switch_is(level)] samr_DomainInfo *info
241                 );
242
243         /************************/
244         /* Function    0x09     */
245         /*
246           only levels 1, 3, 4, 6, 7, 9, 12 are valid for this 
247           call in w2k3
248         */
249         NTSTATUS samr_SetDomainInfo(
250                 [in,ref]      policy_handle *domain_handle,
251                 [in]          uint16 level,
252                 [in,switch_is(level),ref] samr_DomainInfo *info
253                 );
254
255
256         /************************/
257         /* Function    0x0a     */
258         NTSTATUS samr_CreateDomainGroup(
259                 [in,ref]      policy_handle *domain_handle,
260                 [in,ref]      samr_Name *name,
261                 [in]          uint32 access_mask,
262                 [out,ref]     policy_handle *group_handle,
263                 [out,ref]     uint32 *rid
264                 );
265                 
266
267         /************************/
268         /* Function    0x0b     */
269         NTSTATUS samr_EnumDomainGroups(
270                 [in,ref]      policy_handle *domain_handle,
271                 [in,out,ref]  uint32 *resume_handle,
272                 [in]          uint32 max_size,
273                 [out]         samr_SamArray *sam,
274                 [out]         uint32 num_entries
275                 );
276
277         /************************/
278         /* Function    0x0c     */
279         NTSTATUS samr_CreateUser(
280                 [in,ref]      policy_handle *domain_handle,
281                 [in,ref]      samr_Name *account_name,
282                 [in]          uint32 access_mask,
283                 [out,ref]     policy_handle *user_handle,
284                 [out,ref]     uint32 *rid
285                 );
286
287         /************************/
288         /* Function    0x0d     */
289
290
291         /* w2k3 treats max_size as max_users*54 and sets the
292            resume_handle as the rid of the last user sent
293         */
294         const int SAMR_ENUM_USERS_MULTIPLIER = 54;
295
296         NTSTATUS samr_EnumDomainUsers(
297                 [in,ref]      policy_handle *domain_handle,
298                 [in,out,ref]  uint32 *resume_handle,
299                 [in]          uint32 acct_flags,
300                 [in]          uint32 max_size,
301                 [out]         samr_SamArray *sam,
302                 [out]         uint32 num_entries
303                 );
304
305         /************************/
306         /* Function    0x0e     */
307         NTSTATUS samr_CreateDomAlias(
308                 [in,ref]      policy_handle *domain_handle,
309                 [in,ref]      samr_Name     *aliasname,
310                 [in]          uint32         access_mask,
311                 [out,ref]     policy_handle *alias_handle,
312                 [out,ref]     uint32        *rid
313                 );
314
315         /************************/
316         /* Function    0x0f     */
317         NTSTATUS samr_EnumDomainAliases(
318                 [in,ref]      policy_handle *domain_handle,
319                 [in,out,ref]  uint32 *resume_handle,
320                 [in]          uint32 account_flags,
321                 [out]         samr_SamArray *sam,
322                 [out]         uint32 num_entries
323                 );
324
325         /************************/
326         /* Function    0x10     */
327
328         typedef enum {
329                 SID_NAME_USE_NONE = 0,/* NOTUSED */
330                 SID_NAME_USER    = 1, /* user */
331                 SID_NAME_DOM_GRP = 2, /* domain group */
332                 SID_NAME_DOMAIN  = 3, /* domain: don't know what this is */
333                 SID_NAME_ALIAS   = 4, /* local group */
334                 SID_NAME_WKN_GRP = 5, /* well-known group */
335                 SID_NAME_DELETED = 6, /* deleted account: needed for c2 rating */
336                 SID_NAME_INVALID = 7, /* invalid account */
337                 SID_NAME_UNKNOWN = 8  /* oops. */
338         } samr_SidType;
339
340         typedef struct {
341                 uint32 count;
342                 [size_is(count)] uint32 *ids;
343         } samr_Ids;
344
345         NTSTATUS samr_GetAliasMembership(
346                 [in,ref]      policy_handle *alias_handle,
347                 [in,ref]      lsa_SidArray  *sids,
348                 [out]         samr_Ids *rids
349                 );
350
351         /************************/
352         /* Function    0x11     */
353
354         NTSTATUS samr_LookupNames(
355                 [in,ref]      policy_handle *domain_handle,
356                 [in]          uint32 num_names,
357                 [in,ref,size_is(1000),length_is(num_names)] samr_Name *names,
358                 [out]         samr_Ids rids,
359                 [out]         samr_Ids types
360                 );
361
362
363         /************************/
364         /* Function    0x12     */
365
366         typedef struct {
367                 uint32 count;
368                 [size_is(count)] samr_Name *names;
369         } samr_Names;
370
371         NTSTATUS samr_LookupRids(
372                 [in,ref]      policy_handle *domain_handle,
373                 [in]          uint32 num_rids,
374                 [in,ref,size_is(1000),length_is(num_rids)] uint32 *rids,
375                 [out]         samr_Names names,
376                 [out]         samr_Ids types
377                 );
378
379         /************************/
380         /* Function    0x13     */
381         NTSTATUS samr_OpenGroup(
382                 [in,ref]      policy_handle *domain_handle,
383                 [in]          uint32 access_mask,
384                 [in]          uint32 rid,
385                 [out,ref]     policy_handle *group_handle
386                 );
387
388
389         /************************/
390         /* Function    0x14     */
391
392         typedef struct {
393                 samr_Name name;
394                 uint32 unknown;
395                 uint32 num_members;
396                 samr_Name description;
397         } samr_GroupInfoAll;
398
399         typedef struct {
400                 uint32 unknown;
401         } samr_GroupInfoX;
402
403         typedef struct {
404                 samr_Name description;
405         } samr_GroupInfoDesciption;
406
407         typedef enum {
408                 GroupInfoAll = 1,
409                 GroupInfoName,
410                 GroupInfoX,
411                 GroupInfoDescription
412         } GroupInfo;
413
414         typedef union {
415                 [case(GroupInfoAll)]         samr_GroupInfoAll    all;
416                 [case(GroupInfoName)]        samr_Name            name;
417                 [case(GroupInfoX)]           samr_GroupInfoX      unknown;
418                 [case(GroupInfoDescription)] samr_Name            description;
419         } samr_GroupInfo;
420
421         NTSTATUS samr_QueryGroupInfo(
422                 [in,ref]                  policy_handle *group_handle,
423                 [in]                      uint16 level,
424                 [out,switch_is(level)]    samr_GroupInfo *info
425                 );
426
427         /************************/
428         /* Function    0x15     */
429         NTSTATUS samr_SetGroupInfo(
430                 [in,ref]                  policy_handle *group_handle,
431                 [in]                      uint16 level,
432                 [in,switch_is(level),ref] samr_GroupInfo *info
433                 );
434
435         /************************/
436         /* Function    0x16     */
437         NTSTATUS samr_AddGroupMember(
438                 [in,ref]                  policy_handle *group_handle,
439                 [in]                      uint32 rid,
440                 [in]                      uint32 flags
441                 );
442
443         /************************/
444         /* Function    0x17     */
445         NTSTATUS samr_DeleteDomainGroup(
446                 [in,out,ref]   policy_handle *group_handle
447                 );
448
449         /************************/
450         /* Function    0x18     */
451         NTSTATUS samr_DeleteGroupMember(
452                 [in,ref]                  policy_handle *group_handle,
453                 [in]                      uint32 rid
454                 );
455
456
457         /************************/
458         /* Function    0x19     */
459         /*
460           this isn't really valid IDL, but it does work. I suspect
461           I need to do some more pidl work to get this really right
462         */
463         typedef struct {
464                 uint32 count;
465                 uint32 v[count];
466         } samr_intArray;
467
468         typedef struct {
469                 samr_intArray *rids;
470                 samr_intArray *unknown7;
471         } samr_ridArray;
472
473         NTSTATUS samr_QueryGroupMember(
474                 [in,ref]  policy_handle *group_handle,
475                 [out]     uint32 *count,
476                 [out]     samr_ridArray rids
477                 );
478
479
480         /************************/
481         /* Function    0x1a     */
482
483         /*
484           win2003 seems to accept any data at all for the two integers
485           below, and doesn't seem to do anything with them that I can
486           see. Weird. I really expected the first integer to be a rid
487           and the second to be the attributes for that rid member.
488         */
489         NTSTATUS samr_SetMemberAttributesOfGroup(
490                 [in,ref]  policy_handle *group_handle,
491                 [in]      uint32 unknown1,
492                 [in]      uint32 unknown2
493                 );
494
495
496         /************************/
497         /* Function    0x1b     */
498         NTSTATUS samr_OpenAlias (
499                 [in,ref]      policy_handle *domain_handle,
500                 [in]          uint32 access_mask,
501                 [in]          uint32 rid,
502                 [out,ref]     policy_handle *alias_handle
503                 );
504
505
506         /************************/
507         /* Function    0x1c     */
508
509         typedef struct {
510                 samr_Name name;
511                 uint32 num_members;
512                 samr_Name description;
513         } samr_AliasInfoAll;
514
515         typedef union {
516                 [case(1)] samr_AliasInfoAll all;
517                 [case(2)] samr_Name name;
518                 [case(3)] samr_Name description;
519         } samr_AliasInfo;
520
521         NTSTATUS samr_QueryAliasInfo(
522                 [in,ref]                  policy_handle *alias_handle,
523                 [in]                      uint16 level,
524                 [out,switch_is(level)]    samr_AliasInfo *info
525                 );
526
527         /************************/
528         /* Function    0x1d     */
529         NTSTATUS samr_SetAliasInfo(
530                 [in,ref]                  policy_handle  *alias_handle,
531                 [in]                      uint16          level,
532                 [in,switch_is(level)]     samr_AliasInfo  info
533                 );
534
535         /************************/
536         /* Function    0x1e     */
537         NTSTATUS samr_DeleteDomAlias(
538                 [in,out,ref]  policy_handle *alias_handle
539                 );
540
541         /************************/
542         /* Function    0x1f     */
543         NTSTATUS samr_AddAliasMember(
544                 [in,ref]  policy_handle *alias_handle,
545                 [in,ref]  dom_sid2      *sid
546                 );
547
548         /************************/
549         /* Function    0x20     */
550         NTSTATUS samr_DeleteAliasMember(
551                 [in,ref] policy_handle *alias_handle,
552                 [in,ref] dom_sid2      *sid
553                 );
554
555         /************************/
556         /* Function    0x21     */
557         NTSTATUS samr_GetMembersInAlias(
558                 [in,ref]   policy_handle *alias_handle,
559                 [out,ref]  lsa_SidArray    *sids
560                 );
561
562         /************************/
563         /* Function    0x22     */
564         NTSTATUS samr_OpenUser(
565                 [in,ref]      policy_handle *domain_handle,
566                 [in]          uint32 access_mask,
567                 [in]          uint32 rid,
568                 [out,ref]     policy_handle *user_handle
569                 );
570
571         /************************/
572         /* Function    0x23     */
573         NTSTATUS samr_DeleteUser(
574                 [in,out,ref]   policy_handle *user_handle
575                 );
576
577         /************************/
578         /* Function    0x24     */
579         typedef struct {
580                 samr_Name account_name;
581                 samr_Name full_name;
582                 uint32 primary_gid;
583                 samr_Name description;
584                 samr_Name comment;
585         } samr_UserInfo1;
586
587         typedef struct {
588                 samr_Name comment;
589                 samr_Name unknown; /* settable, but doesn't stick. probably obsolete */
590                 uint16 country_code;
591                 uint16 code_page;
592         } samr_UserInfo2;
593
594         typedef struct {
595                 samr_Name account_name;
596                 samr_Name full_name;
597                 uint32 rid;
598                 uint32 primary_gid;
599                 samr_Name home_directory;
600                 samr_Name home_drive;
601                 samr_Name logon_script;
602                 samr_Name profile_path;
603                 samr_Name workstations;
604                 NTTIME last_logon;
605                 NTTIME last_logoff;
606                 NTTIME last_password_change;
607                 NTTIME allow_password_change;
608                 NTTIME force_password_change;
609                 samr_LogonHours logon_hours;
610                 uint16 bad_password_count;
611                 uint16 num_logons;
612                 uint32 acct_flags;
613         } samr_UserInfo3;
614
615         typedef struct {
616                 samr_LogonHours logon_hours;
617         } samr_UserInfo4;
618
619         typedef struct {
620                 samr_Name account_name;
621                 samr_Name full_name;
622                 uint32 rid;
623                 uint32 primary_gid;
624                 samr_Name home_directory;
625                 samr_Name home_drive;
626                 samr_Name logon_script;
627                 samr_Name profile_path;
628                 samr_Name description;
629                 samr_Name workstations;
630                 NTTIME last_logon;
631                 NTTIME last_logoff;
632                 samr_LogonHours logon_hours;
633                 uint16 bad_password_count;
634                 uint16 num_logons;
635                 NTTIME last_password_change;
636                 NTTIME acct_expiry;
637                 uint32 acct_flags;
638         } samr_UserInfo5;
639
640         typedef struct {
641                 samr_Name account_name;
642                 samr_Name full_name;
643         } samr_UserInfo6;
644
645         typedef struct {
646                 samr_Name account_name;
647         } samr_UserInfo7;
648
649         typedef struct {
650                 samr_Name full_name;
651         } samr_UserInfo8;
652
653         typedef struct {
654                 uint32 primary_gid;
655         } samr_UserInfo9;
656
657         typedef struct {
658                 samr_Name home_directory;
659                 samr_Name home_drive;
660         } samr_UserInfo10;
661
662         typedef struct {
663                 samr_Name logon_script;
664         } samr_UserInfo11;
665
666         typedef struct {
667                 samr_Name profile_path;
668         } samr_UserInfo12;
669
670         typedef struct {
671                 samr_Name description;
672         } samr_UserInfo13;
673
674         typedef struct {
675                 samr_Name workstations;
676         } samr_UserInfo14;
677
678         typedef struct {
679                 uint32 acct_flags;
680         } samr_UserInfo16;
681         
682         typedef struct {
683                 NTTIME acct_expiry;
684         } samr_UserInfo17;
685
686         typedef struct {
687                 samr_Name callback;
688         } samr_UserInfo20;
689
690         /* this defines the bits used for fields_present in info21 */
691         const int SAMR_FIELD_NAME         = 0x00000002;
692         const int SAMR_FIELD_DESCRIPTION  = 0x00000010;
693         const int SAMR_FIELD_COMMENT      = 0x00000020;
694         const int SAMR_FIELD_LOGON_SCRIPT = 0x00000100;
695         const int SAMR_FIELD_PROFILE_PATH = 0x00000200;
696         const int SAMR_FIELD_WORKSTATION  = 0x00000400;
697         const int SAMR_FIELD_LOGON_HOURS  = 0x00002000;
698         const int SAMR_FIELD_CALLBACK     = 0x00200000;
699         const int SAMR_FIELD_COUNTRY_CODE = 0x00400000;
700         const int SAMR_FIELD_CODE_PAGE    = 0x00800000;
701         const int SAMR_FIELD_PASSWORD     = 0x03000000; /* 2 bits!? */
702
703         typedef struct {
704                 NTTIME last_logon;
705                 NTTIME last_logoff;
706                 NTTIME last_password_change;
707                 NTTIME acct_expiry;
708                 NTTIME allow_password_change;
709                 NTTIME force_password_change;
710                 samr_Name account_name;
711                 samr_Name full_name;
712                 samr_Name home_directory;
713                 samr_Name home_drive;
714                 samr_Name logon_script;
715                 samr_Name profile_path;
716                 samr_Name description;
717                 samr_Name workstations;
718                 samr_Name comment;
719                 samr_Name callback;
720                 samr_Name unknown1;
721                 samr_Name unknown2;
722                 samr_Name unknown3;
723                 uint32 buf_count;
724                 [size_is(buf_count)] uint8 *buffer;
725                 uint32 rid;
726                 uint32 primary_gid;
727                 uint32 acct_flags;
728                 uint32 fields_present;
729                 samr_LogonHours logon_hours;
730                 uint16 bad_password_count;
731                 uint16 num_logons;
732                 uint16 country_code;
733                 uint16 code_page;
734                 uint8  nt_password_set;
735                 uint8  lm_password_set;
736                 uint8  expired_flag;
737                 uint8  unknown4;
738         } samr_UserInfo21;
739
740         typedef [flag(NDR_PAHEX)] struct {
741                 uint8 data[516];
742         } samr_CryptPassword;
743
744         typedef struct {
745                 samr_UserInfo21 info;
746                 samr_CryptPassword password;
747         } samr_UserInfo23;
748
749         typedef struct {
750                 samr_CryptPassword password;
751                 uint16 pw_len;
752         } samr_UserInfo24;
753
754         typedef [flag(NDR_PAHEX)] struct {
755                 uint8 data[532];
756         } samr_CryptPasswordEx;
757
758         typedef struct {
759                 samr_UserInfo21 info;
760                 samr_CryptPasswordEx password;
761         } samr_UserInfo25;
762
763         typedef struct {
764                 samr_CryptPasswordEx password;
765                 uint8 pw_len;
766         } samr_UserInfo26;
767
768         typedef union {
769                 [case(1)] samr_UserInfo1 info1;
770                 [case(2)] samr_UserInfo2 info2;
771                 [case(3)] samr_UserInfo3 info3;
772                 [case(4)] samr_UserInfo4 info4;
773                 [case(5)] samr_UserInfo5 info5;
774                 [case(6)] samr_UserInfo6 info6;
775                 [case(7)] samr_UserInfo7 info7;
776                 [case(8)] samr_UserInfo8 info8;
777                 [case(9)] samr_UserInfo9 info9;
778                 [case(10)] samr_UserInfo10 info10;
779                 [case(11)] samr_UserInfo11 info11;
780                 [case(12)] samr_UserInfo12 info12;
781                 [case(13)] samr_UserInfo13 info13;
782                 [case(14)] samr_UserInfo14 info14;
783                 [case(16)] samr_UserInfo16 info16;
784                 [case(17)] samr_UserInfo17 info17;
785                 [case(20)] samr_UserInfo20 info20;
786                 [case(21)] samr_UserInfo21 info21;
787                 [case(23)] samr_UserInfo23 info23;
788                 [case(24)] samr_UserInfo24 info24;
789                 [case(25)] samr_UserInfo25 info25;
790                 [case(26)] samr_UserInfo26 info26;
791         } samr_UserInfo;
792
793         NTSTATUS samr_QueryUserInfo(
794                 [in,ref]                  policy_handle *user_handle,
795                 [in]                      uint16 level,
796                 [out,switch_is(level)]    samr_UserInfo *info
797                 );
798
799
800         /************************/
801         /* Function    0x25     */
802         NTSTATUS samr_SetUserInfo(
803                 [in,ref]                   policy_handle *user_handle,
804                 [in]                       uint16 level,
805                 [in,ref,switch_is(level)]  samr_UserInfo *info
806                 );
807
808         /************************/
809         /* Function    0x26     */
810         
811         /*
812           this is a password change interface that doesn't give
813           the server the plaintext password. Depricated.
814         */
815         NTSTATUS samr_ChangePasswordUser(
816                 [in,ref]    policy_handle *user_handle,
817                 [in]        bool8 lm_present,
818                 [in]        samr_Password *old_lm_crypted,
819                 [in]        samr_Password *new_lm_crypted,
820                 [in]        bool8 nt_present,
821                 [in]        samr_Password *old_nt_crypted,
822                 [in]        samr_Password *new_nt_crypted,
823                 [in]        bool8 cross1_present,
824                 [in]        samr_Password *nt_cross,
825                 [in]        bool8 cross2_present,
826                 [in]        samr_Password *lm_cross
827                 );
828
829         /************************/
830         /* Function    0x27     */
831
832         typedef struct {
833                 uint32 rid;
834                 uint32 type;
835         } samr_RidType;
836
837         typedef struct {
838                 uint32     count;
839                 [size_is(count)] samr_RidType *rid;
840         } samr_RidArray;
841
842         NTSTATUS samr_GetGroupsForUser(
843                 [in,ref]   policy_handle *user_handle,
844                 [out]      samr_RidArray  *rids
845                 );
846
847         /************************/
848         /* Function    0x28     */
849
850         typedef struct {
851                 uint32    idx;
852                 uint32    rid;
853                 uint32    acct_flags;
854                 samr_Name account_name;
855                 samr_Name full_name;
856                 samr_Name description;
857         } samr_DispEntryGeneral;
858
859         typedef struct {
860                 uint32 count;
861                 [size_is(count)] samr_DispEntryGeneral *entries;
862         } samr_DispInfoGeneral;
863
864         typedef struct {
865                 uint32    idx;
866                 uint32    rid;
867                 uint32    acct_flags;
868                 samr_Name account_name;
869                 samr_Name description;
870         } samr_DispEntryFull;
871
872         typedef struct {
873                 uint32 count;
874                 [size_is(count)] samr_DispEntryFull *entries;
875         } samr_DispInfoFull;
876
877         typedef struct {
878                 [value(strlen_m(r->name))] uint16 name_len;
879                 [value(strlen_m(r->name))] uint16 name_size;
880                 ascstr_noterm *name;
881         } samr_AsciiName;       
882
883         typedef struct {
884                 uint32    idx;
885                 samr_AsciiName account_name;
886         } samr_DispEntryAscii;
887
888         typedef struct {
889                 uint32 count;
890                 [size_is(count)] samr_DispEntryAscii *entries;
891         } samr_DispInfoAscii;
892
893         typedef union {
894                 [case(1)] samr_DispInfoGeneral info1;/* users */
895                 [case(2)] samr_DispInfoFull info2; /* trust accounts? */
896                 [case(3)] samr_DispInfoFull info3; /* groups */
897                 [case(4)] samr_DispInfoAscii info4; /* users */
898                 [case(5)] samr_DispInfoAscii info5; /* groups */
899         } samr_DispInfo;
900
901         NTSTATUS samr_QueryDisplayInfo(
902                 [in,ref]    policy_handle *domain_handle,
903                 [in]        uint16 level,
904                 [in]        uint32 start_idx,
905                 [in]        uint32 max_entries,
906                 [in]        uint32 buf_size,
907                 [out]       uint32 total_size,
908                 [out]       uint32 returned_size,
909                 [out,switch_is(level)] samr_DispInfo info
910                 );
911
912
913         /************************/
914         /* Function    0x29     */
915
916         /*
917           this seems to be an alphabetic search function. The returned index
918           is the index for samr_QueryDisplayInfo needed to get names occurring
919           after the specified name. The supplied name does not need to exist
920           in the database (for example you can supply just a first letter for 
921           searching starting at that letter)
922
923           The level corresponds to the samr_QueryDisplayInfo level
924         */
925         NTSTATUS samr_GetDisplayEnumerationIndex(
926                 [in,ref]    policy_handle *domain_handle,
927                 [in]        uint16 level,
928                 [in]        samr_Name name,
929                 [out]       uint32 idx
930                 );
931
932
933
934         /************************/
935         /* Function    0x2a     */
936
937         /*
938           w2k3 returns NT_STATUS_NOT_IMPLEMENTED for this
939         */
940         NTSTATUS samr_TestPrivateFunctionsDomain(
941                 [in,ref]    policy_handle *domain_handle
942                 );
943
944
945         /************************/
946         /* Function    0x2b     */
947
948         /*
949           w2k3 returns NT_STATUS_NOT_IMPLEMENTED for this
950         */
951         NTSTATUS samr_TestPrivateFunctionsUser(
952                 [in,ref]    policy_handle *user_handle
953                 );
954
955
956         /************************/
957         /* Function    0x2c     */
958
959         /* password properties flags */
960         const uint32 DOMAIN_PASSWORD_COMPLEX         = 0x00000001;
961         const uint32 DOMAIN_PASSWORD_NO_ANON_CHANGE  = 0x00000002;
962         const uint32 DOMAIN_PASSWORD_NO_CLEAR_CHANGE = 0x00000004;
963         const uint32 DOMAIN_PASSWORD_STORE_CLEARTEXT = 0x00000010;
964         const uint32 DOMAIN_REFUSE_PASSWORD_CHANGE   = 0x00000020;
965
966         typedef struct {
967                 uint16 min_password_len;
968                 uint32 password_properties;
969         } samr_PwInfo;
970
971         NTSTATUS samr_GetUserPwInfo(
972                 [in,ref]    policy_handle *user_handle,
973                 [out]       samr_PwInfo info
974                 );
975
976         /************************/
977         /* Function    0x2d     */
978         NTSTATUS samr_RemoveMemberFromForeignDomain(
979                 [in,ref]    policy_handle *domain_handle,
980                 [in,ref]    dom_sid2 *sid
981                 );
982
983         /************************/
984         /* Function    0x2e     */
985
986         /*
987           how is this different from QueryDomainInfo ??
988         */
989         NTSTATUS samr_QueryDomainInfo2(
990                 [in,ref]      policy_handle *domain_handle,
991                 [in]          uint16 level,
992                 [out,switch_is(level)] samr_DomainInfo *info
993                 );
994
995         /************************/
996         /* Function    0x2f     */
997
998         /*
999           how is this different from QueryUserInfo ??
1000         */
1001         NTSTATUS samr_QueryUserInfo2(
1002                 [in,ref]                  policy_handle *user_handle,
1003                 [in]                      uint16 level,
1004                 [out,switch_is(level)]    samr_UserInfo *info
1005                 );
1006
1007         /************************/
1008         /* Function    0x30     */
1009
1010         /*
1011           how is this different from QueryDisplayInfo??
1012         */
1013         NTSTATUS samr_QueryDisplayInfo2(
1014                 [in,ref]    policy_handle *domain_handle,
1015                 [in]        uint16 level,
1016                 [in]        uint32 start_idx,
1017                 [in]        uint32 max_entries,
1018                 [in]        uint32 buf_size,
1019                 [out]       uint32 total_size,
1020                 [out]       uint32 returned_size,
1021                 [out,switch_is(level)] samr_DispInfo info
1022                 );
1023
1024         /************************/
1025         /* Function    0x31     */
1026
1027         /*
1028           how is this different from GetDisplayEnumerationIndex ??
1029         */
1030         NTSTATUS samr_GetDisplayEnumerationIndex2(
1031                 [in,ref]    policy_handle *domain_handle,
1032                 [in]        uint16 level,
1033                 [in]        samr_Name name,
1034                 [out]       uint32 idx
1035                 );
1036
1037
1038         /************************/
1039         /* Function    0x32     */
1040         NTSTATUS samr_CreateUser2(
1041                 [in,ref]      policy_handle *domain_handle,
1042                 [in,ref]      samr_Name *account_name,
1043                 [in]          uint32 acct_flags,
1044                 [in]          uint32 access_mask,
1045                 [out,ref]     policy_handle *user_handle,
1046                 [out,ref]     uint32 *access_granted,
1047                 [out,ref]     uint32 *rid
1048                 );
1049
1050
1051         /************************/
1052         /* Function    0x33     */
1053
1054         /*
1055           another duplicate. There must be a reason ....
1056         */
1057         NTSTATUS samr_QueryDisplayInfo3(
1058                 [in,ref]    policy_handle *domain_handle,
1059                 [in]        uint16 level,
1060                 [in]        uint32 start_idx,
1061                 [in]        uint32 max_entries,
1062                 [in]        uint32 buf_size,
1063                 [out]       uint32 total_size,
1064                 [out]       uint32 returned_size,
1065                 [out,switch_is(level)] samr_DispInfo info
1066                 );
1067
1068         /************************/
1069         /* Function    0x34     */
1070         NTSTATUS samr_AddMultipleMembersToAlias(
1071                 [in,ref]    policy_handle *alias_handle,
1072                 [in,ref]    lsa_SidArray *sids
1073                 );
1074
1075         /************************/
1076         /* Function    0x35     */
1077         NTSTATUS samr_RemoveMultipleMembersFromAlias(
1078                 [in,ref]    policy_handle *alias_handle,
1079                 [in,ref]    lsa_SidArray *sids
1080                 );
1081
1082         /************************/
1083         /* Function    0x36     */
1084
1085         NTSTATUS samr_OemChangePasswordUser2(
1086                 [in]              samr_AsciiName *server,
1087                 [in,ref]          samr_AsciiName *account,
1088                 [in]              samr_CryptPassword *password,
1089                 [in]              samr_Password *hash
1090                 );
1091
1092         /************************/
1093         /* Function    0x37     */
1094         NTSTATUS samr_ChangePasswordUser2(
1095                 [in]              samr_Name *server,
1096                 [in,ref]          samr_Name *account,
1097                 [in]              samr_CryptPassword *nt_password,
1098                 [in]              samr_Password *nt_verifier,
1099                 [in]              bool8 lm_change,
1100                 [in]              samr_CryptPassword *lm_password,
1101                 [in]              samr_Password *lm_verifier
1102                 );
1103
1104         /************************/
1105         /* Function    0x38     */
1106         NTSTATUS samr_GetDomPwInfo(
1107                 [in]        samr_Name *name,
1108                 [out]       samr_PwInfo info
1109                 );
1110
1111         /************************/
1112         /* Function    0x39     */
1113         NTSTATUS samr_Connect2(
1114                 [in] unistr *system_name,
1115                 [in] uint32 access_mask,
1116                 [out,ref]  policy_handle *connect_handle
1117                 );
1118
1119         /************************/
1120         /* Function    0x3a     */
1121         /*
1122           seems to be an exact alias for samr_SetUserInfo() 
1123         */
1124         NTSTATUS samr_SetUserInfo2(
1125                 [in,ref]                   policy_handle *user_handle,
1126                 [in]                       uint16 level,
1127                 [in,ref,switch_is(level)]  samr_UserInfo *info
1128                 );
1129
1130         /************************/
1131         /* Function    0x3b     */
1132         /*
1133           this one is mysterious. I have a few guesses, but nothing working yet
1134         */
1135         NTSTATUS samr_SetBootKeyInformation(
1136                 [in,ref]   policy_handle *connect_handle,
1137                 [in]       uint32 unknown1,
1138                 [in]       uint32 unknown2,
1139                 [in]       uint32 unknown3
1140                 );
1141
1142         /************************/
1143         /* Function    0x3c     */
1144         NTSTATUS samr_GetBootKeyInformation(
1145                 [in,ref]   policy_handle *domain_handle,
1146                 [out]      uint32 unknown
1147                 );
1148
1149         /************************/
1150         /* Function    0x3d     */
1151         NTSTATUS samr_Connect3(
1152                 [in] unistr *system_name,
1153                 /* this unknown value seems to be completely ignored by w2k3 */
1154                 [in] uint32 unknown,
1155                 [in] uint32 access_mask,
1156                 [out,ref]  policy_handle *connect_handle
1157                 );
1158
1159         /************************/
1160         /* Function    0x3e     */
1161         NTSTATUS samr_Connect4(
1162                 [in] unistr *system_name,
1163                 [in] uint32 unknown,
1164                 [in] uint32 access_mask,
1165                 [out,ref]  policy_handle *connect_handle
1166                 );
1167
1168         /************************/
1169         /* Function    0x3f     */
1170
1171         const int SAMR_REJECT_OTHER      = 0;
1172         const int SAMR_REJECT_TOO_SHORT  = 1;
1173         const int SAMR_REJECT_COMPLEXITY = 2;
1174
1175         typedef struct {
1176                 uint32 reason;
1177                 uint32 unknown1;
1178                 uint32 unknown2;
1179         } samr_ChangeReject;
1180
1181         NTSTATUS samr_ChangePasswordUser3(
1182                 [in]              samr_Name *server,
1183                 [in,ref]          samr_Name *account,
1184                 [in]              samr_CryptPassword *nt_password,
1185                 [in]              samr_Password *nt_verifier,
1186                 [in]              bool8 lm_change,
1187                 [in]              samr_CryptPassword *lm_password,
1188                 [in]              samr_Password *lm_verifier,
1189                 [in]              samr_CryptPassword *password3,
1190                 [out]             samr_DomInfo1 *dominfo,
1191                 [out]             samr_ChangeReject *reject
1192                 );
1193
1194         /************************/
1195         /* Function    0x40      */
1196
1197         typedef struct {
1198                 uint32         unknown1; /* w2k3 gives 3 */
1199                 uint32         unknown2; /* w2k3 gives 0 */
1200         } samr_ConnectInfo1;
1201
1202         typedef union {
1203                 [case(1)]  samr_ConnectInfo1 info1;
1204         } samr_ConnectInfo;
1205
1206         NTSTATUS samr_Connect5(
1207                 [in]       unistr             *system_name,
1208                 [in]       uint32             access_mask,
1209                 [in,out]   uint32             level,
1210                 [in,out,switch_is(level),ref] samr_ConnectInfo *info,
1211                 [out,ref]  policy_handle      *connect_handle
1212                 );
1213
1214         /************************/
1215         /* Function    0x41     */
1216         NTSTATUS samr_RidToSid(
1217                 [in,ref]    policy_handle *domain_handle,
1218                 [in]        uint32        rid,
1219                 [out]       dom_sid2      *sid
1220                 );
1221
1222
1223         /************************/
1224         /* Function    0x42     */
1225
1226         /*
1227           this should set the DSRM password for the server, which is used
1228           when booting into Directory Services Recovery Mode on a DC. Win2003
1229           gives me NT_STATUS_NOT_SUPPORTED
1230         */
1231
1232         NTSTATUS samr_SetDsrmPassword(
1233                 [in]       samr_Name *name,
1234                 [in]       uint32 unknown,
1235                 [in]       samr_Password *hash
1236                 );
1237
1238
1239         /************************/
1240         /* Function    0x43     */
1241         /*
1242           I haven't been able to work out the format of this one yet.
1243           Seems to start with a switch level for a union?
1244         */
1245         NTSTATUS samr_ValidatePassword();
1246 }