s3-samr-idl: add SAM server specific access rights.
[samba.git] / source / librpc / idl / samr.idl
1 #include "idl_types.h"
2
3 /*
4   samr interface definition
5 */
6 import "misc.idl", "lsa.idl", "security.idl";
7
8 /*
9   Thanks to Todd Sabin for some information from his samr.idl in acltools
10 */
11
12 [ uuid("12345778-1234-abcd-ef00-0123456789ac"),
13   version(1.0),
14   endpoint("ncacn_np:[\\pipe\\samr]","ncacn_ip_tcp:", "ncalrpc:"),
15   pointer_default(unique)
16 ] interface samr
17 {
18         typedef bitmap security_secinfo security_secinfo;
19
20         /* account control (acct_flags) bits */
21         typedef [public,bitmap32bit] bitmap {
22                 ACB_DISABLED                    = 0x00000001,  /* 1 = User account disabled */
23                 ACB_HOMDIRREQ                   = 0x00000002,  /* 1 = Home directory required */
24                 ACB_PWNOTREQ                    = 0x00000004,  /* 1 = User password not required */
25                 ACB_TEMPDUP                     = 0x00000008,  /* 1 = Temporary duplicate account */
26                 ACB_NORMAL                      = 0x00000010,  /* 1 = Normal user account */
27                 ACB_MNS                         = 0x00000020,  /* 1 = MNS logon user account */
28                 ACB_DOMTRUST                    = 0x00000040,  /* 1 = Interdomain trust account */
29                 ACB_WSTRUST                     = 0x00000080,  /* 1 = Workstation trust account */
30                 ACB_SVRTRUST                    = 0x00000100,  /* 1 = Server trust account */
31                 ACB_PWNOEXP                     = 0x00000200,  /* 1 = User password does not expire */
32                 ACB_AUTOLOCK                    = 0x00000400,  /* 1 = Account auto locked */
33                 ACB_ENC_TXT_PWD_ALLOWED         = 0x00000800,  /* 1 = Encryped text password is allowed */
34                 ACB_SMARTCARD_REQUIRED          = 0x00001000,  /* 1 = Smart Card required */
35                 ACB_TRUSTED_FOR_DELEGATION      = 0x00002000,  /* 1 = Trusted for Delegation */
36                 ACB_NOT_DELEGATED               = 0x00004000,  /* 1 = Not delegated */
37                 ACB_USE_DES_KEY_ONLY            = 0x00008000,  /* 1 = Use DES key only */
38                 ACB_DONT_REQUIRE_PREAUTH        = 0x00010000,  /* 1 = Preauth not required */
39                 ACB_PW_EXPIRED                  = 0x00020000,  /* 1 = Password Expired */
40                 ACB_NO_AUTH_DATA_REQD           = 0x00080000   /* 1 = No authorization data required */
41         } samr_AcctFlags;
42
43         /* SAM server specific access rights */
44
45         typedef [bitmap32bit] bitmap {
46                 SAMR_ACCESS_CONNECT_TO_SERVER   = 0x00000001,
47                 SAMR_ACCESS_SHUTDOWN_SERVER     = 0x00000002,
48                 SAMR_ACCESS_INITIALIZE_SERVER   = 0x00000004,
49                 SAMR_ACCESS_CREATE_DOMAIN       = 0x00000008,
50                 SAMR_ACCESS_ENUM_DOMAINS        = 0x00000010,
51                 SAMR_ACCESS_OPEN_DOMAIN         = 0x00000020
52         } samr_ConnectAccessMask;
53
54         const int SAMR_ACCESS_ALL_ACCESS = 0x0000003F;
55
56         const int GENERIC_RIGHTS_SAM_ALL_ACCESS =
57                 (STANDARD_RIGHTS_REQUIRED_ACCESS        |
58                  SAMR_ACCESS_ALL_ACCESS);
59
60         const int GENERIC_RIGHTS_SAM_READ =
61                 (STANDARD_RIGHTS_READ_ACCESS            |
62                  SAMR_ACCESS_ENUM_DOMAINS);
63
64         const int GENERIC_RIGHTS_SAM_WRITE =
65                 (STANDARD_RIGHTS_WRITE_ACCESS           |
66                  SAMR_ACCESS_CREATE_DOMAIN              |
67                  SAMR_ACCESS_INITIALIZE_SERVER          |
68                  SAMR_ACCESS_SHUTDOWN_SERVER);
69
70         const int GENERIC_RIGHTS_SAM_EXECUTE =
71                 (STANDARD_RIGHTS_EXECUTE_ACCESS         |
72                  SAMR_ACCESS_OPEN_DOMAIN                |
73                  SAMR_ACCESS_CONNECT_TO_SERVER);
74
75         typedef [bitmap32bit] bitmap {
76                 SAMR_USER_ACCESS_GET_NAME_ETC             = 0x00000001,
77                 SAMR_USER_ACCESS_GET_LOCALE               = 0x00000002,
78                 SAMR_USER_ACCESS_SET_LOC_COM              = 0x00000004,
79                 SAMR_USER_ACCESS_GET_LOGONINFO            = 0x00000008,
80                 SAMR_USER_ACCESS_GET_ATTRIBUTES           = 0x00000010,
81                 SAMR_USER_ACCESS_SET_ATTRIBUTES           = 0x00000020,
82                 SAMR_USER_ACCESS_CHANGE_PASSWORD          = 0x00000040,
83                 SAMR_USER_ACCESS_SET_PASSWORD             = 0x00000080,
84                 SAMR_USER_ACCESS_GET_GROUPS               = 0x00000100,
85                 SAMR_USER_ACCESS_GET_GROUP_MEMBERSHIP     = 0x00000200,
86                 SAMR_USER_ACCESS_CHANGE_GROUP_MEMBERSHIP  = 0x00000400
87         } samr_UserAccessMask;
88
89         typedef [bitmap32bit] bitmap {
90                 SAMR_DOMAIN_ACCESS_LOOKUP_INFO_1  = 0x00000001,
91                 SAMR_DOMAIN_ACCESS_SET_INFO_1     = 0x00000002,
92                 SAMR_DOMAIN_ACCESS_LOOKUP_INFO_2  = 0x00000004,
93                 SAMR_DOMAIN_ACCESS_SET_INFO_2     = 0x00000008,
94                 SAMR_DOMAIN_ACCESS_CREATE_USER    = 0x00000010,
95                 SAMR_DOMAIN_ACCESS_CREATE_GROUP   = 0x00000020,
96                 SAMR_DOMAIN_ACCESS_CREATE_ALIAS   = 0x00000040,
97                 SAMR_DOMAIN_ACCESS_LOOKUP_ALIAS   = 0x00000080,
98                 SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS  = 0x00000100,
99                 SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT   = 0x00000200,
100                 SAMR_DOMAIN_ACCESS_SET_INFO_3     = 0x00000400
101         } samr_DomainAccessMask;
102
103         typedef [bitmap32bit] bitmap {
104                 SAMR_GROUP_ACCESS_LOOKUP_INFO     = 0x00000001,
105                 SAMR_GROUP_ACCESS_SET_INFO        = 0x00000002,
106                 SAMR_GROUP_ACCESS_ADD_MEMBER      = 0x00000004,
107                 SAMR_GROUP_ACCESS_REMOVE_MEMBER   = 0x00000008,
108                 SAMR_GROUP_ACCESS_GET_MEMBERS     = 0x00000010
109         } samr_GroupAccessMask;
110
111         typedef [bitmap32bit] bitmap {
112                 SAMR_ALIAS_ACCESS_ADD_MEMBER      = 0x00000001,
113                 SAMR_ALIAS_ACCESS_REMOVE_MEMBER   = 0x00000002,
114                 SAMR_ALIAS_ACCESS_GET_MEMBERS     = 0x00000004,
115                 SAMR_ALIAS_ACCESS_LOOKUP_INFO     = 0x00000008,
116                 SAMR_ALIAS_ACCESS_SET_INFO        = 0x00000010
117         } samr_AliasAccessMask;
118
119         /******************/
120         /* Function: 0x00 */
121         NTSTATUS samr_Connect (
122                 /* notice the lack of [string] */
123                 [in,unique] uint16 *system_name,
124                 [in]       samr_ConnectAccessMask access_mask,
125                 [out,ref]  policy_handle *connect_handle
126                 );
127
128
129         /******************/
130         /* Function: 0x01 */
131         [public] NTSTATUS samr_Close (
132                 [in,out,ref]  policy_handle *handle
133                 );
134
135         /******************/
136         /* Function: 0x02 */
137
138         NTSTATUS samr_SetSecurity (
139                 [in,ref]          policy_handle *handle,
140                 [in]              security_secinfo sec_info,
141                 [in,ref]          sec_desc_buf *sdbuf
142                 );
143
144         /******************/
145         /* Function: 0x03 */
146
147         NTSTATUS samr_QuerySecurity (
148                 [in,ref]          policy_handle *handle,
149                 [in]              security_secinfo sec_info,
150                 [out,ref]         sec_desc_buf **sdbuf
151                 );
152
153         /******************/
154         /* Function: 0x04 */
155
156         /*
157           shutdown the SAM - once you call this the SAM will be dead
158         */
159         NTSTATUS samr_Shutdown (
160                 [in,ref]   policy_handle *connect_handle
161                 );
162
163         /******************/
164         /* Function: 0x05 */
165         NTSTATUS samr_LookupDomain (
166                 [in,ref]  policy_handle *connect_handle,
167                 [in,ref]  lsa_String *domain_name,
168                 [out,ref] dom_sid2 **sid
169                 );
170
171
172         /******************/
173         /* Function: 0x06 */
174
175         typedef struct {
176                 uint32 idx;
177                 lsa_String name;
178         } samr_SamEntry;
179
180         typedef struct {
181                 uint32 count;
182                 [size_is(count)] samr_SamEntry *entries;
183         } samr_SamArray;
184
185         NTSTATUS samr_EnumDomains (
186                 [in]          policy_handle *connect_handle,
187                 [in,out,ref]  uint32 *resume_handle,
188                 [out,ref]     samr_SamArray **sam,
189                 [in]          uint32 buf_size,
190                 [out,ref]     uint32 *num_entries
191                 );
192
193
194         /************************/
195         /* Function    0x07     */
196         [public] NTSTATUS samr_OpenDomain(
197                 [in,ref]      policy_handle *connect_handle,
198                 [in]          samr_DomainAccessMask access_mask,
199                 [in,ref]      dom_sid2 *sid,
200                 [out,ref]     policy_handle *domain_handle
201                 );
202
203         /************************/
204         /* Function    0x08     */
205         /* server roles */
206         typedef [v1_enum] enum {
207                 SAMR_ROLE_STANDALONE    = 0,
208                 SAMR_ROLE_DOMAIN_MEMBER = 1,
209                 SAMR_ROLE_DOMAIN_BDC    = 2,
210                 SAMR_ROLE_DOMAIN_PDC    = 3
211         } samr_Role;
212
213         /* password properties flags */
214         typedef [public,bitmap32bit] bitmap {
215                 DOMAIN_PASSWORD_COMPLEX         = 0x00000001,
216                 DOMAIN_PASSWORD_NO_ANON_CHANGE  = 0x00000002,
217                 DOMAIN_PASSWORD_NO_CLEAR_CHANGE = 0x00000004,
218                 DOMAIN_PASSWORD_LOCKOUT_ADMINS  = 0x00000008,
219                 DOMAIN_PASSWORD_STORE_CLEARTEXT = 0x00000010,
220                 DOMAIN_REFUSE_PASSWORD_CHANGE   = 0x00000020
221         } samr_PasswordProperties;
222
223         typedef struct {
224                 uint16 min_password_length;
225                 uint16 password_history_length;
226                 samr_PasswordProperties password_properties;
227                 /* yes, these are signed. They are in negative 100ns */
228                 dlong  max_password_age;
229                 dlong  min_password_age;
230         } samr_DomInfo1;
231
232         typedef struct {
233                 NTTIME force_logoff_time;
234                 lsa_String comment;
235                 lsa_String domain_name;
236                 lsa_String primary; /* PDC name if this is a BDC */
237                 udlong sequence_num;
238                 uint32 unknown2;
239                 samr_Role role;
240                 uint32 unknown3;
241                 uint32 num_users;
242                 uint32 num_groups;
243                 uint32 num_aliases;
244         } samr_DomInfo2;
245
246         typedef struct {
247                 NTTIME force_logoff_time;
248         } samr_DomInfo3;
249
250         typedef struct {
251                 lsa_String comment;
252         } samr_DomInfo4;
253
254         typedef struct {
255                 lsa_String domain_name;
256         } samr_DomInfo5;
257
258         typedef struct {
259                 lsa_String primary;
260         } samr_DomInfo6;
261
262         typedef struct {
263                 samr_Role role;
264         } samr_DomInfo7;
265
266         typedef struct {
267                 hyper sequence_num;
268                 NTTIME domain_create_time;
269         } samr_DomInfo8;
270
271         typedef struct {
272                 uint32 unknown; /* w2k3 returns 1 */
273         } samr_DomInfo9;
274
275         typedef struct {
276                 samr_DomInfo2 info2;
277                 hyper lockout_duration;
278                 hyper lockout_window;
279                 uint16 lockout_threshold;
280         } samr_DomInfo11;
281
282         typedef struct {
283                 hyper lockout_duration;
284                 hyper lockout_window;
285                 uint16 lockout_threshold;
286         } samr_DomInfo12;
287
288         typedef struct {
289                 hyper sequence_num;
290                 NTTIME domain_create_time;
291                 uint32 unknown1;
292                 uint32 unknown2;
293         } samr_DomInfo13;
294
295         typedef [switch_type(uint16)] union {
296                 [case(1)] samr_DomInfo1 info1;
297                 [case(2)] samr_DomInfo2 info2;
298                 [case(3)] samr_DomInfo3 info3;
299                 [case(4)] samr_DomInfo4 info4;
300                 [case(5)] samr_DomInfo5 info5;
301                 [case(6)] samr_DomInfo6 info6;
302                 [case(7)] samr_DomInfo7 info7;
303                 [case(8)] samr_DomInfo8 info8;
304                 [case(9)] samr_DomInfo9 info9;
305                 [case(11)] samr_DomInfo11 info11;
306                 [case(12)] samr_DomInfo12 info12;
307                 [case(13)] samr_DomInfo13 info13;
308         } samr_DomainInfo;
309
310         NTSTATUS samr_QueryDomainInfo(
311                 [in,ref]      policy_handle *domain_handle,
312                 [in]          uint16 level,
313                 [out,ref,switch_is(level)] samr_DomainInfo **info
314                 );
315
316         /************************/
317         /* Function    0x09     */
318         /*
319           only levels 1, 3, 4, 6, 7, 9, 12 are valid for this 
320           call in w2k3
321         */
322         NTSTATUS samr_SetDomainInfo(
323                 [in,ref]      policy_handle *domain_handle,
324                 [in]          uint16 level,
325                 [in,switch_is(level),ref] samr_DomainInfo *info
326                 );
327
328
329         /************************/
330         /* Function    0x0a     */
331         NTSTATUS samr_CreateDomainGroup(
332                 [in,ref]      policy_handle *domain_handle,
333                 [in,ref]      lsa_String *name,
334                 [in]          samr_GroupAccessMask access_mask,
335                 [out,ref]     policy_handle *group_handle,
336                 [out,ref]     uint32 *rid
337                 );
338                 
339
340         /************************/
341         /* Function    0x0b     */
342
343         const int MAX_SAM_ENTRIES_W2K = 0x400; /* 1024 */
344         const int MAX_SAM_ENTRIES_W95 = 50;
345
346         NTSTATUS samr_EnumDomainGroups(
347                 [in]          policy_handle *domain_handle,
348                 [in,out,ref]  uint32 *resume_handle,
349                 [out,ref]     samr_SamArray **sam,
350                 [in]          uint32 max_size,
351                 [out,ref]     uint32 *num_entries
352                 );
353
354         /************************/
355         /* Function    0x0c     */
356         NTSTATUS samr_CreateUser(
357                 [in,ref]      policy_handle *domain_handle,
358                 [in,ref]      lsa_String *account_name,
359                 [in]          samr_UserAccessMask access_mask,
360                 [out,ref]     policy_handle *user_handle,
361                 [out,ref]     uint32 *rid
362                 );
363
364         /************************/
365         /* Function    0x0d     */
366
367
368         /* w2k3 treats max_size as max_users*54 and sets the
369            resume_handle as the rid of the last user sent
370         */
371         const int SAMR_ENUM_USERS_MULTIPLIER = 54;
372
373         NTSTATUS samr_EnumDomainUsers(
374                 [in]          policy_handle *domain_handle,
375                 [in,out,ref]  uint32 *resume_handle,
376                 [in]          samr_AcctFlags acct_flags,
377                 [out,ref]     samr_SamArray **sam,
378                 [in]          uint32 max_size,
379                 [out,ref]     uint32 *num_entries
380                 );
381
382         /************************/
383         /* Function    0x0e     */
384         NTSTATUS samr_CreateDomAlias(
385                 [in,ref]      policy_handle *domain_handle,
386                 [in,ref]      lsa_String   *alias_name,
387                 [in]          samr_AliasAccessMask access_mask,
388                 [out,ref]     policy_handle *alias_handle,
389                 [out,ref]     uint32        *rid
390                 );
391
392         /************************/
393         /* Function    0x0f     */
394         NTSTATUS samr_EnumDomainAliases(
395                 [in]          policy_handle *domain_handle,
396                 [in,out,ref]  uint32 *resume_handle,
397                 [out,ref]     samr_SamArray **sam,
398                 [in]          uint32 max_size,
399                 [out,ref]     uint32 *num_entries
400                 );
401
402         /************************/
403         /* Function    0x10     */
404
405         typedef struct {
406                 [range(0,1024)]  uint32 count;
407                 [size_is(count)] uint32 *ids;
408         } samr_Ids;
409
410         NTSTATUS samr_GetAliasMembership(
411                 [in,ref]      policy_handle *domain_handle,
412                 [in,ref]      lsa_SidArray  *sids,
413                 [out,ref]     samr_Ids *rids
414                 );
415
416         /************************/
417         /* Function    0x11     */
418
419         [public] NTSTATUS samr_LookupNames(
420                 [in,ref]      policy_handle *domain_handle,
421                 [in,range(0,1000)] uint32 num_names,
422                 [in,size_is(1000),length_is(num_names)] lsa_String names[],
423                 [out,ref]     samr_Ids *rids,
424                 [out,ref]     samr_Ids *types
425                 );
426
427
428         /************************/
429         /* Function    0x12     */
430         NTSTATUS samr_LookupRids(
431                 [in,ref]      policy_handle *domain_handle,
432                 [in,range(0,1000)] uint32 num_rids,
433                 [in,size_is(1000),length_is(num_rids)] uint32 rids[],
434                 [out,ref]     lsa_Strings *names,
435                 [out,ref]     samr_Ids *types
436                 );
437
438         /************************/
439         /* Function    0x13     */
440         NTSTATUS samr_OpenGroup(
441                 [in,ref]      policy_handle *domain_handle,
442                 [in]          samr_GroupAccessMask access_mask,
443                 [in]          uint32 rid,
444                 [out,ref]     policy_handle *group_handle
445                 );
446
447         /* Group attributes */
448         typedef [public,bitmap32bit] bitmap {
449                 SE_GROUP_MANDATORY              = 0x00000001,
450                 SE_GROUP_ENABLED_BY_DEFAULT     = 0x00000002,
451                 SE_GROUP_ENABLED                = 0x00000004,
452                 SE_GROUP_OWNER                  = 0x00000008,
453                 SE_GROUP_USE_FOR_DENY_ONLY      = 0x00000010,
454                 SE_GROUP_RESOURCE               = 0x20000000,
455                 SE_GROUP_LOGON_ID               = 0xC0000000
456         } samr_GroupAttrs;
457
458         /************************/
459         /* Function    0x14     */
460
461         typedef struct {
462                 lsa_String name;
463                 samr_GroupAttrs attributes;
464                 uint32 num_members;
465                 lsa_String description;
466         } samr_GroupInfoAll;
467
468         typedef struct {
469                 samr_GroupAttrs attributes;
470         } samr_GroupInfoAttributes;
471
472         typedef struct {
473                 lsa_String description;
474         } samr_GroupInfoDescription;
475
476         typedef enum {
477                 GROUPINFOALL          = 1,
478                 GROUPINFONAME         = 2,
479                 GROUPINFOATTRIBUTES   = 3,
480                 GROUPINFODESCRIPTION  = 4,
481                 GROUPINFOALL2         = 5
482         } samr_GroupInfoEnum;
483
484         typedef [switch_type(samr_GroupInfoEnum)] union {
485                 [case(GROUPINFOALL)]         samr_GroupInfoAll        all;
486                 [case(GROUPINFONAME)]        lsa_String               name;
487                 [case(GROUPINFOATTRIBUTES)]  samr_GroupInfoAttributes attributes;
488                 [case(GROUPINFODESCRIPTION)] lsa_String               description;
489                 [case(GROUPINFOALL2)]        samr_GroupInfoAll        all2;
490         } samr_GroupInfo;
491
492         NTSTATUS samr_QueryGroupInfo(
493                 [in,ref]                  policy_handle *group_handle,
494                 [in]                      samr_GroupInfoEnum level,
495                 [out,ref,switch_is(level)] samr_GroupInfo **info
496                 );
497
498         /************************/
499         /* Function    0x15     */
500         NTSTATUS samr_SetGroupInfo(
501                 [in,ref]                  policy_handle *group_handle,
502                 [in]                      samr_GroupInfoEnum level,
503                 [in,switch_is(level),ref] samr_GroupInfo *info
504                 );
505
506         /************************/
507         /* Function    0x16     */
508         NTSTATUS samr_AddGroupMember(
509                 [in,ref]                  policy_handle *group_handle,
510                 [in]                      uint32 rid,
511                 [in]                      uint32 flags
512                 );
513
514         /************************/
515         /* Function    0x17     */
516         NTSTATUS samr_DeleteDomainGroup(
517                 [in,out,ref]   policy_handle *group_handle
518                 );
519
520         /************************/
521         /* Function    0x18     */
522         NTSTATUS samr_DeleteGroupMember(
523                 [in,ref]                  policy_handle *group_handle,
524                 [in]                      uint32 rid
525                 );
526
527
528         /************************/
529         /* Function    0x19     */
530         typedef struct {
531                 uint32 count;
532                 [size_is(count)] uint32 *rids;
533                 [size_is(count)] uint32 *types;
534         } samr_RidTypeArray;
535
536         NTSTATUS samr_QueryGroupMember(
537                 [in,ref]  policy_handle *group_handle,
538                 [out,ref] samr_RidTypeArray **rids
539                 );
540
541
542         /************************/
543         /* Function    0x1a     */
544
545         /*
546           win2003 seems to accept any data at all for the two integers
547           below, and doesn't seem to do anything with them that I can
548           see. Weird. I really expected the first integer to be a rid
549           and the second to be the attributes for that rid member.
550         */
551         NTSTATUS samr_SetMemberAttributesOfGroup(
552                 [in,ref]  policy_handle *group_handle,
553                 [in]      uint32 unknown1,
554                 [in]      uint32 unknown2
555                 );
556
557
558         /************************/
559         /* Function    0x1b     */
560         NTSTATUS samr_OpenAlias (
561                 [in,ref]      policy_handle *domain_handle,
562                 [in]          samr_AliasAccessMask access_mask,
563                 [in]          uint32 rid,
564                 [out,ref]     policy_handle *alias_handle
565                 );
566
567
568         /************************/
569         /* Function    0x1c     */
570
571         typedef struct {
572                 lsa_String name;
573                 uint32 num_members;
574                 lsa_String description;
575         } samr_AliasInfoAll;
576
577         typedef enum {
578                 ALIASINFOALL          = 1,
579                 ALIASINFONAME         = 2,
580                 ALIASINFODESCRIPTION  = 3
581         } samr_AliasInfoEnum;
582
583         typedef [switch_type(samr_AliasInfoEnum)] union {
584                 [case(ALIASINFOALL)] samr_AliasInfoAll all;
585                 [case(ALIASINFONAME)] lsa_String name;
586                 [case(ALIASINFODESCRIPTION)] lsa_String description;
587         } samr_AliasInfo;
588
589         NTSTATUS samr_QueryAliasInfo(
590                 [in,ref]                  policy_handle  *alias_handle,
591                 [in]                      samr_AliasInfoEnum      level,
592                 [out,ref,switch_is(level)] samr_AliasInfo **info
593                 );
594
595         /************************/
596         /* Function    0x1d     */
597         NTSTATUS samr_SetAliasInfo(
598                 [in,ref]                  policy_handle  *alias_handle,
599                 [in]                      samr_AliasInfoEnum      level,
600                 [in,switch_is(level),ref] samr_AliasInfo *info
601                 );
602
603         /************************/
604         /* Function    0x1e     */
605         NTSTATUS samr_DeleteDomAlias(
606                 [in,out,ref]  policy_handle *alias_handle
607                 );
608
609         /************************/
610         /* Function    0x1f     */
611         NTSTATUS samr_AddAliasMember(
612                 [in,ref]  policy_handle *alias_handle,
613                 [in,ref]  dom_sid2      *sid
614                 );
615
616         /************************/
617         /* Function    0x20     */
618         NTSTATUS samr_DeleteAliasMember(
619                 [in,ref] policy_handle *alias_handle,
620                 [in,ref] dom_sid2      *sid
621                 );
622
623         /************************/
624         /* Function    0x21     */
625         NTSTATUS samr_GetMembersInAlias(
626                 [in,ref]   policy_handle *alias_handle,
627                 [out,ref]  lsa_SidArray    *sids
628                 );
629
630         /************************/
631         /* Function    0x22     */
632         [public] NTSTATUS samr_OpenUser(
633                 [in,ref]      policy_handle *domain_handle,
634                 [in]          samr_UserAccessMask access_mask,
635                 [in]          uint32 rid,
636                 [out,ref]     policy_handle *user_handle
637                 );
638
639         /************************/
640         /* Function    0x23     */
641         NTSTATUS samr_DeleteUser(
642                 [in,out,ref]   policy_handle *user_handle
643                 );
644
645         /************************/
646         /* Function    0x24     */
647         typedef struct {
648                 lsa_String account_name;
649                 lsa_String full_name;
650                 uint32 primary_gid;
651                 lsa_String description;
652                 lsa_String comment;
653         } samr_UserInfo1;
654
655         typedef struct {
656                 lsa_String comment;
657                 lsa_String unknown; /* settable, but doesn't stick. probably obsolete */
658                 uint16 country_code;
659                 uint16 code_page;
660         } samr_UserInfo2;
661
662         /* this is also used in samr and netlogon */
663         typedef [public, flag(NDR_PAHEX)] struct {
664                 uint16 units_per_week;
665                 [size_is(1260), length_is(units_per_week/8)] uint8 *bits;
666         } samr_LogonHours;
667
668         typedef struct {
669                 lsa_String account_name;
670                 lsa_String full_name;
671                 uint32 rid;
672                 uint32 primary_gid;
673                 lsa_String home_directory;
674                 lsa_String home_drive;
675                 lsa_String logon_script;
676                 lsa_String profile_path;
677                 lsa_String workstations;
678                 NTTIME last_logon;
679                 NTTIME last_logoff;
680                 NTTIME last_password_change;
681                 NTTIME allow_password_change;
682                 NTTIME force_password_change;
683                 samr_LogonHours logon_hours;
684                 uint16 bad_password_count;
685                 uint16 logon_count;
686                 samr_AcctFlags acct_flags;
687         } samr_UserInfo3;
688
689         typedef struct {
690                 samr_LogonHours logon_hours;
691         } samr_UserInfo4;
692
693         typedef struct {
694                 lsa_String account_name;
695                 lsa_String full_name;
696                 uint32 rid;
697                 uint32 primary_gid;
698                 lsa_String home_directory;
699                 lsa_String home_drive;
700                 lsa_String logon_script;
701                 lsa_String profile_path;
702                 lsa_String description;
703                 lsa_String workstations;
704                 NTTIME last_logon;
705                 NTTIME last_logoff;
706                 samr_LogonHours logon_hours;
707                 uint16 bad_password_count;
708                 uint16 logon_count;
709                 NTTIME last_password_change;
710                 NTTIME acct_expiry;
711                 samr_AcctFlags acct_flags;
712         } samr_UserInfo5;
713
714         typedef struct {
715                 lsa_String account_name;
716                 lsa_String full_name;
717         } samr_UserInfo6;
718
719         typedef struct {
720                 lsa_String account_name;
721         } samr_UserInfo7;
722
723         typedef struct {
724                 lsa_String full_name;
725         } samr_UserInfo8;
726
727         typedef struct {
728                 uint32 primary_gid;
729         } samr_UserInfo9;
730
731         typedef struct {
732                 lsa_String home_directory;
733                 lsa_String home_drive;
734         } samr_UserInfo10;
735
736         typedef struct {
737                 lsa_String logon_script;
738         } samr_UserInfo11;
739
740         typedef struct {
741                 lsa_String profile_path;
742         } samr_UserInfo12;
743
744         typedef struct {
745                 lsa_String description;
746         } samr_UserInfo13;
747
748         typedef struct {
749                 lsa_String workstations;
750         } samr_UserInfo14;
751
752         typedef struct {
753                 samr_AcctFlags acct_flags;
754         } samr_UserInfo16;
755         
756         typedef struct {
757                 NTTIME acct_expiry;
758         } samr_UserInfo17;
759
760         typedef [public, flag(NDR_PAHEX)] struct {
761                 uint8 hash[16];
762         } samr_Password;
763
764         typedef struct {
765                 samr_Password lm_pwd;
766                 samr_Password nt_pwd;
767                 boolean8 lm_pwd_active;
768                 boolean8 nt_pwd_active;
769         } samr_UserInfo18;
770
771         typedef struct {
772                 lsa_BinaryString parameters;
773         } samr_UserInfo20;
774
775         /* this defines the bits used for fields_present in info21 */
776         typedef [bitmap32bit] bitmap {
777                 SAMR_FIELD_ACCOUNT_NAME     = 0x00000001,
778                 SAMR_FIELD_FULL_NAME        = 0x00000002,
779                 SAMR_FIELD_RID              = 0x00000004,
780                 SAMR_FIELD_PRIMARY_GID      = 0x00000008,
781                 SAMR_FIELD_DESCRIPTION      = 0x00000010,
782                 SAMR_FIELD_COMMENT          = 0x00000020,
783                 SAMR_FIELD_HOME_DIRECTORY   = 0x00000040,
784                 SAMR_FIELD_HOME_DRIVE       = 0x00000080,
785                 SAMR_FIELD_LOGON_SCRIPT     = 0x00000100,
786                 SAMR_FIELD_PROFILE_PATH     = 0x00000200,
787                 SAMR_FIELD_WORKSTATIONS     = 0x00000400,
788                 SAMR_FIELD_LAST_LOGON       = 0x00000800,
789                 SAMR_FIELD_LAST_LOGOFF      = 0x00001000,
790                 SAMR_FIELD_LOGON_HOURS      = 0x00002000,
791                 SAMR_FIELD_BAD_PWD_COUNT    = 0x00004000,
792                 SAMR_FIELD_NUM_LOGONS       = 0x00008000,
793                 SAMR_FIELD_ALLOW_PWD_CHANGE = 0x00010000,
794                 SAMR_FIELD_FORCE_PWD_CHANGE = 0x00020000,
795                 SAMR_FIELD_LAST_PWD_CHANGE  = 0x00040000,
796                 SAMR_FIELD_ACCT_EXPIRY      = 0x00080000,
797                 SAMR_FIELD_ACCT_FLAGS       = 0x00100000,
798                 SAMR_FIELD_PARAMETERS       = 0x00200000,
799                 SAMR_FIELD_COUNTRY_CODE     = 0x00400000,
800                 SAMR_FIELD_CODE_PAGE        = 0x00800000,
801                 SAMR_FIELD_PASSWORD         = 0x01000000, /* either of these */
802                 SAMR_FIELD_PASSWORD2        = 0x02000000, /* two bits seems to work */
803                 SAMR_FIELD_PRIVATE_DATA     = 0x04000000,
804                 SAMR_FIELD_EXPIRED_FLAG     = 0x08000000,
805                 SAMR_FIELD_SEC_DESC         = 0x10000000,
806                 SAMR_FIELD_OWF_PWD          = 0x20000000
807         } samr_FieldsPresent;
808
809         /* used for 'password_expired' in samr_UserInfo21 */
810         const int PASS_MUST_CHANGE_AT_NEXT_LOGON = 0x01;
811         const int PASS_DONT_CHANGE_AT_NEXT_LOGON = 0x00;
812
813         typedef struct {
814                 NTTIME last_logon;
815                 NTTIME last_logoff;
816                 NTTIME last_password_change;
817                 NTTIME acct_expiry;
818                 NTTIME allow_password_change;
819                 NTTIME force_password_change;
820                 lsa_String account_name;
821                 lsa_String full_name;
822                 lsa_String home_directory;
823                 lsa_String home_drive;
824                 lsa_String logon_script;
825                 lsa_String profile_path;
826                 lsa_String description;
827                 lsa_String workstations;
828                 lsa_String comment;
829                 lsa_BinaryString parameters;
830                 lsa_String unknown1;
831                 lsa_String unknown2;
832                 lsa_String unknown3;
833                 uint32 buf_count;
834                 [size_is(buf_count)] uint8 *buffer;
835                 uint32 rid;
836                 uint32 primary_gid;
837                 samr_AcctFlags acct_flags;
838                 samr_FieldsPresent fields_present;
839                 samr_LogonHours logon_hours;
840                 uint16 bad_password_count;
841                 uint16 logon_count;
842                 uint16 country_code;
843                 uint16 code_page;
844                 uint8  nt_password_set;
845                 uint8  lm_password_set;
846                 uint8  password_expired;
847                 uint8  unknown4;
848         } samr_UserInfo21;
849
850         typedef [public, flag(NDR_PAHEX)] struct {
851                 uint8 data[516];
852         } samr_CryptPassword;
853
854         typedef struct {
855                 samr_UserInfo21 info;
856                 samr_CryptPassword password;
857         } samr_UserInfo23;
858
859         typedef struct {
860                 samr_CryptPassword password;
861                 uint8 pw_len;
862         } samr_UserInfo24;
863
864         typedef [flag(NDR_PAHEX)] struct {
865                 uint8 data[532];
866         } samr_CryptPasswordEx;
867
868         typedef struct {
869                 samr_UserInfo21 info;
870                 samr_CryptPasswordEx password;
871         } samr_UserInfo25;
872
873         typedef struct {
874                 samr_CryptPasswordEx password;
875                 uint8 pw_len;
876         } samr_UserInfo26;
877
878         typedef [switch_type(uint16)] union {
879                 [case(1)] samr_UserInfo1 info1;
880                 [case(2)] samr_UserInfo2 info2;
881                 [case(3)] samr_UserInfo3 info3;
882                 [case(4)] samr_UserInfo4 info4;
883                 [case(5)] samr_UserInfo5 info5;
884                 [case(6)] samr_UserInfo6 info6;
885                 [case(7)] samr_UserInfo7 info7;
886                 [case(8)] samr_UserInfo8 info8;
887                 [case(9)] samr_UserInfo9 info9;
888                 [case(10)] samr_UserInfo10 info10;
889                 [case(11)] samr_UserInfo11 info11;
890                 [case(12)] samr_UserInfo12 info12;
891                 [case(13)] samr_UserInfo13 info13;
892                 [case(14)] samr_UserInfo14 info14;
893                 [case(16)] samr_UserInfo16 info16;
894                 [case(17)] samr_UserInfo17 info17;
895                 [case(18)] samr_UserInfo18 info18;
896                 [case(20)] samr_UserInfo20 info20;
897                 [case(21)] samr_UserInfo21 info21;
898                 [case(23)] samr_UserInfo23 info23;
899                 [case(24)] samr_UserInfo24 info24;
900                 [case(25)] samr_UserInfo25 info25;
901                 [case(26)] samr_UserInfo26 info26;
902         } samr_UserInfo;
903
904         [public] NTSTATUS samr_QueryUserInfo(
905                 [in,ref]                  policy_handle *user_handle,
906                 [in]                      uint16 level,
907                 [out,ref,switch_is(level)] samr_UserInfo **info
908                 );
909
910
911         /************************/
912         /* Function    0x25     */
913         [public] NTSTATUS samr_SetUserInfo(
914                 [in,ref]                   policy_handle *user_handle,
915                 [in]                       uint16 level,
916                 [in,ref,switch_is(level)]  samr_UserInfo *info
917                 );
918
919         /************************/
920         /* Function    0x26     */
921         /*
922           this is a password change interface that doesn't give
923           the server the plaintext password. Depricated.
924         */
925         NTSTATUS samr_ChangePasswordUser(
926                 [in,ref]    policy_handle *user_handle,
927                 [in]        boolean8 lm_present,
928                 [in,unique] samr_Password *old_lm_crypted,
929                 [in,unique] samr_Password *new_lm_crypted,
930                 [in]        boolean8 nt_present,
931                 [in,unique] samr_Password *old_nt_crypted,
932                 [in,unique] samr_Password *new_nt_crypted,
933                 [in]        boolean8 cross1_present,
934                 [in,unique] samr_Password *nt_cross,
935                 [in]        boolean8 cross2_present,
936                 [in,unique] samr_Password *lm_cross
937                 );
938
939         /************************/
940         /* Function    0x27     */
941
942         typedef [public] struct {
943                 uint32 rid;
944                 samr_GroupAttrs attributes;
945         } samr_RidWithAttribute;
946
947         typedef [public] struct {
948                 uint32     count;
949                 [size_is(count)] samr_RidWithAttribute *rids;
950         } samr_RidWithAttributeArray;
951
952         NTSTATUS samr_GetGroupsForUser(
953                 [in,ref]   policy_handle *user_handle,
954                 [out,ref]  samr_RidWithAttributeArray  **rids
955                 );
956
957         /************************/
958         /* Function    0x28     */
959
960         typedef struct {
961                 uint32    idx;
962                 uint32    rid;
963                 samr_AcctFlags acct_flags;
964                 lsa_String account_name;
965                 lsa_String description;
966                 lsa_String full_name;
967         } samr_DispEntryGeneral;
968
969         typedef struct {
970                 uint32 count;
971                 [size_is(count)] samr_DispEntryGeneral *entries;
972         } samr_DispInfoGeneral;
973
974         typedef struct {
975                 uint32    idx;
976                 uint32    rid;
977                 samr_AcctFlags acct_flags;
978                 lsa_String account_name;
979                 lsa_String description;
980         } samr_DispEntryFull;
981
982         typedef struct {
983                 uint32 count;
984                 [size_is(count)] samr_DispEntryFull *entries;
985         } samr_DispInfoFull;
986
987         typedef struct {
988                 uint32    idx;
989                 uint32    rid;
990                 samr_GroupAttrs acct_flags;
991                 lsa_String account_name;
992                 lsa_String description;
993         } samr_DispEntryFullGroup;
994
995         typedef struct {
996                 uint32 count;
997                 [size_is(count)] samr_DispEntryFullGroup *entries;
998         } samr_DispInfoFullGroups;
999
1000         typedef struct {
1001                 uint32    idx;
1002                 lsa_AsciiStringLarge account_name;
1003         } samr_DispEntryAscii;
1004
1005         typedef struct {
1006                 uint32 count;
1007                 [size_is(count)] samr_DispEntryAscii *entries;
1008         } samr_DispInfoAscii;
1009
1010         typedef [switch_type(uint16)] union {
1011                 [case(1)] samr_DispInfoGeneral info1;/* users */
1012                 [case(2)] samr_DispInfoFull info2; /* trust accounts? */
1013                 [case(3)] samr_DispInfoFullGroups info3; /* groups */
1014                 [case(4)] samr_DispInfoAscii info4; /* users */
1015                 [case(5)] samr_DispInfoAscii info5; /* groups */
1016         } samr_DispInfo;
1017
1018         NTSTATUS samr_QueryDisplayInfo(
1019                 [in,ref]    policy_handle *domain_handle,
1020                 [in]        uint16 level,
1021                 [in]        uint32 start_idx,
1022                 [in]        uint32 max_entries,
1023                 [in]        uint32 buf_size,
1024                 [out,ref]   uint32 *total_size,
1025                 [out,ref]   uint32 *returned_size,
1026                 [out,ref,switch_is(level)] samr_DispInfo *info
1027                 );
1028
1029
1030         /************************/
1031         /* Function    0x29     */
1032
1033         /*
1034           this seems to be an alphabetic search function. The returned index
1035           is the index for samr_QueryDisplayInfo needed to get names occurring
1036           after the specified name. The supplied name does not need to exist
1037           in the database (for example you can supply just a first letter for 
1038           searching starting at that letter)
1039
1040           The level corresponds to the samr_QueryDisplayInfo level
1041         */
1042         NTSTATUS samr_GetDisplayEnumerationIndex(
1043                 [in,ref]    policy_handle *domain_handle,
1044                 [in]        uint16 level,
1045                 [in,ref]    lsa_String *name,
1046                 [out,ref]   uint32 *idx
1047                 );
1048
1049
1050
1051         /************************/
1052         /* Function    0x2a     */
1053
1054         /*
1055           w2k3 returns NT_STATUS_NOT_IMPLEMENTED for this
1056         */
1057         NTSTATUS samr_TestPrivateFunctionsDomain(
1058                 [in,ref]    policy_handle *domain_handle
1059                 );
1060
1061
1062         /************************/
1063         /* Function    0x2b     */
1064
1065         /*
1066           w2k3 returns NT_STATUS_NOT_IMPLEMENTED for this
1067         */
1068         NTSTATUS samr_TestPrivateFunctionsUser(
1069                 [in,ref]    policy_handle *user_handle
1070                 );
1071
1072
1073         /************************/
1074         /* Function    0x2c     */
1075
1076         typedef struct {
1077                 uint16 min_password_length;
1078                 samr_PasswordProperties password_properties;
1079         } samr_PwInfo;
1080
1081         [public] NTSTATUS samr_GetUserPwInfo(
1082                 [in,ref]    policy_handle *user_handle,
1083                 [out,ref]   samr_PwInfo *info
1084                 );
1085
1086         /************************/
1087         /* Function    0x2d     */
1088         NTSTATUS samr_RemoveMemberFromForeignDomain(
1089                 [in,ref]    policy_handle *domain_handle,
1090                 [in,ref]    dom_sid2 *sid
1091                 );
1092
1093         /************************/
1094         /* Function    0x2e     */
1095
1096         /*
1097           how is this different from QueryDomainInfo ??
1098         */
1099         NTSTATUS samr_QueryDomainInfo2(
1100                 [in,ref]      policy_handle *domain_handle,
1101                 [in]          uint16 level,
1102                 [out,ref,switch_is(level)] samr_DomainInfo **info
1103                 );
1104
1105         /************************/
1106         /* Function    0x2f     */
1107
1108         /*
1109           how is this different from QueryUserInfo ??
1110         */
1111         NTSTATUS samr_QueryUserInfo2(
1112                 [in,ref]                  policy_handle *user_handle,
1113                 [in]                      uint16 level,
1114                 [out,ref,switch_is(level)]    samr_UserInfo *info
1115                 );
1116
1117         /************************/
1118         /* Function    0x30     */
1119
1120         /*
1121           how is this different from QueryDisplayInfo??
1122         */
1123         NTSTATUS samr_QueryDisplayInfo2(
1124                 [in,ref]    policy_handle *domain_handle,
1125                 [in]        uint16 level,
1126                 [in]        uint32 start_idx,
1127                 [in]        uint32 max_entries,
1128                 [in]        uint32 buf_size,
1129                 [out,ref]   uint32 *total_size,
1130                 [out,ref]   uint32 *returned_size,
1131                 [out,ref,switch_is(level)] samr_DispInfo *info
1132                 );
1133
1134         /************************/
1135         /* Function    0x31     */
1136
1137         /*
1138           how is this different from GetDisplayEnumerationIndex ??
1139         */
1140         NTSTATUS samr_GetDisplayEnumerationIndex2(
1141                 [in,ref]    policy_handle *domain_handle,
1142                 [in]        uint16 level,
1143                 [in,ref]    lsa_String *name,
1144                 [out,ref]   uint32 *idx
1145                 );
1146
1147
1148         /************************/
1149         /* Function    0x32     */
1150         NTSTATUS samr_CreateUser2(
1151                 [in,ref]      policy_handle *domain_handle,
1152                 [in,ref]      lsa_String *account_name,
1153                 [in]          samr_AcctFlags acct_flags,
1154                 [in]          samr_UserAccessMask access_mask,
1155                 [out,ref]     policy_handle *user_handle,
1156                 [out,ref]     uint32 *access_granted,
1157                 [out,ref]     uint32 *rid
1158                 );
1159
1160
1161         /************************/
1162         /* Function    0x33     */
1163
1164         /*
1165           another duplicate. There must be a reason ....
1166         */
1167         NTSTATUS samr_QueryDisplayInfo3(
1168                 [in,ref]    policy_handle *domain_handle,
1169                 [in]        uint16 level,
1170                 [in]        uint32 start_idx,
1171                 [in]        uint32 max_entries,
1172                 [in]        uint32 buf_size,
1173                 [out,ref]   uint32 *total_size,
1174                 [out,ref]   uint32 *returned_size,
1175                 [out,ref,switch_is(level)] samr_DispInfo *info
1176                 );
1177
1178         /************************/
1179         /* Function    0x34     */
1180         NTSTATUS samr_AddMultipleMembersToAlias(
1181                 [in,ref]    policy_handle *alias_handle,
1182                 [in,ref]    lsa_SidArray *sids
1183                 );
1184
1185         /************************/
1186         /* Function    0x35     */
1187         NTSTATUS samr_RemoveMultipleMembersFromAlias(
1188                 [in,ref]    policy_handle *alias_handle,
1189                 [in,ref]    lsa_SidArray *sids
1190                 );
1191
1192         /************************/
1193         /* Function    0x36     */
1194
1195         NTSTATUS samr_OemChangePasswordUser2(
1196                 [in,unique]       lsa_AsciiString *server,
1197                 [in,ref]          lsa_AsciiString *account,
1198                 [in,unique]       samr_CryptPassword *password,
1199                 [in,unique]       samr_Password *hash
1200                 );
1201
1202         /************************/
1203         /* Function    0x37     */
1204         NTSTATUS samr_ChangePasswordUser2(
1205                 [in,unique]       lsa_String *server,
1206                 [in,ref]          lsa_String *account,
1207                 [in,unique]       samr_CryptPassword *nt_password,
1208                 [in,unique]       samr_Password *nt_verifier,
1209                 [in]              boolean8 lm_change,
1210                 [in,unique]       samr_CryptPassword *lm_password,
1211                 [in,unique]       samr_Password *lm_verifier
1212                 );
1213
1214         /************************/
1215         /* Function    0x38     */
1216         NTSTATUS samr_GetDomPwInfo(
1217                 [in,unique] lsa_String *domain_name,
1218                 [out,ref]   samr_PwInfo *info
1219                 );
1220
1221         /************************/
1222         /* Function    0x39     */
1223         NTSTATUS samr_Connect2(
1224                 [in,unique,string,charset(UTF16)] uint16 *system_name,
1225                 [in] samr_ConnectAccessMask access_mask,
1226                 [out,ref]  policy_handle *connect_handle
1227                 );
1228
1229         /************************/
1230         /* Function    0x3a     */
1231         /*
1232           seems to be an exact alias for samr_SetUserInfo() 
1233         */
1234         [public] NTSTATUS samr_SetUserInfo2(
1235                 [in,ref]                   policy_handle *user_handle,
1236                 [in]                       uint16 level,
1237                 [in,ref,switch_is(level)]  samr_UserInfo *info
1238                 );
1239
1240         /************************/
1241         /* Function    0x3b     */
1242         /*
1243           this one is mysterious. I have a few guesses, but nothing working yet
1244         */
1245         NTSTATUS samr_SetBootKeyInformation(
1246                 [in,ref]   policy_handle *connect_handle,
1247                 [in]       uint32 unknown1,
1248                 [in]       uint32 unknown2,
1249                 [in]       uint32 unknown3
1250                 );
1251
1252         /************************/
1253         /* Function    0x3c     */
1254         NTSTATUS samr_GetBootKeyInformation(
1255                 [in,ref]   policy_handle *domain_handle,
1256                 [out,ref]  uint32 *unknown
1257                 );
1258
1259         /************************/
1260         /* Function    0x3d     */
1261         NTSTATUS samr_Connect3(
1262                 [in,unique,string,charset(UTF16)] uint16 *system_name,
1263                 /* this unknown value seems to be completely ignored by w2k3 */
1264                 [in] uint32 unknown,
1265                 [in] samr_ConnectAccessMask access_mask,
1266                 [out,ref]  policy_handle *connect_handle
1267                 );
1268
1269         /************************/
1270         /* Function    0x3e     */
1271
1272         typedef enum {
1273                 SAMR_CONNECT_PRE_W2K    = 1,
1274                 SAMR_CONNECT_W2K        = 2,
1275                 SAMR_CONNECT_AFTER_W2K  = 3
1276         } samr_ConnectVersion;
1277
1278         NTSTATUS samr_Connect4(
1279                 [in,unique,string,charset(UTF16)] uint16 *system_name,
1280                 [in] samr_ConnectVersion client_version,
1281                 [in] samr_ConnectAccessMask access_mask,
1282                 [out,ref]  policy_handle *connect_handle
1283                 );
1284
1285         /************************/
1286         /* Function    0x3f     */
1287
1288         typedef enum samr_RejectReason samr_RejectReason;
1289
1290         typedef struct {
1291                 samr_RejectReason reason;
1292                 uint32 unknown1;
1293                 uint32 unknown2;
1294         } samr_ChangeReject;
1295
1296         NTSTATUS samr_ChangePasswordUser3(
1297                 [in,unique]       lsa_String *server,
1298                 [in,ref]          lsa_String *account,
1299                 [in,unique]       samr_CryptPassword *nt_password,
1300                 [in,unique]       samr_Password *nt_verifier,
1301                 [in]              boolean8 lm_change,
1302                 [in,unique]       samr_CryptPassword *lm_password,
1303                 [in,unique]       samr_Password *lm_verifier,
1304                 [in,unique]       samr_CryptPassword *password3,
1305                 [out,ref]         samr_DomInfo1 **dominfo,
1306                 [out,ref]         samr_ChangeReject **reject
1307                 );
1308
1309         /************************/
1310         /* Function    0x40      */
1311
1312         typedef struct {
1313                 samr_ConnectVersion client_version; /* w2k3 gives 3 */
1314                 uint32         unknown2; /* w2k3 gives 0 */
1315         } samr_ConnectInfo1;
1316
1317         typedef union {
1318                 [case(1)]  samr_ConnectInfo1 info1;
1319         } samr_ConnectInfo;
1320
1321         [public] NTSTATUS samr_Connect5(
1322                 [in,unique,string,charset(UTF16)] uint16 *system_name,
1323                 [in]       samr_ConnectAccessMask  access_mask,
1324                 [in]       uint32             level_in,
1325                 [in,ref,switch_is(level_in)] samr_ConnectInfo *info_in,
1326                 [out,ref]  uint32             *level_out,
1327                 [out,ref,switch_is(*level_out)] samr_ConnectInfo *info_out,
1328                 [out,ref]  policy_handle      *connect_handle
1329                 );
1330
1331         /************************/
1332         /* Function    0x41     */
1333         NTSTATUS samr_RidToSid(
1334                 [in,ref]    policy_handle *domain_handle,
1335                 [in]        uint32        rid,
1336                 [out,ref]   dom_sid2      *sid
1337                 );
1338
1339
1340         /************************/
1341         /* Function    0x42     */
1342
1343         /*
1344           this should set the DSRM password for the server, which is used
1345           when booting into Directory Services Recovery Mode on a DC. Win2003
1346           gives me NT_STATUS_NOT_SUPPORTED
1347         */
1348
1349         NTSTATUS samr_SetDsrmPassword(
1350                 [in,unique] lsa_String *name,
1351                 [in]       uint32 unknown,
1352                 [in,unique] samr_Password *hash
1353                 );
1354
1355
1356         /************************/
1357         /* Function    0x43     */
1358         /************************/
1359         typedef [bitmap32bit] bitmap {
1360                 SAMR_VALIDATE_FIELD_PASSWORD_LAST_SET           = 0x00000001,
1361                 SAMR_VALIDATE_FIELD_BAD_PASSWORD_TIME           = 0x00000002,
1362                 SAMR_VALIDATE_FIELD_LOCKOUT_TIME                = 0x00000004,
1363                 SAMR_VALIDATE_FIELD_BAD_PASSWORD_COUNT          = 0x00000008,
1364                 SAMR_VALIDATE_FIELD_PASSWORD_HISTORY_LENGTH     = 0x00000010,
1365                 SAMR_VALIDATE_FIELD_PASSWORD_HISTORY            = 0x00000020
1366         } samr_ValidateFieldsPresent;
1367
1368         typedef enum {
1369                 NetValidateAuthentication = 1,
1370                 NetValidatePasswordChange= 2,
1371                 NetValidatePasswordReset = 3
1372         } samr_ValidatePasswordLevel;
1373
1374         /* NetApi maps samr_ValidationStatus errors to WERRORs. Haven't
1375          * identified the mapping of
1376          * - NERR_PasswordFilterError
1377          * - NERR_PasswordExpired and
1378          * - NERR_PasswordCantChange
1379          * yet - Guenther
1380          */
1381
1382         typedef enum {
1383                 SAMR_VALIDATION_STATUS_SUCCESS = 0,
1384                 SAMR_VALIDATION_STATUS_PASSWORD_MUST_CHANGE = 1,
1385                 SAMR_VALIDATION_STATUS_ACCOUNT_LOCKED_OUT = 2,
1386                 SAMR_VALIDATION_STATUS_BAD_PASSWORD = 4,
1387                 SAMR_VALIDATION_STATUS_PWD_HISTORY_CONFLICT = 5,
1388                 SAMR_VALIDATION_STATUS_PWD_TOO_SHORT = 6,
1389                 SAMR_VALIDATION_STATUS_PWD_TOO_LONG = 7,
1390                 SAMR_VALIDATION_STATUS_NOT_COMPLEX_ENOUGH = 8,
1391                 SAMR_VALIDATION_STATUS_PASSWORD_TOO_RECENT = 9
1392         } samr_ValidationStatus;
1393
1394         typedef struct {
1395                 uint32 length;
1396                 [size_is(length)] uint8 *data;
1397         } samr_ValidationBlob;
1398
1399         typedef struct {
1400                 samr_ValidateFieldsPresent fields_present;
1401                 NTTIME_hyper last_password_change;
1402                 NTTIME_hyper bad_password_time;
1403                 NTTIME_hyper lockout_time;
1404                 uint32 bad_pwd_count;
1405                 uint32 pwd_history_len;
1406                 [size_is(pwd_history_len)] samr_ValidationBlob *pwd_history;
1407         } samr_ValidatePasswordInfo;
1408
1409         typedef struct {
1410                 samr_ValidatePasswordInfo info;
1411                 samr_ValidationStatus status;
1412         } samr_ValidatePasswordRepCtr;
1413
1414         typedef [switch_type(uint16)] union {
1415                 [case(1)] samr_ValidatePasswordRepCtr ctr1;
1416                 [case(2)] samr_ValidatePasswordRepCtr ctr2;
1417                 [case(3)] samr_ValidatePasswordRepCtr ctr3;
1418         } samr_ValidatePasswordRep;
1419
1420         typedef struct {
1421                 samr_ValidatePasswordInfo info;
1422                 lsa_StringLarge password;
1423                 lsa_StringLarge account;
1424                 samr_ValidationBlob hash;
1425                 boolean8 pwd_must_change_at_next_logon;
1426                 boolean8 clear_lockout;
1427         } samr_ValidatePasswordReq3;
1428
1429         typedef struct {
1430                 samr_ValidatePasswordInfo info;
1431                 lsa_StringLarge password;
1432                 lsa_StringLarge account;
1433                 samr_ValidationBlob hash;
1434                 boolean8 password_matched;
1435         } samr_ValidatePasswordReq2;
1436
1437         typedef struct {
1438                 samr_ValidatePasswordInfo info;
1439                 boolean8 password_matched;
1440         } samr_ValidatePasswordReq1;
1441
1442         typedef [switch_type(uint16)] union {
1443                 [case(1)] samr_ValidatePasswordReq1 req1;
1444                 [case(2)] samr_ValidatePasswordReq2 req2;
1445                 [case(3)] samr_ValidatePasswordReq3 req3;
1446         } samr_ValidatePasswordReq;
1447
1448         NTSTATUS samr_ValidatePassword(
1449                 [in] samr_ValidatePasswordLevel level,
1450                 [in,switch_is(level)] samr_ValidatePasswordReq req,
1451                 [out,ref,switch_is(level)] samr_ValidatePasswordRep *rep
1452                 );
1453 }