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