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