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