NETLOGON pipe improvements
[ira/wip.git] / 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 import "misc.idl", "lsa.idl", "samr.idl", "security.idl", "nbt.idl";
8
9 #include "idl_types.h"
10
11 cpp_quote("#define netr_DeltaEnum8Bit netr_DeltaEnum")
12 cpp_quote("#define netr_SamDatabaseID8Bit netr_SamDatabaseID")
13
14 [
15   uuid("12345678-1234-abcd-ef00-01234567cffb"),
16   version(1.0),
17   endpoint("ncacn_np:[\\pipe\\netlogon]","ncacn_ip_tcp:","ncalrpc:"),
18   helper("../librpc/ndr/ndr_netlogon.h"),
19   pointer_default(unique)
20 ]
21
22 interface netlogon
23 {
24         typedef bitmap samr_AcctFlags samr_AcctFlags;
25         typedef bitmap samr_GroupAttrs samr_GroupAttrs;
26         typedef enum netr_DeltaEnum8Bit netr_DeltaEnum8Bit;
27         typedef enum netr_SamDatabaseID8Bit netr_SamDatabaseID8Bit;
28
29         /*****************/
30         /* Function 0x00 */
31
32         typedef struct {
33                 [string,charset(UTF16)] uint16 *account_name;
34                 uint32 priv;
35                 uint32 auth_flags;
36                 uint32 logon_count;
37                 uint32 bad_pw_count;
38                 time_t last_logon;
39                 time_t last_logoff;
40                 time_t logoff_time;
41                 time_t kickoff_time;
42                 uint32 password_age;
43                 time_t pw_can_change;
44                 time_t pw_must_change;
45                 [string,charset(UTF16)] uint16 *computer;
46                 [string,charset(UTF16)] uint16 *domain;
47                 [string,charset(UTF16)] uint16 *script_path;
48                 uint32 unknown;
49         } netr_UasInfo;
50
51         WERROR netr_LogonUasLogon(
52                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
53                 [in]   [string,charset(UTF16)] uint16 account_name[],
54                 [in]   [string,charset(UTF16)] uint16 workstation[],
55                 [out,ref]  netr_UasInfo **info
56                 );
57
58
59         /*****************/
60         /* Function 0x01 */
61
62         typedef struct {
63                 uint32 duration;
64                 uint16 logon_count;
65         } netr_UasLogoffInfo;
66
67         WERROR netr_LogonUasLogoff(
68                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
69                 [in] [string,charset(UTF16)] uint16 account_name[],
70                 [in] [string,charset(UTF16)] uint16 workstation[],
71                 [out,ref] netr_UasLogoffInfo *info
72                 );
73
74
75         /*****************/
76         /* Function 0x02 */
77
78         /* in netr_AcctLockStr size seems to be be 24, and rrenard thinks 
79            that the structure of the bindata looks like this:
80
81                 dlong  lockout_duration;
82                 udlong reset_count;
83                 uint32 bad_attempt_lockout;
84                 uint32 dummy;   
85
86            but it doesn't look as though this structure is reflected at the
87            NDR level. Maybe it is left to the application to decode the bindata array.
88         */
89         typedef [public] struct {
90                 dlong lockout_duration;
91                 udlong reset_count;
92                 uint32 bad_attempt_lockout;
93                 uint32 dummy;
94         } netr_AcctLockStr;
95
96         /* - MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT
97          *   sets the NETLOGON_SERVER_TRUST_ACCOUNT user_flag
98          * - MSV1_0_UPDATE_LOGON_STATISTICS
99          *   sets the logon time on network logon
100          * - MSV1_0_RETURN_USER_PARAMETERS
101          *   sets the user parameters in the driveletter
102          * - MSV1_0_RETURN_PROFILE_PATH
103          *   returns the profilepath in the driveletter and
104          *   sets LOGON_PROFILE_PATH_RETURNED user_flag
105          */
106
107         typedef [public,bitmap32bit] bitmap {
108                 MSV1_0_CLEARTEXT_PASSWORD_ALLOWED       = 0x00000002,
109                 MSV1_0_UPDATE_LOGON_STATISTICS          = 0x00000004,
110                 MSV1_0_RETURN_USER_PARAMETERS           = 0x00000008,
111                 MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT       = 0x00000020,
112                 MSV1_0_RETURN_PROFILE_PATH              = 0x00000200,
113                 MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT  = 0x00000800
114         } netr_LogonParameterControl;
115
116         typedef struct {
117                 lsa_String  domain_name;
118                 netr_LogonParameterControl parameter_control; /* see MSV1_0_* */
119                 uint32      logon_id_low;
120                 uint32      logon_id_high;
121                 lsa_String  account_name;
122                 lsa_String  workstation;
123         } netr_IdentityInfo;
124
125         typedef struct {
126                 netr_IdentityInfo identity_info;
127                 samr_Password lmpassword;
128                 samr_Password ntpassword;
129         } netr_PasswordInfo;
130
131         typedef [flag(NDR_PAHEX)] struct {
132                 uint16 length;
133                 [value(length)] uint16 size;
134                 [size_is(length),length_is(length)] uint8 *data;
135         } netr_ChallengeResponse;
136
137         typedef [flag(NDR_PAHEX)] struct {
138                 netr_IdentityInfo identity_info;
139                 uint8 challenge[8];
140                 netr_ChallengeResponse nt;
141                 netr_ChallengeResponse lm;
142         } netr_NetworkInfo;
143
144         typedef [flag(NDR_PAHEX)] struct {
145                 netr_IdentityInfo identity_info;
146                 lsa_String  package_name;
147                 uint32 length;
148                 [size_is(length)] uint8 *data;
149         } netr_GenericInfo;
150
151         typedef enum {
152                 NetlogonInteractiveInformation = 1,
153                 NetlogonNetworkInformation = 2,
154                 NetlogonServiceInformation = 3,
155                 NetlogonGenericInformation = 4,
156                 NetlogonInteractiveTransitiveInformation = 5,
157                 NetlogonNetworkTransitiveInformation = 6,
158                 NetlogonServiceTransitiveInformation = 7
159         } netr_LogonInfoClass;
160
161         typedef [public,switch_type(netr_LogonInfoClass)] union {
162                 [case(NetlogonInteractiveInformation)]           netr_PasswordInfo *password;
163                 [case(NetlogonNetworkInformation)]               netr_NetworkInfo  *network;
164                 [case(NetlogonServiceInformation)]               netr_PasswordInfo *password;
165                 [case(NetlogonGenericInformation)]               netr_GenericInfo  *generic;
166                 [case(NetlogonInteractiveTransitiveInformation)] netr_PasswordInfo *password;
167                 [case(NetlogonNetworkTransitiveInformation)]     netr_NetworkInfo  *network;
168                 [case(NetlogonServiceTransitiveInformation)]     netr_PasswordInfo *password;
169         } netr_LogonLevel;
170
171         typedef [public,flag(NDR_PAHEX)] struct {
172                 uint8 key[16];
173         } netr_UserSessionKey;
174
175         typedef [public,flag(NDR_PAHEX)] struct {
176                 uint8 key[8];
177         } netr_LMSessionKey;
178
179         /* Flags for user_flags below */
180         typedef [public,bitmap32bit] bitmap {
181                 NETLOGON_GUEST                  = 0x00000001,
182                 NETLOGON_NOENCRYPTION           = 0x00000002,
183                 NETLOGON_CACHED_ACCOUNT         = 0x00000004,
184                 NETLOGON_USED_LM_PASSWORD       = 0x00000008,
185                 NETLOGON_EXTRA_SIDS             = 0x00000020,
186                 NETLOGON_SUBAUTH_SESSION_KEY    = 0x00000040,
187                 NETLOGON_SERVER_TRUST_ACCOUNT   = 0x00000080,
188                 NETLOGON_NTLMV2_ENABLED         = 0x00000100,
189                 NETLOGON_RESOURCE_GROUPS        = 0x00000200,
190                 NETLOGON_PROFILE_PATH_RETURNED  = 0x00000400,
191                 NETLOGON_GRACE_LOGON            = 0x01000000
192         } netr_UserFlags;
193
194         typedef struct {
195                 NTTIME last_logon;
196                 NTTIME last_logoff;
197                 NTTIME acct_expiry;
198                 NTTIME last_password_change;
199                 NTTIME allow_password_change;
200                 NTTIME force_password_change;
201                 lsa_String account_name;
202                 lsa_String full_name;
203                 lsa_String logon_script;
204                 lsa_String profile_path;
205                 lsa_String home_directory;
206                 lsa_String home_drive;
207                 uint16 logon_count;
208                 uint16 bad_password_count;
209                 uint32 rid;
210                 uint32 primary_gid;
211                 samr_RidWithAttributeArray groups;
212                 netr_UserFlags user_flags;
213                 netr_UserSessionKey key;
214                 lsa_StringLarge logon_server;
215                 lsa_StringLarge domain;
216                 dom_sid2 *domain_sid;
217                 netr_LMSessionKey LMSessKey;
218                 samr_AcctFlags acct_flags;
219                 uint32 unknown[7];
220         } netr_SamBaseInfo;
221
222         typedef struct {
223                 netr_SamBaseInfo base;
224         } netr_SamInfo2;
225
226         typedef struct {
227                 dom_sid2 *sid;
228                 samr_GroupAttrs attributes;
229         } netr_SidAttr;
230
231         typedef [public] struct {
232                 netr_SamBaseInfo base;
233                 uint32 sidcount;
234                 [size_is(sidcount)] netr_SidAttr *sids;
235         } netr_SamInfo3;
236
237         typedef struct {
238                 netr_SamBaseInfo base;
239                 uint32 sidcount;
240                 [size_is(sidcount)] netr_SidAttr *sids;
241                 lsa_String forest;
242                 lsa_String principle;
243                 uint32 unknown4[20];
244         } netr_SamInfo6;
245
246         typedef struct {
247                 uint32 pac_size;
248                 [size_is(pac_size)] uint8 *pac;
249                 lsa_String logon_domain;
250                 lsa_String logon_server;
251                 lsa_String principal_name;
252                 uint32 auth_size;
253                 [size_is(auth_size)] uint8 *auth;
254                 netr_UserSessionKey user_session_key;
255                 uint32 expansionroom[10];
256                 lsa_String unknown1;
257                 lsa_String unknown2;
258                 lsa_String unknown3;
259                 lsa_String unknown4;
260         } netr_PacInfo;
261
262         typedef [flag(NDR_PAHEX)] struct {
263                 uint32 length;
264                 [size_is(length)] uint8 *data;
265         } netr_GenericInfo2;
266
267         typedef enum {
268                 NetlogonValidationUasInfo = 1,
269                 NetlogonValidationSamInfo = 2,
270                 NetlogonValidationSamInfo2 = 3,
271                 NetlogonValidationGenericInfo2 = 5,
272                 NetlogonValidationSamInfo4 = 6
273         } netr_ValidationInfoClass;
274
275         typedef [public,switch_type(uint16)] union {
276                 [case(NetlogonValidationSamInfo)] netr_SamInfo2 *sam2;
277                 [case(NetlogonValidationSamInfo2)] netr_SamInfo3 *sam3;
278                 [case(4)] netr_PacInfo  *pac;
279                 [case(NetlogonValidationGenericInfo2)] netr_GenericInfo2  *generic;
280                 [case(NetlogonValidationSamInfo4)] netr_SamInfo6 *sam6;
281         } netr_Validation;
282
283         typedef [public, flag(NDR_PAHEX)] struct {
284                 uint8 data[8];
285         } netr_Credential;
286
287         typedef [public] struct {
288                 netr_Credential cred;
289                 time_t timestamp;
290         } netr_Authenticator;
291
292         NTSTATUS netr_LogonSamLogon(
293                 [in,unique] [string,charset(UTF16)] uint16         *server_name,
294                 [in,unique] [string,charset(UTF16)] uint16         *computer_name,
295                 [in,unique] netr_Authenticator                     *credential,
296                 [in,out,unique] netr_Authenticator                 *return_authenticator,
297                 [in]  netr_LogonInfoClass                           logon_level,
298                 [in,ref]  [switch_is(logon_level)] netr_LogonLevel *logon,
299                 [in]  uint16                                        validation_level,
300                 [out,ref] [switch_is(validation_level)] netr_Validation *validation,
301                 [out,ref] uint8                                    *authoritative
302                 );
303
304
305         /*****************/
306         /* Function 0x03 */
307
308         NTSTATUS netr_LogonSamLogoff(
309                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
310                 [in,unique] [string,charset(UTF16)] uint16 *computer_name,
311                 [in,unique] netr_Authenticator *credential,
312                 [in,out,unique] netr_Authenticator *return_authenticator,
313                 [in] netr_LogonInfoClass logon_level,
314                 [in] [switch_is(logon_level)] netr_LogonLevel logon
315                 );
316         
317
318
319         /*****************/
320         /* Function 0x04 */
321
322         [public] NTSTATUS netr_ServerReqChallenge(
323                 [in,unique,string,charset(UTF16)] uint16 *server_name,
324                 [in,string,charset(UTF16)] uint16 computer_name[],
325                 [in,ref] netr_Credential *credentials,
326                 [out,ref] netr_Credential *return_credentials
327                 );
328
329
330         /*****************/
331         /* Function 0x05 */
332
333         typedef enum netr_SchannelType netr_SchannelType;
334
335         NTSTATUS netr_ServerAuthenticate(
336                 [in,unique,string,charset(UTF16)] uint16 *server_name,
337                 [in,string,charset(UTF16)] uint16 account_name[],
338                 [in]                       netr_SchannelType secure_channel_type,
339                 [in,string,charset(UTF16)] uint16 computer_name[],
340                 [in,ref] netr_Credential *credentials,
341                 [out,ref] netr_Credential *return_credentials
342                 );
343
344
345         /*****************/
346         /* Function 0x06 */
347
348         NTSTATUS netr_ServerPasswordSet(
349                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
350                 [in]  [string,charset(UTF16)] uint16 account_name[],
351                 [in]  netr_SchannelType secure_channel_type,
352                 [in]  [string,charset(UTF16)] uint16 computer_name[],
353                 [in,ref]  netr_Authenticator *credential,
354                 [out,ref] netr_Authenticator *return_authenticator,
355                 [in,ref] samr_Password *new_password
356                 );
357
358
359         /*****************/
360         /* Function 0x07 */
361
362         typedef enum netr_SamDatabaseID netr_SamDatabaseID;
363
364         typedef struct {
365                 [string,charset(UTF16)] uint16 *account_name;
366                 lsa_String unknown1;
367                 lsa_String unknown2;
368                 lsa_String unknown3;
369                 lsa_String unknown4;
370                 uint32 unknown5;
371                 uint32 unknown6;
372                 uint32 unknown7;
373                 uint32 unknown8;
374         } netr_DELTA_DELETE_USER;
375
376         typedef struct {
377                 uint16 length;
378                 [value(length)] uint16 size;
379                 uint32 flags;
380                 samr_Password pwd;
381         } netr_USER_KEY16;
382
383         typedef struct {
384                 uint16 nt_length;
385                 [value(nt_length)] uint16 nt_size;
386                 uint32 nt_flags;
387                 uint16 lm_length;
388                 [value(lm_length)] uint16 lm_size;
389                 uint32 lm_flags;
390                 uint8 nt_history[nt_length];
391                 uint8 lm_history[lm_length];
392         } netr_PasswordHistory;
393
394         typedef struct {
395                 netr_USER_KEY16 lmpassword;
396                 netr_USER_KEY16 ntpassword;
397                 netr_PasswordHistory history;
398         } netr_USER_KEYS2;
399
400         typedef struct { /* TODO: make this a union! */
401                 netr_USER_KEYS2 keys2;
402         } netr_USER_KEY_UNION;
403
404         typedef [public] struct {
405                 uint32 version;
406                 netr_USER_KEY_UNION keys;
407         } netr_USER_KEYS;
408
409         typedef struct {
410                 boolean8  SensitiveDataFlag;
411                 uint32 DataLength;
412
413                 /* netr_USER_KEYS encrypted with the session key */
414                 [size_is(DataLength)][flag(NDR_PAHEX)] uint8 *SensitiveData;
415         } netr_USER_PRIVATE_INFO;
416
417         typedef struct {
418                 lsa_String account_name;
419                 lsa_String full_name;
420                 uint32 rid;
421                 uint32 primary_gid;
422                 lsa_String home_directory;
423                 lsa_String home_drive;
424                 lsa_String logon_script;
425                 lsa_String description;
426                 lsa_String workstations;
427                 NTTIME last_logon;
428                 NTTIME last_logoff;
429                 samr_LogonHours logon_hours;
430                 uint16 bad_password_count;
431                 uint16 logon_count;
432                 NTTIME last_password_change;
433                 NTTIME acct_expiry;
434                 samr_AcctFlags acct_flags;
435                 samr_Password lmpassword;
436                 samr_Password ntpassword;
437                 boolean8 nt_password_present;
438                 boolean8 lm_password_present;
439                 boolean8 password_expired;
440                 lsa_String comment;
441                 lsa_BinaryString parameters;
442                 uint16 country_code;
443                 uint16 code_page;
444                 netr_USER_PRIVATE_INFO user_private_info;
445                 uint32 SecurityInformation;
446                 sec_desc_buf sdbuf;
447                 lsa_String profile_path;
448                 lsa_String unknown2;
449                 lsa_String unknown3;
450                 lsa_String unknown4;
451                 uint32 unknown5;
452                 uint32 unknown6;
453                 uint32 unknown7;
454                 uint32 unknown8;
455         } netr_DELTA_USER;
456
457         typedef struct {
458                 lsa_String domain_name;
459                 lsa_String oem_information; /* comment */
460                 dlong force_logoff_time;
461                 uint16 min_password_length;
462                 uint16 password_history_length;
463                 /* yes, these are signed. They are in negative 100ns */
464                 dlong  max_password_age;
465                 dlong  min_password_age;
466                 udlong sequence_num;
467                 NTTIME domain_create_time;
468                 uint32 SecurityInformation;
469                 sec_desc_buf sdbuf;
470                 lsa_BinaryString account_lockout;
471                 lsa_String unknown2;
472                 lsa_String unknown3;
473                 lsa_String unknown4;
474                 uint32 logon_to_chgpass;
475                 uint32 unknown6;
476                 uint32 unknown7;
477                 uint32 unknown8;
478         } netr_DELTA_DOMAIN;
479
480         typedef struct {
481                 lsa_String group_name;
482                 uint32 rid;
483                 uint32 attributes;
484                 lsa_String description;
485                 uint32 SecurityInformation;
486                 sec_desc_buf sdbuf;
487                 lsa_String unknown1;
488                 lsa_String unknown2;
489                 lsa_String unknown3;
490                 lsa_String unknown4;
491                 uint32 unknown5;
492                 uint32 unknown6;
493                 uint32 unknown7;
494                 uint32 unknown8;
495         } netr_DELTA_GROUP;
496
497         typedef struct {
498                 lsa_String OldName;
499                 lsa_String NewName;
500                 lsa_String unknown1;
501                 lsa_String unknown2;
502                 lsa_String unknown3;
503                 lsa_String unknown4;
504                 uint32 unknown5;
505                 uint32 unknown6;
506                 uint32 unknown7;
507                 uint32 unknown8;
508         } netr_DELTA_RENAME;
509
510         typedef struct {
511                 [size_is(num_rids)] uint32 *rids;
512                 [size_is(num_rids)] uint32 *attribs;
513                 uint32 num_rids;
514                 uint32 unknown1;
515                 uint32 unknown2;
516                 uint32 unknown3;
517                 uint32 unknown4;
518         } netr_DELTA_GROUP_MEMBER;
519
520         typedef struct {
521                 lsa_String alias_name;
522                 uint32 rid;
523                 uint32 SecurityInformation;
524                 sec_desc_buf sdbuf;
525                 lsa_String description;
526                 lsa_String unknown2;
527                 lsa_String unknown3;
528                 lsa_String unknown4;
529                 uint32 unknown5;
530                 uint32 unknown6;
531                 uint32 unknown7;
532                 uint32 unknown8;
533         } netr_DELTA_ALIAS;
534
535         typedef struct {
536                 lsa_SidArray sids;
537                 uint32 unknown1;
538                 uint32 unknown2;
539                 uint32 unknown3;
540                 uint32 unknown4;
541         } netr_DELTA_ALIAS_MEMBER;
542
543         typedef struct {
544                 uint32 pagedpoollimit;
545                 uint32 nonpagedpoollimit;
546                 uint32 minimumworkingsetsize;
547                 uint32 maximumworkingsetsize;
548                 uint32 pagefilelimit;
549                 NTTIME timelimit;
550         } netr_QUOTA_LIMITS;
551
552         typedef struct {
553                 uint32 maxlogsize;
554                 NTTIME auditretentionperiod;
555                 boolean8 auditingmode;
556                 uint32 maxauditeventcount;
557                 [size_is(maxauditeventcount+1)] uint32 *eventauditoptions;
558                 lsa_String primary_domain_name;
559                 dom_sid2 *sid;
560                 netr_QUOTA_LIMITS quota_limits;
561                 udlong sequence_num;
562                 NTTIME db_create_time;
563                 uint32 SecurityInformation;
564                 sec_desc_buf sdbuf;
565                 lsa_String unknown1;
566                 lsa_String unknown2;
567                 lsa_String unknown3;
568                 lsa_String unknown4;
569                 uint32 unknown5;
570                 uint32 unknown6;
571                 uint32 unknown7;
572                 uint32 unknown8;
573         } netr_DELTA_POLICY;
574
575         typedef struct {
576                 lsa_String domain_name;
577                 uint32 num_controllers;
578                 [size_is(num_controllers)] lsa_String *controller_names;
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 posix_offset;
586                 uint32 unknown6;
587                 uint32 unknown7;
588                 uint32 unknown8;
589         } netr_DELTA_TRUSTED_DOMAIN;
590
591         typedef struct {
592                 uint16 unknown;
593         } netr_DELTA_DELETE_TRUST;
594
595         typedef struct {
596                 uint32 privilege_entries;
597                 uint32 privilege_control;
598                 [size_is(privilege_entries)] uint32 *privilege_attrib;
599                 [size_is(privilege_entries)] lsa_String *privilege_name;
600                 netr_QUOTA_LIMITS quotalimits;
601                 uint32 system_flags;
602                 uint32 SecurityInformation;
603                 sec_desc_buf sdbuf;
604                 lsa_String unknown1;
605                 lsa_String unknown2;
606                 lsa_String unknown3;
607                 lsa_String unknown4;
608                 uint32 unknown5;
609                 uint32 unknown6;
610                 uint32 unknown7;
611                 uint32 unknown8;
612         } netr_DELTA_ACCOUNT;
613
614         typedef struct {
615                 uint16 unknown;
616         } netr_DELTA_DELETE_ACCOUNT;
617
618         typedef struct {
619                 uint16 unknown;
620         } netr_DELTA_DELETE_SECRET;
621
622         typedef struct {
623                 uint32 len;
624                 uint32 maxlen;
625                 [size_is(maxlen)][length_is(len)] uint8 *cipher_data;
626         } netr_CIPHER_VALUE;
627
628         typedef struct {
629                 netr_CIPHER_VALUE current_cipher;
630                 NTTIME current_cipher_set_time;
631                 netr_CIPHER_VALUE old_cipher;
632                 NTTIME old_cipher_set_time;
633                 uint32 SecurityInformation;
634                 sec_desc_buf sdbuf;
635                 lsa_String unknown1;
636                 lsa_String unknown2;
637                 lsa_String unknown3;
638                 lsa_String unknown4;
639                 uint32 unknown5;
640                 uint32 unknown6;
641                 uint32 unknown7;
642                 uint32 unknown8;
643         } netr_DELTA_SECRET;
644
645         typedef enum {
646                 NETR_DELTA_DOMAIN           = 1,
647                 NETR_DELTA_GROUP            = 2,
648                 NETR_DELTA_DELETE_GROUP     = 3,
649                 NETR_DELTA_RENAME_GROUP     = 4,
650                 NETR_DELTA_USER             = 5,
651                 NETR_DELTA_DELETE_USER      = 6,
652                 NETR_DELTA_RENAME_USER      = 7,
653                 NETR_DELTA_GROUP_MEMBER     = 8,
654                 NETR_DELTA_ALIAS            = 9,
655                 NETR_DELTA_DELETE_ALIAS     = 10,
656                 NETR_DELTA_RENAME_ALIAS     = 11,
657                 NETR_DELTA_ALIAS_MEMBER     = 12,
658                 NETR_DELTA_POLICY           = 13,
659                 NETR_DELTA_TRUSTED_DOMAIN   = 14,
660                 NETR_DELTA_DELETE_TRUST     = 15,
661                 NETR_DELTA_ACCOUNT          = 16,
662                 NETR_DELTA_DELETE_ACCOUNT   = 17,
663                 NETR_DELTA_SECRET           = 18,
664                 NETR_DELTA_DELETE_SECRET    = 19,
665                 NETR_DELTA_DELETE_GROUP2    = 20,
666                 NETR_DELTA_DELETE_USER2     = 21,
667                 NETR_DELTA_MODIFY_COUNT     = 22
668         } netr_DeltaEnum;
669
670         typedef [switch_type(netr_DeltaEnum)] union {
671                 [case(NETR_DELTA_DOMAIN)]          netr_DELTA_DOMAIN          *domain;
672                 [case(NETR_DELTA_GROUP)]           netr_DELTA_GROUP           *group;
673                 [case(NETR_DELTA_DELETE_GROUP)]    ; /* rid only */
674                 [case(NETR_DELTA_RENAME_GROUP)]    netr_DELTA_RENAME          *rename_group;
675                 [case(NETR_DELTA_USER)]            netr_DELTA_USER            *user;
676                 [case(NETR_DELTA_DELETE_USER)]     ; /* rid only */
677                 [case(NETR_DELTA_RENAME_USER)]     netr_DELTA_RENAME          *rename_user;
678                 [case(NETR_DELTA_GROUP_MEMBER)]    netr_DELTA_GROUP_MEMBER    *group_member;
679                 [case(NETR_DELTA_ALIAS)]           netr_DELTA_ALIAS           *alias;
680                 [case(NETR_DELTA_DELETE_ALIAS)]    ; /* rid only */
681                 [case(NETR_DELTA_RENAME_ALIAS)]    netr_DELTA_RENAME          *rename_alias;
682                 [case(NETR_DELTA_ALIAS_MEMBER)]    netr_DELTA_ALIAS_MEMBER    *alias_member;
683                 [case(NETR_DELTA_POLICY)]          netr_DELTA_POLICY          *policy;
684                 [case(NETR_DELTA_TRUSTED_DOMAIN)]  netr_DELTA_TRUSTED_DOMAIN   *trusted_domain;
685                 [case(NETR_DELTA_DELETE_TRUST)]    netr_DELTA_DELETE_TRUST     delete_trust;
686                 [case(NETR_DELTA_ACCOUNT)]         netr_DELTA_ACCOUNT         *account;
687                 [case(NETR_DELTA_DELETE_ACCOUNT)]  netr_DELTA_DELETE_ACCOUNT   delete_account;
688                 [case(NETR_DELTA_SECRET)]          netr_DELTA_SECRET          *secret;
689                 [case(NETR_DELTA_DELETE_SECRET)]   netr_DELTA_DELETE_SECRET    delete_secret;
690                 [case(NETR_DELTA_DELETE_GROUP2)]   netr_DELTA_DELETE_USER     *delete_group;
691                 [case(NETR_DELTA_DELETE_USER2)]    netr_DELTA_DELETE_USER     *delete_user;
692                 [case(NETR_DELTA_MODIFY_COUNT)]    udlong                     *modified_count;
693         } netr_DELTA_UNION;
694
695         typedef [switch_type(netr_DeltaEnum)] union {
696                 [case(NETR_DELTA_DOMAIN)]          uint32 rid;
697                 [case(NETR_DELTA_GROUP)]           uint32 rid;
698                 [case(NETR_DELTA_DELETE_GROUP)]    uint32 rid;
699                 [case(NETR_DELTA_RENAME_GROUP)]    uint32 rid;
700                 [case(NETR_DELTA_USER)]            uint32 rid;
701                 [case(NETR_DELTA_DELETE_USER)]     uint32 rid;
702                 [case(NETR_DELTA_RENAME_USER)]     uint32 rid;
703                 [case(NETR_DELTA_GROUP_MEMBER)]    uint32 rid;
704                 [case(NETR_DELTA_ALIAS)]           uint32 rid;
705                 [case(NETR_DELTA_DELETE_ALIAS)]    uint32 rid;
706                 [case(NETR_DELTA_RENAME_ALIAS)]    uint32 rid;
707                 [case(NETR_DELTA_ALIAS_MEMBER)]    uint32 rid;
708                 [case(NETR_DELTA_POLICY)]          dom_sid2 *sid;
709                 [case(NETR_DELTA_TRUSTED_DOMAIN)]  dom_sid2 *sid;
710                 [case(NETR_DELTA_DELETE_TRUST)]    dom_sid2 *sid;
711                 [case(NETR_DELTA_ACCOUNT)]         dom_sid2 *sid;
712                 [case(NETR_DELTA_DELETE_ACCOUNT)]  dom_sid2 *sid;
713                 [case(NETR_DELTA_SECRET)]          [string,charset(UTF16)] uint16 *name;
714                 [case(NETR_DELTA_DELETE_SECRET)]   [string,charset(UTF16)] uint16 *name;
715                 [case(NETR_DELTA_DELETE_GROUP2)]   uint32 rid;
716                 [case(NETR_DELTA_DELETE_USER2)]    uint32 rid;
717                 [case(NETR_DELTA_MODIFY_COUNT)]    ;
718         } netr_DELTA_ID_UNION;
719
720         typedef struct {
721                 netr_DeltaEnum delta_type;
722                 [switch_is(delta_type)] netr_DELTA_ID_UNION delta_id_union;
723                 [switch_is(delta_type)] netr_DELTA_UNION delta_union;
724         } netr_DELTA_ENUM;
725
726         typedef struct {
727                 uint32 num_deltas;
728                 [size_is(num_deltas)] netr_DELTA_ENUM *delta_enum;
729         } netr_DELTA_ENUM_ARRAY;
730
731         NTSTATUS netr_DatabaseDeltas(
732                 [in]      [string,charset(UTF16)] uint16 logon_server[],
733                 [in]      [string,charset(UTF16)] uint16 computername[],
734                 [in,ref]  netr_Authenticator *credential,
735                 [in,out,ref]  netr_Authenticator *return_authenticator,
736                 [in]      netr_SamDatabaseID database_id,
737                 [in,out,ref]  udlong *sequence_num,
738                 [out,ref]     netr_DELTA_ENUM_ARRAY **delta_enum_array,
739                 [in]      uint32 preferredmaximumlength
740                 );
741
742
743         /*****************/
744         /* Function 0x08 */
745
746         NTSTATUS netr_DatabaseSync(
747                 [in]     [string,charset(UTF16)] uint16 logon_server[],
748                 [in]     [string,charset(UTF16)] uint16 computername[],
749                 [in,ref] netr_Authenticator *credential,
750                 [in,out,ref] netr_Authenticator *return_authenticator,
751                 [in]     netr_SamDatabaseID database_id,
752                 [in,out,ref] uint32 *sync_context,
753                 [out,ref]    netr_DELTA_ENUM_ARRAY **delta_enum_array,
754                 [in]     uint32 preferredmaximumlength
755                 );
756
757
758         /*****************/
759         /* Function 0x09 */
760
761         /* w2k3 returns NT_STATUS_NOT_IMPLEMENTED for this call */
762
763         typedef [flag(NDR_PAHEX)] struct {
764                 uint8 computer_name[16];
765                 uint32 timecreated;
766                 uint32 serial_number;
767         } netr_UAS_INFO_0;
768
769         typedef struct {
770                 [flag(NDR_REMAINING)] DATA_BLOB blob;
771         } netr_AccountBuffer;
772
773         NTSTATUS netr_AccountDeltas(
774                 [in,unique] [string,charset(UTF16)] uint16 *logon_server,
775                 [in]     [string,charset(UTF16)] uint16 computername[],
776                 [in]     netr_Authenticator credential,
777                 [in,out,ref] netr_Authenticator *return_authenticator,
778                 [in]     netr_UAS_INFO_0 uas,
779                 [in]     uint32 count,
780                 [in]     uint32 level,
781                 [in]     uint32 buffersize,
782                 [out,ref,subcontext(4)] netr_AccountBuffer *buffer,
783                 [out,ref]    uint32 *count_returned,
784                 [out,ref]    uint32 *total_entries,
785                 [out,ref]    netr_UAS_INFO_0 *recordid
786                 );
787
788
789         /*****************/
790         /* Function 0x0A */
791
792         NTSTATUS netr_AccountSync(
793                 [in,unique] [string,charset(UTF16)] uint16 *logon_server,
794                 [in]      [string,charset(UTF16)] uint16 computername[],
795                 [in]      netr_Authenticator credential,
796                 [in,out,ref]  netr_Authenticator *return_authenticator,
797                 [in]      uint32 reference,
798                 [in]      uint32 level,
799                 [in]      uint32 buffersize,
800                 [out,ref,subcontext(4)] netr_AccountBuffer *buffer,
801                 [out,ref]     uint32 *count_returned,
802                 [out,ref]     uint32 *total_entries,
803                 [out,ref]     uint32 *next_reference,
804                 [in,out,ref]  netr_UAS_INFO_0 *recordid
805                 );
806
807
808         /*****************/
809         /* Function 0x0B */
810
811         WERROR netr_GetDcName(
812                 [in]  [string,charset(UTF16)] uint16 logon_server[],
813                 [in,unique] [string,charset(UTF16)] uint16 *domainname,
814                 [out,ref] [string,charset(UTF16)] uint16 **dcname
815                 );
816
817         /*****************/
818         /* Function 0x0C */
819
820         typedef [bitmap32bit] bitmap {
821                 NETLOGON_CTRL_REPL_NEEDED       = 0x0001,
822                 NETLOGON_CTRL_REPL_IN_PROGRESS  = 0x0002,
823                 NETLOGON_CTRL_REPL_FULL_SYNC    = 0x0004
824         } netr_InfoFlags;
825
826         typedef struct {
827                 netr_InfoFlags flags;
828                 uint32 pdc_connection_status;
829         } netr_NETLOGON_INFO_1;
830
831         typedef struct {
832                 netr_InfoFlags flags;
833                 uint32 pdc_connection_status;
834                 [string,charset(UTF16)] uint16 *trusted_dc_name;
835                 uint32 tc_connection_status;
836         } netr_NETLOGON_INFO_2;
837
838         typedef struct {
839                 netr_InfoFlags flags;
840                 uint32 logon_attempts;
841                 uint32 unknown1;
842                 uint32 unknown2;
843                 uint32 unknown3;
844                 uint32 unknown4;
845                 uint32 unknown5;
846         } netr_NETLOGON_INFO_3;
847
848         typedef struct {
849                 [string,charset(UTF16)] uint16 *trusted_dc_name;
850                 [string,charset(UTF16)] uint16 *trusted_domain_name;
851         } netr_NETLOGON_INFO_4;
852
853         typedef union {
854                 [case(1)]  netr_NETLOGON_INFO_1 *info1;
855                 [case(2)]  netr_NETLOGON_INFO_2 *info2;
856                 [case(3)]  netr_NETLOGON_INFO_3 *info3;
857                 [case(4)]  netr_NETLOGON_INFO_4 *info4;
858         } netr_CONTROL_QUERY_INFORMATION;
859
860         /* function_code values */
861         typedef [v1_enum] enum {
862                 NETLOGON_CONTROL_QUERY                  = 0x00000001,
863                 NETLOGON_CONTROL_REPLICATE              = 0x00000002,
864                 NETLOGON_CONTROL_SYNCHRONIZE            = 0x00000003,
865                 NETLOGON_CONTROL_PDC_REPLICATE          = 0x00000004,
866                 NETLOGON_CONTROL_REDISCOVER             = 0x00000005,
867                 NETLOGON_CONTROL_TC_QUERY               = 0x00000006,
868                 NETLOGON_CONTROL_TRANSPORT_NOTIFY       = 0x00000007,
869                 NETLOGON_CONTROL_FIND_USER              = 0x00000008,
870                 NETLOGON_CONTROL_CHANGE_PASSWORD        = 0x00000009,
871                 NETLOGON_CONTROL_TC_VERIFY              = 0x0000000A,
872                 NETLOGON_CONTROL_FORCE_DNS_REG          = 0x0000000B,
873                 NETLOGON_CONTROL_QUERY_DNS_REG          = 0x0000000C,
874                 NETLOGON_CONTROL_BACKUP_CHANGE_LOG      = 0x0000FFFC,
875                 NETLOGON_CONTROL_TRUNCATE_LOG           = 0x0000FFFD,
876                 NETLOGON_CONTROL_SET_DBFLAG             = 0x0000FFFE,
877                 NETLOGON_CONTROL_BREAKPOINT             = 0x0000FFFF
878         } netr_LogonControlCode;
879
880         WERROR netr_LogonControl(
881                 [in,unique] [string,charset(UTF16)] uint16 *logon_server,
882                 [in]   netr_LogonControlCode function_code,
883                 [in]   uint32 level,
884                 [out,ref,switch_is(level)]  netr_CONTROL_QUERY_INFORMATION *query
885                 );
886
887
888         /*****************/
889         /* Function 0x0D */
890
891         WERROR netr_GetAnyDCName(
892                 [in,unique] [string,charset(UTF16)] uint16 *logon_server,
893                 [in,unique] [string,charset(UTF16)] uint16 *domainname,
894                 [out,ref] [string,charset(UTF16)] uint16 **dcname
895                 );
896
897
898         /*****************/
899         /* Function 0x0E */
900
901         typedef union {
902                 [case(NETLOGON_CONTROL_REDISCOVER)]        [string,charset(UTF16)] uint16 *domain;
903                 [case(NETLOGON_CONTROL_TC_QUERY)]          [string,charset(UTF16)] uint16 *domain;
904                 [case(NETLOGON_CONTROL_TRANSPORT_NOTIFY)]  [string,charset(UTF16)] uint16 *domain;
905                 [case(NETLOGON_CONTROL_CHANGE_PASSWORD)]   [string,charset(UTF16)] uint16 *domain;
906                 [case(NETLOGON_CONTROL_TC_VERIFY)]         [string,charset(UTF16)] uint16 *domain;
907                 [case(NETLOGON_CONTROL_FIND_USER)]         [string,charset(UTF16)] uint16 *user;
908                 [case(NETLOGON_CONTROL_SET_DBFLAG)]        uint32 debug_level;
909         } netr_CONTROL_DATA_INFORMATION;
910
911         WERROR netr_LogonControl2(
912                 [in,unique] [string,charset(UTF16)] uint16 *logon_server,
913                 [in]    netr_LogonControlCode function_code,
914                 [in]    uint32 level,
915                 [in,ref][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION  *data,
916                 [out,ref][switch_is(level)]        netr_CONTROL_QUERY_INFORMATION *query
917                 );
918
919
920         /* If NETLOGON_NEG_ARCFOUR flag is not set, then the passwords and LM
921          * session keys are encrypted with DES calls.  (And the user session key
922          * is unencrypted) */
923
924         /*****************/
925         /* Function 0x0F */
926
927         typedef [bitmap32bit] bitmap {
928                 NETLOGON_NEG_ACCOUNT_LOCKOUT            = 0x00000001,
929                 NETLOGON_NEG_PERSISTENT_SAMREPL         = 0x00000002,
930                 NETLOGON_NEG_ARCFOUR                    = 0x00000004,
931                 NETLOGON_NEG_PROMOTION_COUNT            = 0x00000008,
932                 NETLOGON_NEG_CHANGELOG_BDC              = 0x00000010,
933                 NETLOGON_NEG_FULL_SYNC_REPL             = 0x00000020,
934                 NETLOGON_NEG_MULTIPLE_SIDS              = 0x00000040,
935                 NETLOGON_NEG_REDO                       = 0x00000080,
936                 NETLOGON_NEG_PASSWORD_CHANGE_REFUSAL    = 0x00000100,
937                 NETLOGON_NEG_SEND_PASSWORD_INFO_PDC     = 0x00000200,
938                 NETLOGON_NEG_GENERIC_PASSTHROUGH        = 0x00000400,
939                 NETLOGON_NEG_CONCURRENT_RPC             = 0x00000800,
940                 NETLOGON_NEG_AVOID_ACCOUNT_DB_REPL      = 0x00001000,
941                 NETLOGON_NEG_AVOID_SECURITYAUTH_DB_REPL = 0x00002000,
942                 NETLOGON_NEG_STRONG_KEYS                = 0x00004000,
943                 NETLOGON_NEG_TRANSITIVE_TRUSTS          = 0x00008000,
944                 NETLOGON_NEG_DNS_DOMAIN_TRUSTS          = 0x00010000,
945                 NETLOGON_NEG_PASSWORD_SET2              = 0x00020000,
946                 NETLOGON_NEG_GETDOMAININFO              = 0x00040000,
947                 NETLOGON_NEG_CROSS_FOREST_TRUSTS        = 0x00080000,
948                 NETLOGON_NEG_NEUTRALIZE_NT4_EMULATION   = 0x00100000,
949                 NETLOGON_NEG_RODC_PASSTHROUGH           = 0x00200000,
950                 NETLOGON_NEG_SUPPORTS_AES_SHA2          = 0x00400000,
951                 NETLOGON_NEG_AUTHENTICATED_RPC_LSASS    = 0x20000000,
952                 NETLOGON_NEG_AUTHENTICATED_RPC          = 0x40000000
953         } netr_NegotiateFlags;
954
955         const uint32 NETLOGON_NEG_128BIT = NETLOGON_NEG_STRONG_KEYS;
956         const uint32 NETLOGON_NEG_SCHANNEL = NETLOGON_NEG_AUTHENTICATED_RPC;
957
958         NTSTATUS netr_ServerAuthenticate2(
959                 [in,unique]  [string,charset(UTF16)] uint16 *server_name,
960                 [in]         [string,charset(UTF16)] uint16 account_name[],
961                 [in]         netr_SchannelType secure_channel_type,
962                 [in]         [string,charset(UTF16)] uint16 computer_name[],
963                 [in,ref]     netr_Credential *credentials,
964                 [out,ref]    netr_Credential *return_credentials,
965                 [in,out,ref] netr_NegotiateFlags *negotiate_flags
966                 );
967
968
969         /*****************/
970         /* Function 0x10 */
971
972         typedef enum {
973                 SYNCSTATE_NORMAL_STATE             = 0,
974                 SYNCSTATE_DOMAIN_STATE             = 1,
975                 SYNCSTATE_GROUP_STATE              = 2,
976                 SYNCSTATE_UAS_BUILT_IN_GROUP_STATE = 3,
977                 SYNCSTATE_USER_STATE               = 4,
978                 SYNCSTATE_GROUP_MEMBER_STATE       = 5,
979                 SYNCSTATE_ALIAS_STATE              = 6,
980                 SYNCSTATE_ALIAS_MEMBER_STATE       = 7,
981                 SYNCSTATE_SAM_DONE_STATE           = 8
982         } SyncStateEnum;
983
984         NTSTATUS netr_DatabaseSync2(
985                 [in]     [string,charset(UTF16)] uint16 logon_server[],
986                 [in]     [string,charset(UTF16)] uint16 computername[],
987                 [in,ref] netr_Authenticator *credential,
988                 [in,out,ref] netr_Authenticator *return_authenticator,
989                 [in]     netr_SamDatabaseID database_id,
990                 [in]     SyncStateEnum restart_state,
991                 [in,out,ref] uint32 *sync_context,
992                 [out,ref]    netr_DELTA_ENUM_ARRAY **delta_enum_array,
993                 [in]     uint32 preferredmaximumlength
994                 );
995
996
997         /*****************/
998         /* Function 0x11 */
999
1000         /* i'm not at all sure how this call works */
1001
1002         typedef [bitmap16bit] bitmap {
1003                 NETR_CHANGELOG_IMMEDIATE_REPL_REQUIRED  = 0x0001,
1004                 NETR_CHANGELOG_CHANGED_PASSWORD         = 0x0002,
1005                 NETR_CHANGELOG_SID_INCLUDED             = 0x0004,
1006                 NETR_CHANGELOG_NAME_INCLUDED            = 0x0008,
1007                 NETR_CHANGELOG_FIRST_PROMOTION_OBJ      = 0x0010
1008         } netr_ChangeLogFlags;
1009
1010         typedef [nodiscriminant] union {
1011                 [case(NETR_CHANGELOG_SID_INCLUDED)] dom_sid object_sid;
1012                 [case(NETR_CHANGELOG_NAME_INCLUDED)] nstring object_name;
1013                 [default];
1014         } netr_ChangeLogObject;
1015
1016         typedef [public,gensize] struct {
1017                 uint32 serial_number1;
1018                 uint32 serial_number2;
1019                 uint32 object_rid;
1020                 netr_ChangeLogFlags flags;
1021                 netr_SamDatabaseID8Bit db_index;
1022                 netr_DeltaEnum8Bit delta_type;
1023                 [switch_is(flags & (NETR_CHANGELOG_SID_INCLUDED|NETR_CHANGELOG_NAME_INCLUDED))] netr_ChangeLogObject object;
1024         } netr_ChangeLogEntry;
1025
1026         NTSTATUS netr_DatabaseRedo(
1027                 [in]     [string,charset(UTF16)] uint16 logon_server[],
1028                 [in]     [string,charset(UTF16)] uint16 computername[],
1029                 [in]     netr_Authenticator *credential,
1030                 [in,out,ref] netr_Authenticator *return_authenticator,
1031                 [in]     [subcontext(4),subcontext_size(change_log_entry_size)] netr_ChangeLogEntry change_log_entry,
1032                 [in]     [value(ndr_size_netr_ChangeLogEntry(&change_log_entry, ndr->iconv_convenience, ndr->flags))] uint32 change_log_entry_size,
1033                 [out,ref]    netr_DELTA_ENUM_ARRAY **delta_enum_array
1034                 );
1035
1036
1037         /*****************/
1038         /* Function 0x12 */
1039
1040         WERROR netr_LogonControl2Ex(
1041                 [in,unique] [string,charset(UTF16)] uint16 *logon_server,
1042                 [in]   netr_LogonControlCode function_code,
1043                 [in]   uint32 level,
1044                 [in,ref][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION  *data,
1045                 [out,ref][switch_is(level)]     netr_CONTROL_QUERY_INFORMATION *query
1046                 );
1047
1048         /*****************/
1049         /* Function 0x13 */
1050         typedef struct {
1051                 uint32 length;
1052                 [size_is(length)] uint8 *data;
1053         } netr_Blob;
1054
1055         WERROR netr_NetrEnumerateTrustedDomains(
1056                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1057                 [out,ref] netr_Blob *trusted_domains_blob
1058                 );
1059
1060         /*****************/
1061         /* Function 0x14 */
1062
1063         /* one unkown bit still: DS_IP_VERSION_AGNOSTIC - gd*/
1064
1065         const int DSGETDC_VALID_FLAGS = (DS_FORCE_REDISCOVERY |
1066                                          DS_DIRECTORY_SERVICE_REQUIRED |
1067                                          DS_DIRECTORY_SERVICE_PREFERRED |
1068                                          DS_GC_SERVER_REQUIRED |
1069                                          DS_PDC_REQUIRED |
1070                                          DS_BACKGROUND_ONLY |
1071                                          DS_IP_REQUIRED |
1072                                          DS_KDC_REQUIRED |
1073                                          DS_TIMESERV_REQUIRED |
1074                                          DS_WRITABLE_REQUIRED |
1075                                          DS_GOOD_TIMESERV_PREFERRED |
1076                                          DS_AVOID_SELF |
1077                                          DS_ONLY_LDAP_NEEDED |
1078                                          DS_IS_FLAT_NAME |
1079                                          DS_IS_DNS_NAME |
1080                                          DS_RETURN_FLAT_NAME |
1081                                          DS_RETURN_DNS_NAME);
1082
1083         typedef [bitmap32bit] bitmap {
1084                 DS_FORCE_REDISCOVERY            = 0x00000001,
1085                 DS_DIRECTORY_SERVICE_REQUIRED   = 0x00000010,
1086                 DS_DIRECTORY_SERVICE_PREFERRED  = 0x00000020,
1087                 DS_GC_SERVER_REQUIRED           = 0x00000040,
1088                 DS_PDC_REQUIRED                 = 0x00000080,
1089                 DS_BACKGROUND_ONLY              = 0x00000100,
1090                 DS_IP_REQUIRED                  = 0x00000200,
1091                 DS_KDC_REQUIRED                 = 0x00000400,
1092                 DS_TIMESERV_REQUIRED            = 0x00000800,
1093                 DS_WRITABLE_REQUIRED            = 0x00001000,
1094                 DS_GOOD_TIMESERV_PREFERRED      = 0x00002000,
1095                 DS_AVOID_SELF                   = 0x00004000,
1096                 DS_ONLY_LDAP_NEEDED             = 0x00008000,
1097                 DS_IS_FLAT_NAME                 = 0x00010000,
1098                 DS_IS_DNS_NAME                  = 0x00020000,
1099                 DS_TRY_NEXTCLOSEST_SITE         = 0x00040000,
1100                 DS_DIRECTORY_SERVICE_6_REQUIRED = 0x00080000,
1101                 DS_RETURN_DNS_NAME              = 0x40000000,
1102                 DS_RETURN_FLAT_NAME             = 0x80000000
1103         } netr_DsRGetDCName_flags;
1104
1105         typedef [v1_enum] enum {
1106                 DS_ADDRESS_TYPE_INET            = 1,
1107                 DS_ADDRESS_TYPE_NETBIOS         = 2
1108         } netr_DsRGetDCNameInfo_AddressType;
1109
1110         typedef [bitmap32bit] bitmap {
1111                 DS_SERVER_PDC                    = NBT_SERVER_PDC,
1112                 DS_SERVER_GC                     = NBT_SERVER_GC,
1113                 DS_SERVER_LDAP                   = NBT_SERVER_LDAP,
1114                 DS_SERVER_DS                     = NBT_SERVER_DS,
1115                 DS_SERVER_KDC                    = NBT_SERVER_KDC,
1116                 DS_SERVER_TIMESERV               = NBT_SERVER_TIMESERV,
1117                 DS_SERVER_CLOSEST                = NBT_SERVER_CLOSEST,
1118                 DS_SERVER_WRITABLE               = NBT_SERVER_WRITABLE,
1119                 DS_SERVER_GOOD_TIMESERV          = NBT_SERVER_GOOD_TIMESERV,
1120                 DS_SERVER_NDNC                   = NBT_SERVER_NDNC,
1121                 DS_SERVER_SELECT_SECRET_DOMAIN_6 = NBT_SERVER_SELECT_SECRET_DOMAIN_6,
1122                 DS_SERVER_FULL_SECRET_DOMAIN_6   = NBT_SERVER_FULL_SECRET_DOMAIN_6,
1123                 DS_DNS_CONTROLLER                = 0x20000000,
1124                 DS_DNS_DOMAIN                    = 0x40000000,
1125                 DS_DNS_FOREST                    = 0x80000000
1126         } netr_DsR_DcFlags;
1127
1128         typedef [public] struct {
1129                 [string,charset(UTF16)] uint16 *dc_unc;
1130                 [string,charset(UTF16)] uint16 *dc_address;
1131                 netr_DsRGetDCNameInfo_AddressType dc_address_type;
1132                 GUID domain_guid;
1133                 [string,charset(UTF16)] uint16 *domain_name;
1134                 [string,charset(UTF16)] uint16 *forest_name;
1135                 netr_DsR_DcFlags dc_flags;
1136                 [string,charset(UTF16)] uint16 *dc_site_name;
1137                 [string,charset(UTF16)] uint16 *client_site_name;
1138         } netr_DsRGetDCNameInfo;
1139
1140         WERROR netr_DsRGetDCName(
1141                 [in,unique] [string,charset(UTF16)] uint16 *server_unc,
1142                 [in,unique] [string,charset(UTF16)] uint16 *domain_name,
1143                 [in,unique] GUID *domain_guid,
1144                 [in,unique] GUID *site_guid,
1145                 [in] netr_DsRGetDCName_flags flags,
1146                 [out,ref] netr_DsRGetDCNameInfo **info
1147                 );
1148
1149         /*****************/
1150         /* Function 0x15 */
1151         typedef [switch_type(uint32)] union {
1152                 [case(1)] netr_NegotiateFlags server_capabilities;
1153         } netr_Capabilities;
1154
1155         NTSTATUS netr_LogonGetCapabilities(
1156                 [in]         [string,charset(UTF16)] uint16 server_name[],
1157                 [in,unique]  [string,charset(UTF16)] uint16 *computer_name,
1158                 [in,ref]     netr_Authenticator *credential,
1159                 [in,out,ref] netr_Authenticator *return_authenticator,
1160                 [in]         uint32 query_level,
1161                 [out,ref,switch_is(query_level)] netr_Capabilities *capabilities
1162                 );
1163
1164         /****************/
1165         /* Function 0x16 */
1166         [todo] WERROR netr_NETRLOGONSETSERVICEBITS();
1167
1168         /****************/
1169         /* Function 0x17 */
1170         WERROR netr_LogonGetTrustRid(
1171                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1172                 [in,unique] [string,charset(UTF16)] uint16 *domain_name,
1173                 [out,ref] uint32 *rid
1174         );
1175
1176         /****************/
1177         /* Function 0x18 */
1178         [todo] WERROR netr_NETRLOGONCOMPUTESERVERDIGEST();
1179
1180         /****************/
1181         /* Function 0x19 */
1182         [todo] WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST();
1183
1184         /****************/
1185         /* Function 0x1a */
1186         [public] NTSTATUS netr_ServerAuthenticate3(
1187                 [in,unique]  [string,charset(UTF16)] uint16 *server_name,
1188                 [in]         [string,charset(UTF16)] uint16 account_name[],
1189                 [in]         netr_SchannelType secure_channel_type,
1190                 [in]         [string,charset(UTF16)] uint16 computer_name[],
1191                 [in,ref]     netr_Credential *credentials,
1192                 [out,ref]    netr_Credential *return_credentials,
1193                 [in,out,ref] netr_NegotiateFlags *negotiate_flags,
1194                 [out,ref]    uint32 *rid
1195                 );
1196
1197         /****************/
1198         /* Function 0x1b */
1199
1200         WERROR netr_DsRGetDCNameEx(
1201                 [in,unique] [string,charset(UTF16)] uint16 *server_unc,
1202                 [in,unique] [string,charset(UTF16)] uint16 *domain_name,
1203                 [in,unique] GUID *domain_guid,
1204                 [in,unique] [string,charset(UTF16)] uint16 *site_name,
1205                 [in] netr_DsRGetDCName_flags flags,
1206                 [out,ref] netr_DsRGetDCNameInfo **info
1207                 );
1208
1209
1210         /****************/
1211         /* Function 0x1c */
1212         WERROR netr_DsRGetSiteName(
1213                 [in,unique] [string,charset(UTF16)] uint16 *computer_name,
1214                 [out,ref] [string,charset(UTF16)] uint16 **site
1215                 );
1216
1217         /****************/
1218         /* Function 0x1d */
1219         typedef [bitmap32bit] bitmap {
1220                 NETR_TRUST_FLAG_IN_FOREST = 0x00000001,
1221                 NETR_TRUST_FLAG_OUTBOUND  = 0x00000002,
1222                 NETR_TRUST_FLAG_TREEROOT  = 0x00000004,
1223                 NETR_TRUST_FLAG_PRIMARY   = 0x00000008,
1224                 NETR_TRUST_FLAG_NATIVE    = 0x00000010,
1225                 NETR_TRUST_FLAG_INBOUND   = 0x00000020,
1226                 NETR_TRUST_FLAG_MIT_KRB5  = 0x00000080,
1227                 NETR_TRUST_FLAG_AES       = 0x00000100
1228         } netr_TrustFlags;
1229
1230         typedef struct {
1231                 netr_Blob blob;
1232                 [string,charset(UTF16)] uint16 *workstation_domain;
1233                 [string,charset(UTF16)] uint16 *workstation_site;
1234                 [string,charset(UTF16)] uint16 *unknown1;
1235                 [string,charset(UTF16)] uint16 *unknown2;
1236                 [string,charset(UTF16)] uint16 *unknown3;
1237                 [string,charset(UTF16)] uint16 *unknown4;
1238                 lsa_BinaryString blob2;
1239                 lsa_String product;
1240                 lsa_String unknown5;
1241                 lsa_String unknown6;
1242                 uint32 unknown7[4];
1243         } netr_DomainQuery1;
1244
1245         typedef union {
1246                 [case(1)] netr_DomainQuery1 *query1;
1247                 [case(2)] netr_DomainQuery1 *query1;
1248         } netr_DomainQuery;
1249
1250         typedef struct {
1251                 /* these first 3 values come from the fact windows
1252                    actually encodes this structure as a UNICODE_STRING
1253                    - see MS-NRPC section 2.2.1.3.9 */
1254                 [value(8)] uint32 length;
1255                 [value(0)] uint32 dummy;
1256                 [value(8)] uint32 size;
1257                 netr_TrustFlags flags;
1258                 uint32 parent_index;
1259                 uint32 trust_type;
1260                 uint32 trust_attributes;
1261         } netr_trust_extension;
1262
1263         typedef struct {
1264                 uint16 length; /* value is 16 when info != NULL, otherwise 0 */
1265                 [value(length)] uint16 size;   /* value is 16 when info != NULL, otherwise 0 */
1266                 netr_trust_extension *info;
1267         } netr_trust_extension_container;
1268
1269         typedef struct {
1270                 lsa_String domainname;
1271                 lsa_String fulldomainname;
1272                 lsa_String forest;
1273                 GUID        guid;
1274                 dom_sid2    *sid;
1275                 netr_trust_extension_container trust_extension;
1276                 lsa_String dummystring[3];
1277                 uint32     dummy[4];
1278         } netr_DomainTrustInfo;
1279
1280         typedef struct {
1281                 uint32 policy_size;
1282                 [size_is(policy_size)] uint8 *policy;
1283         } netr_LsaPolicyInfo;
1284
1285         typedef [public,bitmap32bit] bitmap {
1286                 NETR_WS_FLAG_HANDLES_INBOUND_TRUSTS = 0x00000001,
1287                 NETR_WS_FLAG_HANDLES_SPN_UPDATE     = 0x00000002
1288         } netr_WorkstationFlags;
1289
1290         typedef struct {
1291                 netr_DomainTrustInfo domaininfo;
1292                 uint32 num_trusts;
1293                 [size_is(num_trusts)] netr_DomainTrustInfo *trusts;
1294                 netr_LsaPolicyInfo lsa_policy;
1295                 lsa_String dns_hostname;
1296                 lsa_String dummystring[3];
1297                 netr_WorkstationFlags workstation_flags;
1298                 uint32 supported_enc_types;
1299                 uint32 dummy[2];
1300         } netr_DomainInfo1;
1301
1302         typedef union {
1303                 [case(1)] netr_DomainInfo1 *info1;
1304                 [case(2)] netr_DomainInfo1 *info2;
1305         } netr_DomainInfo;
1306         
1307         NTSTATUS netr_LogonGetDomainInfo(
1308                 [in]         [string,charset(UTF16)] uint16 server_name[],
1309                 [in,unique]  [string,charset(UTF16)] uint16 *computer_name,
1310                 [in,ref]     netr_Authenticator *credential,
1311                 [in,out,ref] netr_Authenticator *return_authenticator,
1312                 [in]         uint32 level,
1313                 [in,switch_is(level)] netr_DomainQuery query,
1314                 [out,ref,switch_is(level)] netr_DomainInfo *info
1315                 );
1316
1317         typedef [flag(NDR_PAHEX)] struct {
1318                 uint8 data[512];
1319                 uint32 length;
1320         } netr_CryptPassword;
1321
1322         /*****************/
1323         /* Function 0x1e */
1324         NTSTATUS netr_ServerPasswordSet2(
1325                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1326                 [in]  [string,charset(UTF16)] uint16 account_name[],
1327                 [in]  netr_SchannelType secure_channel_type,
1328                 [in]  [string,charset(UTF16)] uint16 computer_name[],
1329                 [in,ref] netr_Authenticator *credential,
1330                 [out,ref] netr_Authenticator *return_authenticator,
1331                 [in,ref] netr_CryptPassword *new_password
1332                 );
1333
1334         /****************/
1335         /* Function 0x1f */
1336         WERROR netr_ServerPasswordGet(
1337                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1338                 [in]  [string,charset(UTF16)] uint16 account_name[],
1339                 [in]  netr_SchannelType secure_channel_type,
1340                 [in]  [string,charset(UTF16)] uint16 computer_name[],
1341                 [in,ref] netr_Authenticator *credential,
1342                 [out,ref] netr_Authenticator *return_authenticator,
1343                 [out,ref] samr_Password *password
1344                 );
1345
1346         /****************/
1347         /* Function 0x20 */
1348         [todo] WERROR netr_NETRLOGONSENDTOSAM();
1349
1350         /****************/
1351         /* Function 0x21 */
1352         typedef struct {
1353                 uint32 count;
1354                 [size_is(count)] lsa_String *sitename;
1355         } netr_DsRAddressToSitenamesWCtr;
1356
1357         typedef struct {
1358                 [size_is(size)] uint8 *buffer;
1359                 uint32 size;
1360         } netr_DsRAddress;
1361
1362         WERROR netr_DsRAddressToSitenamesW(
1363                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1364                 [in] [range(0,32000)] uint32 count,
1365                 [in] [size_is(count)] [ref] netr_DsRAddress *addresses,
1366                 [out] [ref] netr_DsRAddressToSitenamesWCtr **ctr
1367                 );
1368
1369         /****************/
1370         /* Function 0x22 */
1371         WERROR netr_DsRGetDCNameEx2(
1372                 [in,unique] [string,charset(UTF16)] uint16 *server_unc,
1373                 [in,unique] [string,charset(UTF16)] uint16 *client_account,
1374                 [in] samr_AcctFlags mask,
1375                 [in,unique] [string,charset(UTF16)] uint16 *domain_name,
1376                 [in,unique] GUID *domain_guid,
1377                 [in,unique] [string,charset(UTF16)] uint16 *site_name,
1378                 [in] netr_DsRGetDCName_flags flags,
1379                 [out,ref] netr_DsRGetDCNameInfo **info
1380                 );
1381
1382         /****************/
1383         /* Function 0x23 */
1384         [todo] WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN();
1385
1386         /****************/
1387         /* Function 0x24 */
1388
1389         typedef [v1_enum] enum {
1390                 NETR_TRUST_TYPE_DOWNLEVEL       = 1,
1391                 NETR_TRUST_TYPE_UPLEVEL         = 2,
1392                 NETR_TRUST_TYPE_MIT             = 3,
1393                 NETR_TRUST_TYPE_DCE             = 4
1394         } netr_TrustType;
1395
1396         typedef [bitmap32bit] bitmap {
1397                 NETR_TRUST_ATTRIBUTE_NON_TRANSITIVE     = 0x00000001,
1398                 NETR_TRUST_ATTRIBUTE_UPLEVEL_ONLY       = 0x00000002,
1399                 NETR_TRUST_ATTRIBUTE_QUARANTINED_DOMAIN = 0x00000004,
1400                 NETR_TRUST_ATTRIBUTE_FOREST_TRANSITIVE  = 0x00000008,
1401                 NETR_TRUST_ATTRIBUTE_CROSS_ORGANIZATION = 0x00000010,
1402                 NETR_TRUST_ATTRIBUTE_WITHIN_FOREST      = 0x00000020,
1403                 NETR_TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL  = 0x00000040
1404         } netr_TrustAttributes;
1405
1406         typedef struct {
1407                 [string,charset(UTF16)] uint16                  *netbios_name;
1408                 [string,charset(UTF16)] uint16                  *dns_name;
1409                 netr_TrustFlags         trust_flags;
1410                 uint32                  parent_index;
1411                 netr_TrustType          trust_type;
1412                 netr_TrustAttributes    trust_attributes;
1413                 dom_sid2                *sid;
1414                 GUID                    guid;
1415         } netr_DomainTrust;
1416
1417         typedef struct {
1418                 uint32 count;
1419                 [size_is(count)] netr_DomainTrust *array;
1420         } netr_DomainTrustList;
1421
1422         WERROR netr_NetrEnumerateTrustedDomainsEx(
1423                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1424                 [out,ref] netr_DomainTrustList *dom_trust_list
1425         );
1426
1427         /****************/
1428         /* Function 0x25 */
1429         typedef struct {
1430                 uint32 count;
1431                 [size_is(count)] lsa_String *sitename;
1432                 [size_is(count)] lsa_String *subnetname;
1433         } netr_DsRAddressToSitenamesExWCtr;
1434
1435         WERROR netr_DsRAddressToSitenamesExW(
1436                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1437                 [in] [range(0,32000)] uint32 count,
1438                 [in] [size_is(count)] [ref] netr_DsRAddress *addresses,
1439                 [out] [ref] netr_DsRAddressToSitenamesExWCtr **ctr
1440                 );
1441
1442         /****************/
1443         /* Function 0x26 */
1444
1445         typedef struct {
1446                 uint32 num_sites;
1447                 [size_is(num_sites)] [unique] lsa_String *sites;
1448         } DcSitesCtr;
1449
1450         WERROR netr_DsrGetDcSiteCoverageW(
1451                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1452                 [out,ref] DcSitesCtr **ctr
1453                 );
1454
1455         /****************/
1456         /* Function 0x27 */
1457         NTSTATUS netr_LogonSamLogonEx(
1458                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1459                 [in,unique] [string,charset(UTF16)] uint16 *computer_name,
1460                 [in]  netr_LogonInfoClass logon_level,
1461                 [in,ref]  [switch_is(logon_level)] netr_LogonLevel *logon,
1462                 [in]  uint16 validation_level,
1463                 [out,ref] [switch_is(validation_level)] netr_Validation *validation,
1464                 [out,ref] uint8 *authoritative,
1465                 [in,out,ref] uint32 *flags
1466                 );
1467
1468         /****************/
1469         /* Function 0x28 */
1470
1471         WERROR netr_DsrEnumerateDomainTrusts(
1472                 [in,unique]          [string,charset(UTF16)] uint16           *server_name,
1473                 [in]                 netr_TrustFlags  trust_flags,
1474                 [out,ref]            netr_DomainTrustList *trusts
1475                 );
1476
1477
1478         /****************/
1479         /* Function 0x29 */
1480         WERROR netr_DsrDeregisterDNSHostRecords(
1481                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1482                 [in,unique] [string,charset(UTF16)] uint16 *domain,
1483                 [in,unique] GUID *domain_guid,
1484                 [in,unique] GUID *dsa_guid,
1485                 [in,ref] [string,charset(UTF16)] uint16 *dns_host
1486                 );
1487
1488         /****************/
1489         /* Function 0x2a */
1490         NTSTATUS netr_ServerTrustPasswordsGet(
1491                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1492                 [in]  [string,charset(UTF16)] uint16 account_name[],
1493                 [in]  netr_SchannelType secure_channel_type,
1494                 [in]  [string,charset(UTF16)] uint16 computer_name[],
1495                 [in,ref] netr_Authenticator *credential,
1496                 [out,ref] netr_Authenticator *return_authenticator,
1497                 [out,ref] samr_Password *password,
1498                 [out,ref] samr_Password *password2
1499         );
1500
1501         /****************/
1502         /* Function 0x2b */
1503
1504         const int DS_GFTI_UPDATE_TDO = 0x1;
1505
1506         WERROR netr_DsRGetForestTrustInformation(
1507                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1508                 [in,unique] [string,charset(UTF16)] uint16 *trusted_domain_name,
1509                 [in] uint32 flags,
1510                 [out,ref] lsa_ForestTrustInformation **forest_trust_info
1511                 );
1512
1513         /****************/
1514         /* Function 0x2c */
1515         WERROR netr_GetForestTrustInformation(
1516                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1517                 [in,ref] [string,charset(UTF16)] uint16 *trusted_domain_name,
1518                 [in,ref] netr_Authenticator *credential,
1519                 [out,ref] netr_Authenticator *return_authenticator,
1520                 [in] uint32 flags,
1521                 [out,ref] lsa_ForestTrustInformation **forest_trust_info
1522                 );
1523
1524         /****************/
1525         /* Function 0x2d */
1526
1527         /* this is the ADS varient. I don't yet know what the "flags" are for */
1528         NTSTATUS netr_LogonSamLogonWithFlags(
1529                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1530                 [in,unique] [string,charset(UTF16)] uint16 *computer_name,
1531                 [in,unique] netr_Authenticator *credential,
1532                 [in,out,unique] netr_Authenticator *return_authenticator,
1533                 [in]  netr_LogonInfoClass logon_level,
1534                 [in,ref]  [switch_is(logon_level)] netr_LogonLevel *logon,
1535                 [in]  uint16 validation_level,
1536                 [out,ref] [switch_is(validation_level)] netr_Validation *validation,
1537                 [out,ref] uint8 *authoritative,
1538                 [in,out,ref] uint32 *flags
1539                 );
1540
1541         /****************/
1542         /* Function 0x2e */
1543
1544         typedef struct {
1545                 uint32 count;
1546                 [size_is(count)] uint32 *data;
1547                 uint32 entry_count;
1548                 [size_is(count)] lsa_String *entries;
1549         } netr_TrustInfo;
1550
1551         NTSTATUS netr_ServerGetTrustInfo(
1552                 [in,unique] [string,charset(UTF16)] uint16 *server_name,
1553                 [in,ref] [string,charset(UTF16)] uint16 *account_name,
1554                 [in] netr_SchannelType secure_channel_type,
1555                 [in,ref] [string,charset(UTF16)] uint16 *computer_name,
1556                 [in,ref] netr_Authenticator *credential,
1557                 [out,ref] netr_Authenticator *return_authenticator,
1558                 [out,ref] samr_Password *new_owf_password,
1559                 [out,ref] samr_Password *old_owf_password,
1560                 [out,ref] netr_TrustInfo **trust_info
1561                 );
1562 }