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