1b03527cf7834db5eea8bcec4e356a7dcf0c1c30
[samba.git] / source / librpc / idl / netlogon.idl
1 /*
2   netlogon interface
3   much of this was derived from the ethereal sources - thanks to everyone 
4   who contributed!
5 */
6
7 #include "idl_types.h"
8
9 [
10   uuid("12345678-1234-abcd-ef00-01234567cffb"),
11   version(1.0),
12   endpoint("ncacn_np:[\\pipe\\netlogon]","ncacn_ip_tcp:","ncalrpc:"),
13   pointer_default(unique),
14   pointer_default_top(unique),
15   depends(lsa,samr,security)
16 ]
17
18 interface netlogon
19 {
20         declare bitmap samr_AcctFlags;
21
22         /*****************/
23         /* Function 0x00 */
24
25         typedef struct {
26                 [string,charset(UTF16)] uint16 *account_name;
27                 uint32 priv;
28                 uint32 auth_flags;
29                 uint32 logon_count;
30                 uint32 bad_pw_count;
31                 time_t last_logon;
32                 time_t last_logoff;
33                 time_t logoff_time;
34                 time_t kickoff_time;
35                 uint32 password_age;
36                 time_t pw_can_change;
37                 time_t pw_must_change;
38                 [string,charset(UTF16)] uint16 *computer;
39                 [string,charset(UTF16)] uint16 *domain;
40                 [string,charset(UTF16)] uint16 *script_path;
41                 uint32 unknown;
42         } netr_UasInfo;
43
44         WERROR netr_LogonUasLogon(
45                 [in]   [string,charset(UTF16)] uint16 *server_name,
46                 [in]   [string,charset(UTF16)] uint16 account_name[],
47                 [in]   [string,charset(UTF16)] uint16 workstation[],
48                 [out]  netr_UasInfo *info
49                 );
50
51
52         /*****************/
53         /* Function 0x01 */
54
55         typedef struct {
56                 uint32 duration;
57                 uint16 logon_count;
58         } netr_UasLogoffInfo;
59
60         WERROR netr_LogonUasLogoff(
61                 [in] [string,charset(UTF16)] uint16 *server_name,
62                 [in] [string,charset(UTF16)] uint16 account_name[],
63                 [in] [string,charset(UTF16)] uint16 workstation[],
64                 [out] netr_UasLogoffInfo info
65                 );
66
67
68         /*****************/
69         /* Function 0x02 */
70
71         /* in netr_AcctLockStr size seems to be be 24, and rrenard thinks 
72            that the structure of the bindata looks like this:
73
74                 dlong  lockout_duration;
75                 udlong reset_count;
76                 uint32 bad_attempt_lockout;
77                 uint32 dummy;   
78
79            but it doesn't look as though this structure is reflected at the
80            NDR level. Maybe it is left to the application to decode the bindata array.
81         */
82         typedef struct {
83                 uint16 size;
84                 uint16 length;
85                 [size_is(size/2),length_is(length/2)] uint16 *bindata;
86         } netr_AcctLockStr;
87
88         const int MSV1_0_CLEARTEXT_PASSWORD_ALLOWED = 0x002;
89         const int MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT = 0x020;
90         const int MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT = 0x800;
91
92         typedef struct {
93                 lsa_String  domain_name;
94                 uint32      parameter_control; /* see MSV1_0_* */
95                 uint32      logon_id_low;
96                 uint32      logon_id_high;
97                 lsa_String  account_name;
98                 lsa_String  workstation;
99         } netr_IdentityInfo;
100
101         typedef struct {
102                 netr_IdentityInfo identity_info;
103                 samr_Password lmpassword;
104                 samr_Password ntpassword;
105         } netr_PasswordInfo;
106
107         typedef [flag(NDR_PAHEX)] struct {
108                 uint16 length;
109                 [value(length)] uint16 size;
110                 [size_is(length),length_is(length)] uint8 *data;
111         } netr_ChallengeResponse;
112
113         typedef [flag(NDR_PAHEX)] struct {
114                 netr_IdentityInfo identity_info;
115                 uint8 challenge[8];
116                 netr_ChallengeResponse nt;
117                 netr_ChallengeResponse lm;
118         } netr_NetworkInfo;
119
120         typedef [switch_type(uint16)] union {
121                 [case(1)] netr_PasswordInfo *password;
122                 [case(2)] netr_NetworkInfo  *network;
123                 [case(3)] netr_PasswordInfo *password;
124                 [case(5)] netr_PasswordInfo *password;
125                 [case(6)] netr_NetworkInfo  *network;
126         } netr_LogonLevel;
127
128         typedef [public] struct {
129                 uint32 rid;
130                 uint32 attributes;
131         } netr_GroupMembership;
132
133         typedef [public,flag(NDR_PAHEX)] struct {
134                 uint8 key[16];
135         } netr_UserSessionKey;
136
137         typedef [public,flag(NDR_PAHEX)] struct {
138                 uint8 key[8];
139         } netr_LMSessionKey;
140
141         /* Flags for user_flags below */
142         typedef [public,bitmap32bit] bitmap {
143                 NETLOGON_GUEST                  = 0x0001,
144                 NETLOGON_NOENCRYPTION           = 0x0002,
145                 NETLOGON_CACHED_ACCOUNT         = 0x0004,
146                 NETLOGON_USED_LM_PASSWORD       = 0x0008,
147                 NETLOGON_EXTRA_SIDS             = 0x0020,
148                 NETLOGON_SUBAUTH_SESSION_KEY    = 0x0040,
149                 NETLOGON_SERVER_TRUST_ACCOUNT   = 0x0080,
150                 NETLOGON_NTLMV2_ENABLED         = 0x0100,
151                 NETLOGON_RESOURCE_GROUPS        = 0x0200,
152                 NETLOGON_PROFILE_PATH_RETURNED  = 0x0400
153         } netr_UserFlags;
154
155         typedef struct {
156                 NTTIME last_logon;
157                 NTTIME last_logoff;
158                 NTTIME acct_expiry;
159                 NTTIME last_password_change;
160                 NTTIME allow_password_change;
161                 NTTIME force_password_change;
162                 lsa_String account_name;
163                 lsa_String full_name;
164                 lsa_String logon_script;
165                 lsa_String profile_path;
166                 lsa_String home_directory;
167                 lsa_String home_drive;
168                 uint16 logon_count;
169                 uint16 bad_password_count;
170                 uint32 rid;
171                 uint32 primary_gid;
172                 samr_RidWithAttributeArray groups;
173                 netr_UserFlags user_flags;
174                 netr_UserSessionKey key;
175                 lsa_StringLarge logon_server;
176                 lsa_StringLarge domain;
177                 dom_sid2 *domain_sid;
178                 netr_LMSessionKey LMSessKey;
179                 samr_AcctFlags acct_flags;
180                 uint32 unknown[7];
181         } netr_SamBaseInfo;
182
183         typedef struct {
184                 netr_SamBaseInfo base;
185         } netr_SamInfo2;
186
187         typedef struct {
188                 dom_sid2 *sid;
189                 uint32 attribute;
190         } netr_SidAttr;
191
192         typedef [public] struct {
193                 netr_SamBaseInfo base;
194                 uint32 sidcount;
195                 [size_is(sidcount)] netr_SidAttr *sids;
196         } netr_SamInfo3;
197
198         typedef struct {
199                 netr_SamBaseInfo base;
200                 uint32 sidcount;
201                 [size_is(sidcount)] netr_SidAttr *sids;
202                 lsa_String forest;
203                 lsa_String principle;
204                 uint32 unknown4[20];
205         } netr_SamInfo6;
206
207         typedef struct {
208                 uint32 pac_size;
209                 [size_is(pac_size)] uint8 *pac;
210                 lsa_String logon_domain;
211                 lsa_String logon_server;
212                 lsa_String principal_name;
213                 uint32 auth_size;
214                 [size_is(auth_size)] uint8 *auth;
215                 netr_UserSessionKey user_session_key;
216                 uint32 expansionroom[10];
217                 lsa_String unknown1;
218                 lsa_String unknown2;
219                 lsa_String unknown3;
220                 lsa_String unknown4;
221         } netr_PacInfo;
222
223         typedef [switch_type(uint16)] union {
224                 [case(2)] netr_SamInfo2 *sam2;
225                 [case(3)] netr_SamInfo3 *sam3;
226                 [case(4)] netr_PacInfo  *pac;
227                 [case(5)] netr_PacInfo  *pac;
228                 [case(6)] netr_SamInfo6 *sam6;
229         } netr_Validation;
230
231         typedef [public, flag(NDR_PAHEX)] struct {
232                 uint8 data[8];
233         } netr_Credential;
234
235         typedef [public] struct {
236                 netr_Credential cred;
237                 time_t timestamp;
238         } netr_Authenticator;
239
240         NTSTATUS netr_LogonSamLogon(
241                 [in] [string,charset(UTF16)] uint16 *server_name,
242                 [in] [string,charset(UTF16)] uint16 *computer_name,
243                 [in] netr_Authenticator *credential,
244                 [in][out] netr_Authenticator *return_authenticator,
245                 [in]  uint16 logon_level,
246                 [in]  [switch_is(logon_level)] netr_LogonLevel logon,
247                 [in]  uint16 validation_level,
248                 [out] [switch_is(validation_level)] netr_Validation validation,
249                 [out] uint8 authoritative
250                 );
251
252
253         /*****************/
254         /* Function 0x03 */
255
256         NTSTATUS netr_LogonSamLogoff(
257                 [in] [string,charset(UTF16)] uint16 *server_name,
258                 [in] [string,charset(UTF16)] uint16 *computer_name,
259                 [in]      netr_Authenticator *credential,
260                 [in][out] netr_Authenticator *return_authenticator,
261                 [in] uint16 logon_level,
262                 [in] [switch_is(logon_level)] netr_LogonLevel logon
263                 );
264         
265
266
267         /*****************/
268         /* Function 0x04 */
269
270         NTSTATUS netr_ServerReqChallenge(
271                 [in,string,charset(UTF16)] uint16 *server_name,
272                 [in,string,charset(UTF16)] uint16 computer_name[],
273                 [in,out,ref] netr_Credential *credentials
274                 );
275
276
277         /*****************/
278         /* Function 0x05 */
279
280         declare enum netr_SchannelType;
281
282         NTSTATUS netr_ServerAuthenticate(
283                 [in,string,charset(UTF16)] uint16 *server_name,
284                 [in,string,charset(UTF16)] uint16 account_name[],
285                 [in]                       netr_SchannelType secure_channel_type,
286                 [in,string,charset(UTF16)] uint16 computer_name[],
287                 [in,out,ref] netr_Credential *credentials
288                 );
289
290
291         /*****************/
292         /* Function 0x06 */
293
294         NTSTATUS netr_ServerPasswordSet(
295                 [in]  [string,charset(UTF16)] uint16 *server_name,
296                 [in]  [string,charset(UTF16)] uint16 account_name[],
297                 [in]  netr_SchannelType secure_channel_type,
298                 [in]  [string,charset(UTF16)] uint16 computer_name[],
299                 [in]  netr_Authenticator credential,
300                 [in]  samr_Password new_password,
301                 [out] netr_Authenticator return_authenticator
302                 );
303
304
305         /*****************/
306         /* Function 0x07 */
307
308         declare enum netr_SamDatabaseID;
309
310         typedef struct {
311                 [string,charset(UTF16)] uint16 *account_name;
312                 lsa_String unknown1;
313                 lsa_String unknown2;
314                 lsa_String unknown3;
315                 lsa_String unknown4;
316                 uint32 unknown5;
317                 uint32 unknown6;
318                 uint32 unknown7;
319                 uint32 unknown8;
320         } netr_DELTA_DELETE_USER;
321
322         typedef struct {
323                 uint16 length;
324                 [value(length)] uint16 size;
325                 uint32 flags;
326                 samr_Password pwd;
327         } netr_USER_KEY16;
328
329         typedef struct {
330                 uint16 nt_length;
331                 uint16 nt_size;
332                 uint32 nt_flags;
333                 uint16 lm_length;
334                 uint16 lm_size;
335                 uint32 lm_flags;
336                 uint8 nt_history[nt_length];
337                 uint8 lm_history[lm_length];
338         } netr_PasswordHistory;
339
340         typedef struct {
341                 netr_USER_KEY16 lmpassword;
342                 netr_USER_KEY16 ntpassword;
343                 netr_PasswordHistory lmhistory;
344         } netr_USER_KEYS2;
345
346         typedef struct {
347                 netr_USER_KEYS2 keys2;
348         } netr_USER_KEY_UNION;
349
350         typedef [public] struct {
351                 uint32 version;
352                 netr_USER_KEY_UNION keys;
353         } netr_USER_KEYS;
354
355         typedef struct {
356                 bool8  SensitiveDataFlag;
357                 uint32 DataLength;
358
359                 /* netr_USER_KEYS encrypted with the session key */
360                 [size_is(DataLength)][flag(NDR_PAHEX)] uint8 *SensitiveData;
361         } netr_USER_PRIVATE_INFO;
362
363         typedef struct {
364                 lsa_String account_name;
365                 lsa_String full_name;
366                 uint32 rid;
367                 uint32 primary_gid;
368                 lsa_String home_directory;
369                 lsa_String home_drive;
370                 lsa_String logon_script;
371                 lsa_String description;
372                 lsa_String workstations;
373                 NTTIME last_logon;
374                 NTTIME last_logoff;
375                 samr_LogonHours logon_hours;
376                 uint16 bad_password_count;
377                 uint16 logon_count;
378                 NTTIME last_password_change;
379                 NTTIME acct_expiry;
380                 samr_AcctFlags acct_flags;
381                 samr_Password lmpassword;
382                 samr_Password ntpassword;
383                 bool8 nt_password_present;
384                 bool8 lm_password_present;
385                 bool8 password_expired;
386                 lsa_String comment;
387                 lsa_String parameters;
388                 uint16 country_code;
389                 uint16 code_page;
390                 netr_USER_PRIVATE_INFO user_private_info;
391                 uint32 SecurityInformation;
392                 sec_desc_buf sdbuf;
393                 lsa_String profile_path;
394                 lsa_String unknown2;
395                 lsa_String unknown3;
396                 lsa_String unknown4;
397                 uint32 unknown5;
398                 uint32 unknown6;
399                 uint32 unknown7;
400                 uint32 unknown8;
401         } netr_DELTA_USER;
402
403         typedef struct {
404                 lsa_String domain_name;
405                 lsa_String comment;
406                 dlong force_logoff_time;
407                 uint16 min_password_length;
408                 uint16 password_history_length;
409                 /* yes, these are signed. They are in negative 100ns */
410                 dlong  max_password_age;
411                 dlong  min_password_age;
412                 udlong sequence_num;
413                 NTTIME domain_create_time;
414                 uint32 SecurityInformation;
415                 sec_desc_buf sdbuf;
416                 netr_AcctLockStr account_lockout;
417                 lsa_String unknown2;
418                 lsa_String unknown3;
419                 lsa_String unknown4;
420                 uint32 logon_to_chgpass;
421                 uint32 unknown6;
422                 uint32 unknown7;
423                 uint32 unknown8;
424         } netr_DELTA_DOMAIN;
425
426         typedef struct {
427                 lsa_String group_name;
428                 uint32 rid;
429                 uint32 attributes;
430                 lsa_String description;
431                 uint32 SecurityInformation;
432                 sec_desc_buf sdbuf;
433                 lsa_String unknown1;
434                 lsa_String unknown2;
435                 lsa_String unknown3;
436                 lsa_String unknown4;
437                 uint32 unknown5;
438                 uint32 unknown6;
439                 uint32 unknown7;
440                 uint32 unknown8;
441         } netr_DELTA_GROUP;
442
443         typedef struct {
444                 lsa_String OldName;
445                 lsa_String NewName;
446                 lsa_String unknown1;
447                 lsa_String unknown2;
448                 lsa_String unknown3;
449                 lsa_String unknown4;
450                 uint32 unknown5;
451                 uint32 unknown6;
452                 uint32 unknown7;
453                 uint32 unknown8;
454         } netr_DELTA_RENAME;
455
456         typedef struct {
457                 [size_is(num_rids)] uint32 *rids;
458                 [size_is(num_rids)] uint32 *attribs;
459                 uint32 num_rids;
460                 uint32 unknown1;
461                 uint32 unknown2;
462                 uint32 unknown3;
463                 uint32 unknown4;
464         } netr_DELTA_GROUP_MEMBER;
465
466         typedef struct {
467                 lsa_String alias_name;
468                 uint32 rid;
469                 uint32 SecurityInformation;
470                 sec_desc_buf sdbuf;
471                 lsa_String description;
472                 lsa_String unknown2;
473                 lsa_String unknown3;
474                 lsa_String unknown4;
475                 uint32 unknown5;
476                 uint32 unknown6;
477                 uint32 unknown7;
478                 uint32 unknown8;
479         } netr_DELTA_ALIAS;
480
481         typedef struct {
482                 lsa_SidArray sids;
483                 uint32 unknown1;
484                 uint32 unknown2;
485                 uint32 unknown3;
486                 uint32 unknown4;
487         } netr_DELTA_ALIAS_MEMBER;
488
489         typedef struct {
490                 uint32 pagedpoollimit;
491                 uint32 nonpagedpoollimit;
492                 uint32 minimumworkingsetsize;
493                 uint32 maximumworkingsetsize;
494                 uint32 pagefilelimit;
495                 NTTIME timelimit;
496         } netr_QUOTA_LIMITS;
497
498         typedef struct {
499                 uint32 maxlogsize;
500                 NTTIME auditretentionperiod;
501                 bool8 auditingmode;
502                 uint32 maxauditeventcount;
503                 [size_is(maxauditeventcount+1)] uint32 *eventauditoptions;
504                 lsa_String primary_domain_name;
505                 dom_sid2 *sid;
506                 netr_QUOTA_LIMITS quota_limits;
507                 udlong sequence_num;
508                 NTTIME db_create_time;
509                 uint32 SecurityInformation;
510                 sec_desc_buf sdbuf;
511                 lsa_String unknown1;
512                 lsa_String unknown2;
513                 lsa_String unknown3;
514                 lsa_String unknown4;
515                 uint32 unknown5;
516                 uint32 unknown6;
517                 uint32 unknown7;
518                 uint32 unknown8;
519         } netr_DELTA_POLICY;
520
521         typedef struct {
522                 lsa_String domain_name;
523                 uint32 num_controllers;
524                 [size_is(num_controllers)] lsa_String *controller_names;
525                 uint32 SecurityInformation;
526                 sec_desc_buf sdbuf;
527                 lsa_String unknown1;
528                 lsa_String unknown2;
529                 lsa_String unknown3;
530                 lsa_String unknown4;
531                 uint32 posix_offset;
532                 uint32 unknown6;
533                 uint32 unknown7;
534                 uint32 unknown8;
535         } netr_DELTA_TRUSTED_DOMAIN;
536
537         typedef struct {
538                 uint16 unknown;
539         } netr_DELTA_DELETE_TRUST;
540
541         typedef struct {
542                 uint32 privilege_entries;
543                 uint32 privilege_control;
544                 [size_is(privilege_entries)] uint32 *privilege_attrib;
545                 [size_is(privilege_entries)] lsa_String *privilege_name;
546                 netr_QUOTA_LIMITS quotalimits;
547                 uint32 system_flags;
548                 uint32 SecurityInformation;
549                 sec_desc_buf sdbuf;
550                 lsa_String unknown1;
551                 lsa_String unknown2;
552                 lsa_String unknown3;
553                 lsa_String unknown4;
554                 uint32 unknown5;
555                 uint32 unknown6;
556                 uint32 unknown7;
557                 uint32 unknown8;
558         } netr_DELTA_ACCOUNT;
559
560         typedef struct {
561                 uint16 unknown;
562         } netr_DELTA_DELETE_ACCOUNT;
563
564         typedef struct {
565                 uint16 unknown;
566         } netr_DELTA_DELETE_SECRET;
567
568         typedef struct {
569                 uint32 len;
570                 uint32 maxlen;
571                 [size_is(maxlen)][length_is(len)] uint8 *cipher_data;
572         } netr_CIPHER_VALUE;
573
574         typedef struct {
575                 netr_CIPHER_VALUE current_cipher;
576                 NTTIME current_cipher_set_time;
577                 netr_CIPHER_VALUE old_cipher;
578                 NTTIME old_cipher_set_time;
579                 uint32 SecurityInformation;
580                 sec_desc_buf sdbuf;
581                 lsa_String unknown1;
582                 lsa_String unknown2;
583                 lsa_String unknown3;
584                 lsa_String unknown4;
585                 uint32 unknown5;
586                 uint32 unknown6;
587                 uint32 unknown7;
588                 uint32 unknown8;
589         } netr_DELTA_SECRET;
590
591         typedef enum {
592                 NETR_DELTA_DOMAIN           = 1,
593                 NETR_DELTA_GROUP            = 2,
594                 NETR_DELTA_DELETE_GROUP     = 3,
595                 NETR_DELTA_RENAME_GROUP     = 4,
596                 NETR_DELTA_USER             = 5,
597                 NETR_DELTA_DELETE_USER      = 6,
598                 NETR_DELTA_RENAME_USER      = 7,
599                 NETR_DELTA_GROUP_MEMBER     = 8,
600                 NETR_DELTA_ALIAS            = 9,
601                 NETR_DELTA_DELETE_ALIAS     = 10,
602                 NETR_DELTA_RENAME_ALIAS     = 11,
603                 NETR_DELTA_ALIAS_MEMBER     = 12,
604                 NETR_DELTA_POLICY           = 13,
605                 NETR_DELTA_TRUSTED_DOMAIN   = 14,
606                 NETR_DELTA_DELETE_TRUST     = 15,
607                 NETR_DELTA_ACCOUNT          = 16,
608                 NETR_DELTA_DELETE_ACCOUNT   = 17,
609                 NETR_DELTA_SECRET           = 18,
610                 NETR_DELTA_DELETE_SECRET    = 19,
611                 NETR_DELTA_DELETE_GROUP2    = 20,
612                 NETR_DELTA_DELETE_USER2     = 21,
613                 NETR_DELTA_MODIFY_COUNT     = 22
614         } netr_DeltaEnum;
615
616         typedef [switch_type(netr_DeltaEnum)] union {
617                 [case(NETR_DELTA_DOMAIN)]          netr_DELTA_DOMAIN          *domain;
618                 [case(NETR_DELTA_GROUP)]           netr_DELTA_GROUP           *group;
619                 [case(NETR_DELTA_DELETE_GROUP)]    ; /* rid only */
620                 [case(NETR_DELTA_RENAME_GROUP)]    netr_DELTA_RENAME          *rename_group;
621                 [case(NETR_DELTA_USER)]            netr_DELTA_USER            *user;
622                 [case(NETR_DELTA_DELETE_USER)]     ; /* rid only */
623                 [case(NETR_DELTA_RENAME_USER)]     netr_DELTA_RENAME          *rename_user;
624                 [case(NETR_DELTA_GROUP_MEMBER)]    netr_DELTA_GROUP_MEMBER    *group_member;
625                 [case(NETR_DELTA_ALIAS)]           netr_DELTA_ALIAS           *alias;
626                 [case(NETR_DELTA_DELETE_ALIAS)]    ; /* rid only */
627                 [case(NETR_DELTA_RENAME_ALIAS)]    netr_DELTA_RENAME          *rename_alias;
628                 [case(NETR_DELTA_ALIAS_MEMBER)]    netr_DELTA_ALIAS_MEMBER    *alias_member;
629                 [case(NETR_DELTA_POLICY)]          netr_DELTA_POLICY          *policy;
630                 [case(NETR_DELTA_TRUSTED_DOMAIN)]  netr_DELTA_TRUSTED_DOMAIN   *trusted_domain;
631                 [case(NETR_DELTA_DELETE_TRUST)]    netr_DELTA_DELETE_TRUST     delete_trust;
632                 [case(NETR_DELTA_ACCOUNT)]         netr_DELTA_ACCOUNT         *account;
633                 [case(NETR_DELTA_DELETE_ACCOUNT)]  netr_DELTA_DELETE_ACCOUNT   delete_account;
634                 [case(NETR_DELTA_SECRET)]          netr_DELTA_SECRET          *secret;
635                 [case(NETR_DELTA_DELETE_SECRET)]   netr_DELTA_DELETE_SECRET    delete_secret;
636                 [case(NETR_DELTA_DELETE_GROUP2)]   netr_DELTA_DELETE_USER     *delete_group;
637                 [case(NETR_DELTA_DELETE_USER2)]    netr_DELTA_DELETE_USER     *delete_user;
638                 [case(NETR_DELTA_MODIFY_COUNT)]    udlong                     *modified_count;
639         } netr_DELTA_UNION;
640
641         typedef [switch_type(netr_DeltaEnum)] union {
642                 [case(NETR_DELTA_DOMAIN)]          uint32 rid;
643                 [case(NETR_DELTA_GROUP)]           uint32 rid;
644                 [case(NETR_DELTA_DELETE_GROUP)]    uint32 rid;
645                 [case(NETR_DELTA_RENAME_GROUP)]    uint32 rid;
646                 [case(NETR_DELTA_USER)]            uint32 rid;
647                 [case(NETR_DELTA_DELETE_USER)]     uint32 rid;
648                 [case(NETR_DELTA_RENAME_USER)]     uint32 rid;
649                 [case(NETR_DELTA_GROUP_MEMBER)]    uint32 rid;
650                 [case(NETR_DELTA_ALIAS)]           uint32 rid;
651                 [case(NETR_DELTA_DELETE_ALIAS)]    uint32 rid;
652                 [case(NETR_DELTA_RENAME_ALIAS)]    uint32 rid;
653                 [case(NETR_DELTA_ALIAS_MEMBER)]    uint32 rid;
654                 [case(NETR_DELTA_POLICY)]          dom_sid2 *sid;
655                 [case(NETR_DELTA_TRUSTED_DOMAIN)]  dom_sid2 *sid;
656                 [case(NETR_DELTA_DELETE_TRUST)]    dom_sid2 *sid;
657                 [case(NETR_DELTA_ACCOUNT)]         dom_sid2 *sid;
658                 [case(NETR_DELTA_DELETE_ACCOUNT)]  dom_sid2 *sid;
659                 [case(NETR_DELTA_SECRET)]          [string,charset(UTF16)] uint16 *name;
660                 [case(NETR_DELTA_DELETE_SECRET)]   [string,charset(UTF16)] uint16 *name;
661                 [case(NETR_DELTA_DELETE_GROUP2)]   uint32 rid;
662                 [case(NETR_DELTA_DELETE_USER2)]    uint32 rid;
663                 [case(NETR_DELTA_MODIFY_COUNT)]    ;
664         } netr_DELTA_ID_UNION;
665
666         typedef struct {
667                 netr_DeltaEnum delta_type;
668                 [switch_is(delta_type)] netr_DELTA_ID_UNION delta_id_union;
669                 [switch_is(delta_type)] netr_DELTA_UNION delta_union;
670         } netr_DELTA_ENUM;
671
672         typedef struct {
673                 uint32 num_deltas;
674                 [size_is(num_deltas)] netr_DELTA_ENUM *delta_enum;
675         } netr_DELTA_ENUM_ARRAY;
676
677
678         NTSTATUS netr_DatabaseDeltas(
679                 [in]      [string,charset(UTF16)] uint16 logon_server[],
680                 [in]      [string,charset(UTF16)] uint16 computername[],
681                 [in]      netr_Authenticator credential,
682                 [in,out]  netr_Authenticator return_authenticator,
683                 [in]      netr_SamDatabaseID database_id,
684                 [in,out]  udlong sequence_num,
685                 [in]      uint32 preferredmaximumlength,
686                 [out]     netr_DELTA_ENUM_ARRAY *delta_enum_array
687                 );
688
689
690         /*****************/
691         /* Function 0x08 */
692
693         NTSTATUS netr_DatabaseSync(
694                 [in]     [string,charset(UTF16)] uint16 logon_server[],
695                 [in]     [string,charset(UTF16)] uint16 computername[],
696                 [in]     netr_Authenticator credential,
697                 [in,out] netr_Authenticator return_authenticator,
698                 [in]     netr_SamDatabaseID database_id,
699                 [in,out] uint32 sync_context,
700                 [in]     uint32 preferredmaximumlength,
701                 [out]    netr_DELTA_ENUM_ARRAY *delta_enum_array
702                 );
703
704
705         /*****************/
706         /* Function 0x09 */
707
708         /* w2k3 returns NT_STATUS_NOT_IMPLEMENTED for this call */
709
710         typedef [flag(NDR_PAHEX)] struct {
711                 uint8 computer_name[16];
712                 uint32 timecreated;
713                 uint32 serial_number;
714         } netr_UAS_INFO_0;
715
716         typedef struct {
717                 [flag(NDR_REMAINING)] DATA_BLOB blob;
718         } netr_AccountBuffer;
719
720         NTSTATUS netr_AccountDeltas(
721                 [in]     [string,charset(UTF16)] uint16 *logon_server,
722                 [in]     [string,charset(UTF16)] uint16 computername[],
723                 [in]     netr_Authenticator credential,
724                 [in,out] netr_Authenticator return_authenticator,
725                 [in]     netr_UAS_INFO_0 uas,
726                 [in]     uint32 count,
727                 [in]     uint32 level,
728                 [in]     uint32 buffersize,
729                 [out,subcontext(4)] netr_AccountBuffer buffer,
730                 [out]    uint32 count_returned,
731                 [out]    uint32 total_entries,
732                 [out]    netr_UAS_INFO_0 recordid
733                 );
734
735
736         /*****************/
737         /* Function 0x0A */
738
739         NTSTATUS netr_AccountSync(
740                 [in]      [string,charset(UTF16)] uint16 *logon_server,
741                 [in]      [string,charset(UTF16)] uint16 computername[],
742                 [in]      netr_Authenticator credential,
743                 [in,out]  netr_Authenticator return_authenticator,
744                 [in]      uint32 reference,
745                 [in]      uint32 level,
746                 [in]      uint32 buffersize,
747                 [out,subcontext(4)] netr_AccountBuffer buffer,
748                 [out]     uint32 count_returned,
749                 [out]     uint32 total_entries,
750                 [out]     uint32 next_reference,
751                 [in,out]  netr_UAS_INFO_0 recordid
752                 );
753
754
755         /*****************/
756         /* Function 0x0B */
757
758         NTSTATUS netr_GetDcName(
759                 [in]  [string,charset(UTF16)] uint16 logon_server[],
760                 [in]  [string,charset(UTF16)] uint16 *domainname,
761                 [out] [string,charset(UTF16)] uint16 *dcname
762                 );
763
764         /*****************/
765         /* Function 0x0C */
766
767         typedef struct {
768                 uint32 flags;
769                 uint32 pdc_connection_status;
770         } netr_NETLOGON_INFO_1;
771
772         typedef struct {
773                 uint32 flags;
774                 uint32 pdc_connection_status;
775                 [string,charset(UTF16)] uint16 trusted_dc_name[];
776                 uint32 tc_connection_status;
777         } netr_NETLOGON_INFO_2;
778
779         typedef struct {
780                 uint32 flags;
781                 uint32 logon_attempts;
782                 uint32 unknown1;
783                 uint32 unknown2;
784                 uint32 unknown3;
785                 uint32 unknown4;
786                 uint32 unknown5;
787         } netr_NETLOGON_INFO_3;
788
789         typedef union {
790                 [case(1)]  netr_NETLOGON_INFO_1 *info1;
791                 [case(2)]  netr_NETLOGON_INFO_2 *info2;
792                 [case(3)]  netr_NETLOGON_INFO_3 *info3;
793         } netr_CONTROL_QUERY_INFORMATION;
794
795         /* function_code values */
796         typedef [v1_enum] enum {
797                 NETLOGON_CONTROL_REDISCOVER       = 5,
798                 NETLOGON_CONTROL_TC_QUERY         = 6,
799                 NETLOGON_CONTROL_TRANSPORT_NOTIFY = 7,
800                 NETLOGON_CONTROL_SET_DBFLAG       = 65534
801         } netr_LogonControlCode;
802
803         WERROR netr_LogonControl(
804                 [in]   [string,charset(UTF16)] uint16 *logon_server,
805                 [in]   netr_LogonControlCode function_code,
806                 [in]   uint32 level,
807                 [out,switch_is(level)]  netr_CONTROL_QUERY_INFORMATION info
808                 );
809
810
811         /*****************/
812         /* Function 0x0D */
813
814         WERROR netr_GetAnyDCName(
815                 [in]  [string,charset(UTF16)] uint16 *logon_server,
816                 [in]  [string,charset(UTF16)] uint16 *domainname,
817                 [out] [string,charset(UTF16)] uint16 *dcname
818                 );
819
820
821         /*****************/
822         /* Function 0x0E */
823
824         typedef union {
825                 [case(NETLOGON_CONTROL_REDISCOVER)]        [string,charset(UTF16)] uint16 *domain;
826                 [case(NETLOGON_CONTROL_TC_QUERY)]          [string,charset(UTF16)] uint16 *domain;
827                 [case(NETLOGON_CONTROL_TRANSPORT_NOTIFY)]  [string,charset(UTF16)] uint16 *domain;
828                 [case(NETLOGON_CONTROL_SET_DBFLAG)]        uint32 debug_level;
829         } netr_CONTROL_DATA_INFORMATION;
830
831         WERROR netr_LogonControl2(
832                 [in]    [string,charset(UTF16)] uint16 *logon_server,
833                 [in]    uint32 function_code,
834                 [in]    uint32 level,
835                 [in][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION  data,
836                 [out][switch_is(level)]        netr_CONTROL_QUERY_INFORMATION query
837                 );
838
839
840         /* If this flag is not set, then the passwords and LM session keys are
841          * encrypted with DES calls.  (And the user session key is
842          * unencrypted) */ 
843         const int NETLOGON_NEG_ARCFOUR  = 0x00000004;
844         const int NETLOGON_NEG_128BIT   = 0x00004000;
845         const int NETLOGON_NEG_SCHANNEL = 0x40000000;
846
847         /*****************/
848         /* Function 0x0F */
849
850         NTSTATUS netr_ServerAuthenticate2(
851                 [in]         [string,charset(UTF16)] uint16 *server_name,
852                 [in]         [string,charset(UTF16)] uint16 account_name[],
853                 [in]         netr_SchannelType secure_channel_type,
854                 [in]         [string,charset(UTF16)] uint16 computer_name[],
855                 [in,out,ref] netr_Credential *credentials,
856                 [in,out,ref] uint32 *negotiate_flags
857                 );
858
859
860         /*****************/
861         /* Function 0x10 */
862
863         NTSTATUS netr_DatabaseSync2(
864                 [in]     [string,charset(UTF16)] uint16 logon_server[],
865                 [in]     [string,charset(UTF16)] uint16 computername[],
866                 [in]     netr_Authenticator credential,
867                 [in,out] netr_Authenticator return_authenticator,
868                 [in]     netr_SamDatabaseID database_id,
869                 [in]     uint16 restart_state,
870                 [in,out] uint32 sync_context,
871                 [in]     uint32 preferredmaximumlength,
872                 [out]    netr_DELTA_ENUM_ARRAY *delta_enum_array
873                 );
874
875
876         /*****************/
877         /* Function 0x11 */
878
879         /* i'm not at all sure how this call works */
880
881         NTSTATUS netr_DatabaseRedo(
882                 [in]     [string,charset(UTF16)] uint16 logon_server[],
883                 [in]     [string,charset(UTF16)] uint16 computername[],
884                 [in]     netr_Authenticator credential,
885                 [in,out] netr_Authenticator return_authenticator,
886                 [in][size_is(change_log_entry_size)] uint8 *change_log_entry,
887                 [in]     uint32 change_log_entry_size,
888                 [out]    netr_DELTA_ENUM_ARRAY *delta_enum_array
889                 );
890
891
892         /*****************/
893         /* Function 0x12 */
894
895         WERROR netr_LogonControl2Ex(
896                 [in]   [string,charset(UTF16)] uint16 *logon_server,
897                 [in]   uint32 function_code,
898                 [in]   uint32 level,
899                 [in][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION  data,
900                 [out][switch_is(level)]        netr_CONTROL_QUERY_INFORMATION query
901                 );
902
903         /*****************/
904         /* Function 0x13 */
905         WERROR netr_NETRENUMERATETRUSTEDDOMAINS() ;
906
907         /*****************/
908         /* Function 0x14 */             
909         typedef struct {
910                 [string,charset(UTF16)] uint16 *dc_unc;
911                 [string,charset(UTF16)] uint16 *dc_address;
912                 int32 dc_address_type;
913                 GUID domain_guid;
914                 [string,charset(UTF16)] uint16 *domain_name;
915                 [string,charset(UTF16)] uint16 *forest_name;
916                 uint32 dc_flags;
917                 [string,charset(UTF16)] uint16 *dc_site_name;
918                 [string,charset(UTF16)] uint16 *client_site_name;
919         } netr_DsRGetDCNameInfo;
920
921         WERROR netr_DsRGetDCName(
922                 [in] [string,charset(UTF16)] uint16 *server_unc,
923                 [in] [string,charset(UTF16)] uint16 *domain_name,
924                 [in] GUID *domain_guid,
925                 [in] GUID *site_guid,
926                 [in] uint32 flags,
927                 [out] netr_DsRGetDCNameInfo *info
928                 );
929
930         /*****************/
931         /* Function 0x15 */
932         WERROR netr_NETRLOGONDUMMYROUTINE1();
933
934         /****************/
935         /* Function 0x16 */
936         WERROR netr_NETRLOGONSETSERVICEBITS();
937
938         /****************/
939         /* Function 0x17 */
940         WERROR netr_NETRLOGONGETTRUSTRID();
941
942         /****************/
943         /* Function 0x18 */
944         WERROR netr_NETRLOGONCOMPUTESERVERDIGEST();
945
946         /****************/
947         /* Function 0x19 */
948         WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST();
949
950         /****************/
951         /* Function 0x1a */
952         NTSTATUS netr_ServerAuthenticate3(
953                 [in]         [string,charset(UTF16)] uint16 *server_name,
954                 [in]         [string,charset(UTF16)] uint16 account_name[],
955                 [in]         netr_SchannelType secure_channel_type,
956                 [in]         [string,charset(UTF16)] uint16 computer_name[],
957                 [in,out,ref] netr_Credential *credentials,
958                 [in,out,ref] uint32 *negotiate_flags,
959                 [out,ref]    uint32 *rid
960                 );
961
962         /****************/
963         /* Function 0x1b */
964
965         WERROR netr_DsRGetDCNameEx(
966                 [in] [string,charset(UTF16)] uint16 *server_unc,
967                 [in] [string,charset(UTF16)] uint16 *domain_name,
968                 [in] GUID *domain_guid,
969                 [in] [string,charset(UTF16)] uint16 *site_name,
970                 [in] uint32 flags,
971                 [out] netr_DsRGetDCNameInfo *info
972                 );
973
974         /****************/
975         /* Function 0x1c */
976         WERROR netr_DsRGetSiteName(
977                 [in] [string,charset(UTF16)] uint16 *computer_name,
978                 [out] [string,charset(UTF16)] uint16 *site
979                 );
980
981         /****************/
982         /* Function 0x1d */
983
984         typedef struct {
985                 uint32 length;
986                 [size_is(length)] uint8 *data;
987         } netr_Blob;
988
989         typedef [flag(NDR_PAHEX)] struct {
990                 uint16 length;
991                 uint16 size;
992                 [size_is(size/2),length_is(length/2)] uint16 *data;
993         } netr_BinaryString;
994
995         typedef struct {
996                 netr_Blob blob;
997                 [string,charset(UTF16)] uint16 *workstation_domain;
998                 [string,charset(UTF16)] uint16 *workstation_site;
999                 [string,charset(UTF16)] uint16 *unknown1;
1000                 [string,charset(UTF16)] uint16 *unknown2;
1001                 [string,charset(UTF16)] uint16 *unknown3;
1002                 [string,charset(UTF16)] uint16 *unknown4;
1003                 netr_BinaryString blob2;
1004                 lsa_String product;
1005                 lsa_String unknown5;
1006                 lsa_String unknown6;
1007                 uint32 unknown7[4];
1008         } netr_DomainQuery1;
1009
1010         typedef union {
1011                 [case(1)] netr_DomainQuery1 *query1;
1012                 [case(2)] netr_DomainQuery1 *query1;
1013         } netr_DomainQuery;
1014
1015         typedef struct {
1016                 lsa_String domainname;
1017                 lsa_String fulldomainname;
1018                 lsa_String forest;
1019                 GUID        guid;
1020                 dom_sid2    *sid;
1021                 netr_BinaryString unknown1[4];
1022                 uint32      unknown[4];
1023         } netr_DomainTrustInfo;
1024
1025         typedef struct {
1026                 netr_DomainTrustInfo domaininfo;
1027                 uint32 num_trusts;
1028                 [size_is(num_trusts)] netr_DomainTrustInfo *trusts;
1029                 uint32 unknown[14]; /* room for expansion? */
1030         } netr_DomainInfo1;
1031
1032         typedef union {
1033                 [case(1)] netr_DomainInfo1 *info1;
1034                 [case(2)] netr_DomainInfo1 *info1;
1035         } netr_DomainInfo;
1036         
1037         NTSTATUS netr_LogonGetDomainInfo(
1038                 [in]         [string,charset(UTF16)] uint16 server_name[],
1039                 [in]         [string,charset(UTF16)] uint16 *computer_name,
1040                 [in,ref]     netr_Authenticator *credential,
1041                 [in,out,ref] netr_Authenticator *return_authenticator,
1042                 [in]         uint32 level,
1043                 [in,switch_is(level)] netr_DomainQuery query,
1044                 [out,switch_is(level)] netr_DomainInfo info
1045                 );
1046
1047         typedef [flag(NDR_PAHEX)] struct {
1048                 uint16 data[256];
1049                 uint32 length;
1050         } netr_CryptPassword;
1051
1052         /*****************/
1053         /* Function 0x1e */
1054         NTSTATUS netr_ServerPasswordSet2(
1055                 [in]  [string,charset(UTF16)] uint16 *server_name,
1056                 [in]  [string,charset(UTF16)] uint16 account_name[],
1057                 [in]  netr_SchannelType secure_channel_type,
1058                 [in]  [string,charset(UTF16)] uint16 computer_name[],
1059                 [in]  netr_Authenticator credential,
1060                 [in]  netr_CryptPassword new_password,
1061                 [out] netr_Authenticator return_authenticator
1062                 );
1063
1064         /****************/
1065         /* Function 0x1f */
1066         WERROR netr_NETRSERVERPASSWORDGET();
1067
1068         /****************/
1069         /* Function 0x20 */
1070         WERROR netr_NETRLOGONSENDTOSAM();
1071
1072         /****************/
1073         /* Function 0x21 */
1074         WERROR netr_DSRADDRESSTOSITENAMESW();
1075
1076         /****************/
1077         /* Function 0x22 */
1078         WERROR netr_DsRGetDCNameEx2(
1079                 [in] [string,charset(UTF16)] uint16 *server_unc,
1080                 [in] [string,charset(UTF16)] uint16 *client_account,
1081                 [in] uint32 mask,
1082                 [in] [string,charset(UTF16)] uint16 *domain_name,
1083                 [in] GUID *domain_guid,
1084                 [in] [string,charset(UTF16)] uint16 *site_name,
1085                 [in] uint32 flags,
1086                 [out] netr_DsRGetDCNameInfo *info
1087                 );
1088
1089         /****************/
1090         /* Function 0x23 */
1091         WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN();
1092
1093         /****************/
1094         /* Function 0x24 */
1095         WERROR netr_NETRENUMERATETRUSTEDDOMAINSEX();
1096
1097         /****************/
1098         /* Function 0x25 */
1099         WERROR netr_DSRADDRESSTOSITENAMESEXW();
1100
1101         /****************/
1102         /* Function 0x26 */
1103         WERROR netr_DSRGETDCSITECOVERAGEW();
1104
1105         /****************/
1106         /* Function 0x27 */
1107         NTSTATUS netr_LogonSamLogonEx(
1108                 [in] [string,charset(UTF16)] uint16 *server_name,
1109                 [in] [string,charset(UTF16)] uint16 *computer_name,
1110                 [in]  uint16 logon_level,
1111                 [in]  [switch_is(logon_level)] netr_LogonLevel logon,
1112                 [in]  uint16 validation_level,
1113                 [out] [switch_is(validation_level)] netr_Validation validation,
1114                 [out] uint8 authoritative,
1115                 [in,out] uint32 flags
1116                 );
1117
1118         /****************/
1119         /* Function 0x28 */
1120
1121         typedef [bitmap32bit] bitmap {
1122                 NETR_TRUST_FLAG_IN_FOREST = 0x00000001,
1123                 NETR_TRUST_FLAG_OUTBOUND  = 0x00000002,
1124                 NETR_TRUST_FLAG_TREEROOT  = 0x00000004,
1125                 NETR_TRUST_FLAG_PRIMARY   = 0x00000008,
1126                 NETR_TRUST_FLAG_NATIVE    = 0x00000010,
1127                 NETR_TRUST_FLAG_INBOUND   = 0x00000020
1128         } netr_TrustFlags;
1129
1130         typedef [v1_enum] enum {
1131                 NETR_TRUST_TYPE_DOWNLEVEL       = 1,
1132                 NETR_TRUST_TYPE_UPLEVEL         = 2,
1133                 NETR_TRUST_TYPE_MIT             = 3,
1134                 NETR_TRUST_TYPE_DCE             = 4
1135         } netr_TrustType;
1136
1137         typedef [bitmap32bit] bitmap {
1138                 NETR_TRUST_ATTRIBUTE_NON_TRANSITIVE     = 0x00000001,
1139                 NETR_TRUST_ATTRIBUTE_UPLEVEL_ONLY       = 0x00000002,
1140                 NETR_TRUST_ATTRIBUTE_QUARANTINED_DOMAIN = 0x00000004,
1141                 NETR_TRUST_ATTRIBUTE_FOREST_TRANSITIVE  = 0x00000008,
1142                 NETR_TRUST_ATTRIBUTE_CROSS_ORGANIZATION = 0x00000010,
1143                 NETR_TRUST_ATTRIBUTE_WITHIN_FOREST      = 0x00000020,
1144                 NETR_TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL  = 0x00000040
1145         } netr_TrustAttributes;
1146
1147         typedef struct {
1148                 [string,charset(UTF16)] uint16                  *netbios_name;
1149                 [string,charset(UTF16)] uint16                  *dns_name;
1150                 netr_TrustFlags         trust_flags;
1151                 uint32                  parent_index;
1152                 netr_TrustType          trust_type;
1153                 netr_TrustAttributes    trust_attributes;
1154                 dom_sid2                *sid;
1155                 GUID                    guid;
1156         } netr_DomainTrust;
1157
1158         WERROR netr_DsrEnumerateDomainTrusts(
1159                 [in]                 [string,charset(UTF16)] uint16           *server_name,
1160                 [in]                 netr_TrustFlags  trust_flags,
1161                 [out]                uint32           count,
1162                 [out,size_is(count)] netr_DomainTrust *trusts
1163                 );
1164
1165
1166         /****************/
1167         /* Function 0x29 */
1168         WERROR netr_DSRDEREGISTERDNSHOSTRECORDS();
1169
1170         /****************/
1171         /* Function 0x2a */
1172         WERROR netr_NETRSERVERTRUSTPASSWORDSGET();
1173
1174         /****************/
1175         /* Function 0x2b */
1176         WERROR netr_DSRGETFORESTTRUSTINFORMATION();
1177
1178         /****************/
1179         /* Function 0x2c */
1180         WERROR netr_NETRGETFORESTTRUSTINFORMATION();
1181
1182         /****************/
1183         /* Function 0x2d */
1184
1185         /* this is the ADS varient. I don't yet know what the "flags" are for */
1186         NTSTATUS netr_LogonSamLogonWithFlags(
1187                 [in] [string,charset(UTF16)] uint16 *server_name,
1188                 [in] [string,charset(UTF16)] uint16 *computer_name,
1189                 [in] netr_Authenticator *credential,
1190                 [in][out] netr_Authenticator *return_authenticator,
1191                 [in]  uint16 logon_level,
1192                 [in]  [switch_is(logon_level)] netr_LogonLevel logon,
1193                 [in]  uint16 validation_level,
1194                 [out] [switch_is(validation_level)] netr_Validation validation,
1195                 [out] uint8 authoritative,
1196                 [in,out] uint32 flags
1197                 );
1198
1199         /****************/
1200         /* Function 0x2e */
1201         WERROR netr_NETRSERVERGETTRUSTINFO();
1202 }