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