fix a typo
[tprouty/samba.git] / source / include / rpc_netlogon.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup
4    Copyright (C) Andrew Tridgell 1992-1997
5    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
6    Copyright (C) Paul Ashton 1997
7    Copyright (C) Jean François Micouleau 2002
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #ifndef _RPC_NETLOGON_H /* _RPC_NETLOGON_H */
25 #define _RPC_NETLOGON_H 
26
27
28 /* NETLOGON pipe */
29 #define NET_SAMLOGON            0x02
30 #define NET_SAMLOGOFF           0x03
31 #define NET_REQCHAL             0x04
32 #define NET_AUTH                0x05
33 #define NET_SRVPWSET            0x06
34 #define NET_SAM_DELTAS          0x07
35 #define NET_LOGON_CTRL          0x0c
36 #define NET_GETANYDCNAME        0x0d
37 #define NET_AUTH2               0x0f
38 #define NET_LOGON_CTRL2         0x0e
39 #define NET_SAM_SYNC            0x10
40 #define NET_TRUST_DOM_LIST      0x13
41 #define NET_DSR_GETDCNAME       0x14
42 #define NET_AUTH3               0x1a
43 #define NET_DSR_GETDCNAMEEX     0x1b
44 #define NET_DSR_GETSITENAME     0x1c
45 #define NET_DSR_GETDCNAMEEX2    0x22
46 #define NET_SAMLOGON_EX         0x27
47
48 /* Secure Channel types.  used in NetrServerAuthenticate negotiation */
49 #define SEC_CHAN_WKSTA   2
50 #define SEC_CHAN_DOMAIN  4
51 #define SEC_CHAN_BDC     6
52
53 /* Returned delta types */
54 #define SAM_DELTA_DOMAIN_INFO    0x01
55 #define SAM_DELTA_GROUP_INFO     0x02
56 #define SAM_DELTA_RENAME_GROUP   0x04
57 #define SAM_DELTA_ACCOUNT_INFO   0x05
58 #define SAM_DELTA_RENAME_USER    0x07
59 #define SAM_DELTA_GROUP_MEM      0x08
60 #define SAM_DELTA_ALIAS_INFO     0x09
61 #define SAM_DELTA_RENAME_ALIAS   0x0b
62 #define SAM_DELTA_ALIAS_MEM      0x0c
63 #define SAM_DELTA_POLICY_INFO    0x0d
64 #define SAM_DELTA_TRUST_DOMS     0x0e
65 #define SAM_DELTA_PRIVS_INFO     0x10 /* DT_DELTA_ACCOUNTS */
66 #define SAM_DELTA_SECRET_INFO    0x12
67 #define SAM_DELTA_DELETE_GROUP   0x14
68 #define SAM_DELTA_DELETE_USER    0x15
69 #define SAM_DELTA_MODIFIED_COUNT 0x16
70
71 /* SAM database types */
72 #define SAM_DATABASE_DOMAIN    0x00 /* Domain users and groups */
73 #define SAM_DATABASE_BUILTIN   0x01 /* BUILTIN users and groups */
74 #define SAM_DATABASE_PRIVS     0x02 /* Privileges */
75
76 /* flags use when sending a NETLOGON_CONTROL request */
77
78 #define NETLOGON_CONTROL_SYNC                   0x2
79 #define NETLOGON_CONTROL_REDISCOVER             0x5
80 #define NETLOGON_CONTROL_TC_QUERY               0x6
81 #define NETLOGON_CONTROL_TRANSPORT_NOTIFY       0x7
82 #define NETLOGON_CONTROL_SET_DBFLAG             0xfffe
83
84 /* Some flag values reverse engineered from NLTEST.EXE */
85 /* used in the NETLOGON_CONTROL[2] reply */
86
87 #define NL_CTRL_IN_SYNC          0x0000
88 #define NL_CTRL_REPL_NEEDED      0x0001
89 #define NL_CTRL_REPL_IN_PROGRESS 0x0002
90 #define NL_CTRL_FULL_SYNC        0x0004
91
92 #define LOGON_GUEST                     0x00000001
93 #define LOGON_NOENCRYPTION              0x00000002
94 #define LOGON_CACHED_ACCOUNT            0x00000004
95 #define LOGON_USED_LM_PASSWORD          0x00000008
96 #define LOGON_EXTRA_SIDS                0x00000020
97 #define LOGON_SUBAUTH_SESSION_KEY       0x00000040
98 #define LOGON_SERVER_TRUST_ACCOUNT      0x00000080
99 #define LOGON_NTLMV2_ENABLED            0x00000100
100 #define LOGON_RESOURCE_GROUPS           0x00000200
101 #define LOGON_PROFILE_PATH_RETURNED     0x00000400
102 #define LOGON_GRACE_LOGON               0x01000000
103
104 #define SE_GROUP_MANDATORY              0x00000001
105 #define SE_GROUP_ENABLED_BY_DEFAULT     0x00000002
106 #define SE_GROUP_ENABLED                0x00000004
107 #define SE_GROUP_OWNER                  0x00000008
108 #define SE_GROUP_USE_FOR_DENY_ONLY      0x00000010
109 #define SE_GROUP_LOGON_ID               0xC0000000
110 #define SE_GROUP_RESOURCE               0x20000000
111
112 /* Flags for controlling the behaviour of a particular logon */
113
114 /* sets LOGON_SERVER_TRUST_ACCOUNT user_flag */
115 #define MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT       0x00000020
116 #define MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT  0x00000800
117
118 /* updates the "logon time" on network logon */
119 #define MSV1_0_UPDATE_LOGON_STATISTICS          0x00000004
120
121 /* returns the user parameters in the driveletter */
122 #define MSV1_0_RETURN_USER_PARAMETERS           0x00000008
123
124 /* returns the profilepath in the driveletter and 
125  * sets LOGON_PROFILE_PATH_RETURNED user_flag */
126 #define MSV1_0_RETURN_PROFILE_PATH              0x00000200
127
128 #if 0
129 /* I think this is correct - it's what gets parsed on the wire. JRA. */
130 /* NET_USER_INFO_2 */
131 typedef struct net_user_info_2 {
132         uint32 ptr_user_info;
133
134         NTTIME logon_time;            /* logon time */
135         NTTIME logoff_time;           /* logoff time */
136         NTTIME kickoff_time;          /* kickoff time */
137         NTTIME pass_last_set_time;    /* password last set time */
138         NTTIME pass_can_change_time;  /* password can change time */
139         NTTIME pass_must_change_time; /* password must change time */
140
141         UNIHDR hdr_user_name;    /* username unicode string header */
142         UNIHDR hdr_full_name;    /* user's full name unicode string header */
143         UNIHDR hdr_logon_script; /* logon script unicode string header */
144         UNIHDR hdr_profile_path; /* profile path unicode string header */
145         UNIHDR hdr_home_dir;     /* home directory unicode string header */
146         UNIHDR hdr_dir_drive;    /* home directory drive unicode string header */
147
148         uint16 logon_count;  /* logon count */
149         uint16 bad_pw_count; /* bad password count */
150
151         uint32 user_id;       /* User ID */
152         uint32 group_id;      /* Group ID */
153         uint32 num_groups;    /* num groups */
154         uint32 buffer_groups; /* undocumented buffer pointer to groups. */
155         uint32 user_flgs;     /* user flags */
156
157         uint8 user_sess_key[16]; /* unused user session key */
158
159         UNIHDR hdr_logon_srv; /* logon server unicode string header */
160         UNIHDR hdr_logon_dom; /* logon domain unicode string header */
161
162         uint32 buffer_dom_id; /* undocumented logon domain id pointer */
163         uint8 padding[40];    /* unused padding bytes.  expansion room */
164
165         UNISTR2 uni_user_name;    /* username unicode string */
166         UNISTR2 uni_full_name;    /* user's full name unicode string */
167         UNISTR2 uni_logon_script; /* logon script unicode string */
168         UNISTR2 uni_profile_path; /* profile path unicode string */
169         UNISTR2 uni_home_dir;     /* home directory unicode string */
170         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
171
172         uint32 num_groups2;        /* num groups */
173         DOM_GID *gids; /* group info */
174
175         UNISTR2 uni_logon_srv; /* logon server unicode string */
176         UNISTR2 uni_logon_dom; /* logon domain unicode string */
177
178         DOM_SID2 dom_sid;           /* domain SID */
179
180         uint32 num_other_groups;        /* other groups */
181         DOM_GID *other_gids; /* group info */
182         DOM_SID2 *other_sids; /* undocumented - domain SIDs */
183
184 } NET_USER_INFO_2;
185 #endif
186
187 /* NET_USER_INFO_2 */
188 typedef struct net_user_info_2 {
189         uint32 ptr_user_info;
190
191         NTTIME logon_time;            /* logon time */
192         NTTIME logoff_time;           /* logoff time */
193         NTTIME kickoff_time;          /* kickoff time */
194         NTTIME pass_last_set_time;    /* password last set time */
195         NTTIME pass_can_change_time;  /* password can change time */
196         NTTIME pass_must_change_time; /* password must change time */
197
198         UNIHDR hdr_user_name;    /* username unicode string header */
199         UNIHDR hdr_full_name;    /* user's full name unicode string header */
200         UNIHDR hdr_logon_script; /* logon script unicode string header */
201         UNIHDR hdr_profile_path; /* profile path unicode string header */
202         UNIHDR hdr_home_dir;     /* home directory unicode string header */
203         UNIHDR hdr_dir_drive;    /* home directory drive unicode string header */
204
205         uint16 logon_count;  /* logon count */
206         uint16 bad_pw_count; /* bad password count */
207
208         uint32 user_rid;       /* User RID */
209         uint32 group_rid;      /* Group RID */
210
211         uint32 num_groups;    /* num groups */
212         uint32 buffer_groups; /* undocumented buffer pointer to groups. */
213         uint32 user_flgs;     /* user flags */
214
215         uint8 user_sess_key[16]; /* user session key */
216
217         UNIHDR hdr_logon_srv; /* logon server unicode string header */
218         UNIHDR hdr_logon_dom; /* logon domain unicode string header */
219
220         uint32 buffer_dom_id; /* undocumented logon domain id pointer */
221         uint8 lm_sess_key[8];   /* lm session key */
222         uint32 acct_flags;      /* account flags */
223         uint32 unknown[7];      /* unknown */
224
225         UNISTR2 uni_user_name;    /* username unicode string */
226         UNISTR2 uni_full_name;    /* user's full name unicode string */
227         UNISTR2 uni_logon_script; /* logon script unicode string */
228         UNISTR2 uni_profile_path; /* profile path unicode string */
229         UNISTR2 uni_home_dir;     /* home directory unicode string */
230         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
231
232         UNISTR2 uni_logon_srv; /* logon server unicode string */
233         UNISTR2 uni_logon_dom; /* logon domain unicode string */
234
235         DOM_SID2 dom_sid;           /* domain SID */
236 } NET_USER_INFO_2;
237
238 /* NET_USER_INFO_3 */
239 typedef struct net_user_info_3 {
240         uint32 ptr_user_info;
241
242         NTTIME logon_time;            /* logon time */
243         NTTIME logoff_time;           /* logoff time */
244         NTTIME kickoff_time;          /* kickoff time */
245         NTTIME pass_last_set_time;    /* password last set time */
246         NTTIME pass_can_change_time;  /* password can change time */
247         NTTIME pass_must_change_time; /* password must change time */
248
249         UNIHDR hdr_user_name;    /* username unicode string header */
250         UNIHDR hdr_full_name;    /* user's full name unicode string header */
251         UNIHDR hdr_logon_script; /* logon script unicode string header */
252         UNIHDR hdr_profile_path; /* profile path unicode string header */
253         UNIHDR hdr_home_dir;     /* home directory unicode string header */
254         UNIHDR hdr_dir_drive;    /* home directory drive unicode string header */
255
256         uint16 logon_count;  /* logon count */
257         uint16 bad_pw_count; /* bad password count */
258
259         uint32 user_rid;       /* User RID */
260         uint32 group_rid;      /* Group RID */
261
262         uint32 num_groups;    /* num groups */
263         uint32 buffer_groups; /* undocumented buffer pointer to groups. */
264         uint32 user_flgs;     /* user flags */
265
266         uint8 user_sess_key[16]; /* user session key */
267
268         UNIHDR hdr_logon_srv; /* logon server unicode string header */
269         UNIHDR hdr_logon_dom; /* logon domain unicode string header */
270
271         uint32 buffer_dom_id; /* undocumented logon domain id pointer */
272         uint8 lm_sess_key[8];   /* lm session key */
273         uint32 acct_flags;      /* account flags */
274         uint32 unknown[7];      /* unknown */
275
276         uint32 num_other_sids; /* number of foreign/trusted domain sids */
277         uint32 buffer_other_sids;
278         
279         /* The next three uint32 are not really part of user_info_3 but here
280          * for parsing convenience.  They are only valid in Kerberos PAC
281          * parsing - Guenther */
282         uint32 ptr_res_group_dom_sid;
283         uint32 res_group_count;
284         uint32 ptr_res_groups;
285
286         UNISTR2 uni_user_name;    /* username unicode string */
287         UNISTR2 uni_full_name;    /* user's full name unicode string */
288         UNISTR2 uni_logon_script; /* logon script unicode string */
289         UNISTR2 uni_profile_path; /* profile path unicode string */
290         UNISTR2 uni_home_dir;     /* home directory unicode string */
291         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
292
293         uint32 num_groups2;        /* num groups */
294         DOM_GID *gids; /* group info */
295
296         UNISTR2 uni_logon_srv; /* logon server unicode string */
297         UNISTR2 uni_logon_dom; /* logon domain unicode string */
298
299         DOM_SID2 dom_sid;           /* domain SID */
300
301         DOM_SID2 *other_sids; /* foreign/trusted domain SIDs */
302         uint32 *other_sids_attrib;
303 } NET_USER_INFO_3;
304
305
306 /* NETLOGON_INFO_1 - pdc status info, i presume */
307 typedef struct netlogon_1_info {
308         uint32 flags;            /* 0x0 - undocumented */
309         uint32 pdc_status;       /* 0x0 - undocumented */
310 } NETLOGON_INFO_1;
311
312 /* NETLOGON_INFO_2 - pdc status info, plus trusted domain info */
313 typedef struct netlogon_2_info {
314         uint32  flags;            /* 0x0 - undocumented */
315         uint32  pdc_status;       /* 0x0 - undocumented */
316         uint32  ptr_trusted_dc_name; /* pointer to trusted domain controller name */
317         uint32  tc_status;           
318         UNISTR2 uni_trusted_dc_name; /* unicode string - trusted dc name */
319 } NETLOGON_INFO_2;
320
321 /* NETLOGON_INFO_3 - logon status info, i presume */
322 typedef struct netlogon_3_info {
323         uint32 flags;            /* 0x0 - undocumented */
324         uint32 logon_attempts;   /* number of logon attempts */
325         uint32 reserved_1;       /* 0x0 - undocumented */
326         uint32 reserved_2;       /* 0x0 - undocumented */
327         uint32 reserved_3;       /* 0x0 - undocumented */
328         uint32 reserved_4;       /* 0x0 - undocumented */
329         uint32 reserved_5;       /* 0x0 - undocumented */
330 } NETLOGON_INFO_3;
331
332 /********************************************************
333  Logon Control Query
334
335  This is generated by a nltest /bdc_query:DOMAIN
336
337  query_level 0x1, function_code 0x1
338
339  ********************************************************/
340
341 /* NET_Q_LOGON_CTRL - LSA Netr Logon Control */
342
343 typedef struct net_q_logon_ctrl_info {
344         uint32 ptr;
345         UNISTR2 uni_server_name;
346         uint32 function_code;
347         uint32 query_level;
348 } NET_Q_LOGON_CTRL;
349
350 /* NET_R_LOGON_CTRL - LSA Netr Logon Control */
351
352 typedef struct net_r_logon_ctrl_info {
353         uint32 switch_value;
354         uint32 ptr;
355
356         union {
357                 NETLOGON_INFO_1 info1;
358         } logon;
359
360         NTSTATUS status;
361 } NET_R_LOGON_CTRL;
362
363
364 typedef struct ctrl_data_info_5 {
365         uint32          function_code;
366         
367         uint32          ptr_domain;
368         UNISTR2         domain;
369 } CTRL_DATA_INFO_5;
370
371 typedef struct ctrl_data_info_6 {
372         uint32          function_code;
373         
374         uint32          ptr_domain;
375         UNISTR2         domain;
376 } CTRL_DATA_INFO_6;
377
378
379 /********************************************************
380  Logon Control2 Query
381
382  query_level 0x1 - pdc status
383  query_level 0x3 - number of logon attempts.
384
385  ********************************************************/
386
387 /* NET_Q_LOGON_CTRL2 - LSA Netr Logon Control 2 */
388 typedef struct net_q_logon_ctrl2_info {
389         uint32          ptr;             /* undocumented buffer pointer */
390         UNISTR2         uni_server_name; /* server name, starting with two '\'s */
391         
392         uint32          function_code; 
393         uint32          query_level;   
394         union {
395                 CTRL_DATA_INFO_5 info5;
396                 CTRL_DATA_INFO_6 info6;
397         } info;
398 } NET_Q_LOGON_CTRL2;
399
400 /*******************************************************
401  Logon Control Response
402
403  switch_value is same as query_level in request 
404  *******************************************************/
405
406 /* NET_R_LOGON_CTRL2 - response to LSA Logon Control2 */
407 typedef struct net_r_logon_ctrl2_info {
408         uint32       switch_value;  /* 0x1, 0x3 */
409         uint32       ptr;
410
411         union
412         {
413                 NETLOGON_INFO_1 info1;
414                 NETLOGON_INFO_2 info2;
415                 NETLOGON_INFO_3 info3;
416
417         } logon;
418
419         NTSTATUS status; /* return code */
420 } NET_R_LOGON_CTRL2;
421
422 /* NET_Q_GETANYDCNAME - Ask a DC for a trusted DC name */
423
424 typedef struct net_q_getanydcname {
425         uint32  ptr_logon_server;
426         UNISTR2 uni_logon_server;
427         uint32  ptr_domainname;
428         UNISTR2 uni_domainname;
429 } NET_Q_GETANYDCNAME;
430
431 /* NET_R_GETANYDCNAME - Ask a DC for a trusted DC name */
432
433 typedef struct net_r_getanydcname {
434         uint32  ptr_dcname;
435         UNISTR2 uni_dcname;
436         WERROR status;
437 } NET_R_GETANYDCNAME;
438
439 /* NET_Q_TRUST_DOM_LIST - LSA Query Trusted Domains */
440 typedef struct net_q_trust_dom_info {
441         uint32       ptr;             /* undocumented buffer pointer */
442         UNISTR2      uni_server_name; /* server name, starting with two '\'s */
443 } NET_Q_TRUST_DOM_LIST;
444
445 #define MAX_TRUST_DOMS 1
446
447 /* NET_R_TRUST_DOM_LIST - response to LSA Trusted Domains */
448 typedef struct net_r_trust_dom_info {
449         UNISTR2 uni_trust_dom_name[MAX_TRUST_DOMS];
450
451         NTSTATUS status; /* return code */
452 } NET_R_TRUST_DOM_LIST;
453
454
455 /* NEG_FLAGS */
456 typedef struct neg_flags_info {
457         uint32 neg_flags; /* negotiated flags */
458 } NEG_FLAGS;
459
460
461 /* NET_Q_REQ_CHAL */
462 typedef struct net_q_req_chal_info {
463         uint32  undoc_buffer; /* undocumented buffer pointer */
464         UNISTR2 uni_logon_srv; /* logon server unicode string */
465         UNISTR2 uni_logon_clnt; /* logon client unicode string */
466         DOM_CHAL clnt_chal; /* client challenge */
467 } NET_Q_REQ_CHAL;
468
469
470 /* NET_R_REQ_CHAL */
471 typedef struct net_r_req_chal_info {
472         DOM_CHAL srv_chal; /* server challenge */
473         NTSTATUS status; /* return code */
474 } NET_R_REQ_CHAL;
475
476 /* NET_Q_AUTH */
477 typedef struct net_q_auth_info {
478         DOM_LOG_INFO clnt_id; /* client identification info */
479         DOM_CHAL clnt_chal;     /* client-calculated credentials */
480 } NET_Q_AUTH;
481
482 /* NET_R_AUTH */
483 typedef struct net_r_auth_info {
484         DOM_CHAL srv_chal;     /* server-calculated credentials */
485         NTSTATUS status; /* return code */
486 } NET_R_AUTH;
487
488 /* NET_Q_AUTH_2 */
489 typedef struct net_q_auth2_info {
490         DOM_LOG_INFO clnt_id; /* client identification info */
491         DOM_CHAL clnt_chal;     /* client-calculated credentials */
492
493         NEG_FLAGS clnt_flgs; /* usually 0x0000 01ff */
494 } NET_Q_AUTH_2;
495
496
497 /* NET_R_AUTH_2 */
498 typedef struct net_r_auth2_info {
499         DOM_CHAL srv_chal;     /* server-calculated credentials */
500         NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */
501         NTSTATUS status; /* return code */
502 } NET_R_AUTH_2;
503
504 /* NET_Q_AUTH_3 */
505 typedef struct net_q_auth3_info {
506         DOM_LOG_INFO clnt_id;   /* client identification info */
507         DOM_CHAL clnt_chal;             /* client-calculated credentials */
508         NEG_FLAGS clnt_flgs;    /* usually 0x6007 ffff */
509 } NET_Q_AUTH_3;
510
511 /* NET_R_AUTH_3 */
512 typedef struct net_r_auth3_info {
513         DOM_CHAL srv_chal;      /* server-calculated credentials */
514         NEG_FLAGS srv_flgs;     /* usually 0x6007 ffff */
515         uint32 unknown;         /* 0x0000045b */
516         NTSTATUS status;        /* return code */
517 } NET_R_AUTH_3;
518
519
520 /* NET_Q_SRV_PWSET */
521 typedef struct net_q_srv_pwset_info {
522         DOM_CLNT_INFO clnt_id; /* client identification/authentication info */
523         uint8 pwd[16]; /* new password - undocumented. */
524 } NET_Q_SRV_PWSET;
525     
526 /* NET_R_SRV_PWSET */
527 typedef struct net_r_srv_pwset_info {
528         DOM_CRED srv_cred;     /* server-calculated credentials */
529
530         NTSTATUS status; /* return code */
531 } NET_R_SRV_PWSET;
532
533 /* NET_ID_INFO_2 */
534 typedef struct net_network_info_2 {
535         uint32            ptr_id_info2;        /* pointer to id_info_2 */
536         UNIHDR            hdr_domain_name;     /* domain name unicode header */
537         uint32            param_ctrl;          /* param control (0x2) */
538         DOM_LOGON_ID      logon_id;            /* logon ID */
539         UNIHDR            hdr_user_name;       /* user name unicode header */
540         UNIHDR            hdr_wksta_name;      /* workstation name unicode header */
541         uint8             lm_chal[8];          /* lan manager 8 byte challenge */
542         STRHDR            hdr_nt_chal_resp;    /* nt challenge response */
543         STRHDR            hdr_lm_chal_resp;    /* lm challenge response */
544
545         UNISTR2           uni_domain_name;     /* domain name unicode string */
546         UNISTR2           uni_user_name;       /* user name unicode string */
547         UNISTR2           uni_wksta_name;      /* workgroup name unicode string */
548         STRING2           nt_chal_resp;        /* nt challenge response */
549         STRING2           lm_chal_resp;        /* lm challenge response */
550 } NET_ID_INFO_2;
551
552 /* NET_ID_INFO_1 */
553 typedef struct id_info_1 {
554         uint32            ptr_id_info1;        /* pointer to id_info_1 */
555         UNIHDR            hdr_domain_name;     /* domain name unicode header */
556         uint32            param_ctrl;          /* param control */
557         DOM_LOGON_ID      logon_id;            /* logon ID */
558         UNIHDR            hdr_user_name;       /* user name unicode header */
559         UNIHDR            hdr_wksta_name;      /* workstation name unicode header */
560         OWF_INFO          lm_owf;              /* LM OWF Password */
561         OWF_INFO          nt_owf;              /* NT OWF Password */
562         UNISTR2           uni_domain_name;     /* domain name unicode string */
563         UNISTR2           uni_user_name;       /* user name unicode string */
564         UNISTR2           uni_wksta_name;      /* workgroup name unicode string */
565 } NET_ID_INFO_1;
566
567 #define INTERACTIVE_LOGON_TYPE 1
568 #define NET_LOGON_TYPE 2
569
570 /* NET_ID_INFO_CTR */
571 typedef struct net_id_info_ctr_info {
572         uint16         switch_value;
573   
574         union {
575                 NET_ID_INFO_1 id1; /* auth-level 1 - interactive user login */
576                 NET_ID_INFO_2 id2; /* auth-level 2 - workstation referred login */
577         } auth;
578 } NET_ID_INFO_CTR;
579
580 /* SAM_INFO - sam logon/off id structure */
581 typedef struct sam_info {
582         DOM_CLNT_INFO2  client;
583         uint32          ptr_rtn_cred; /* pointer to return credentials */
584         DOM_CRED        rtn_cred; /* return credentials */
585         uint16          logon_level;
586         NET_ID_INFO_CTR *ctr;
587 } DOM_SAM_INFO;
588
589 /* SAM_INFO - sam logon/off id structure - no creds */
590 typedef struct sam_info_ex {
591         DOM_CLNT_SRV    client;
592         uint16          logon_level;
593         NET_ID_INFO_CTR *ctr;
594 } DOM_SAM_INFO_EX;
595
596 /* NET_Q_SAM_LOGON */
597 typedef struct net_q_sam_logon_info {
598         DOM_SAM_INFO sam_id;
599         uint16          validation_level;
600 } NET_Q_SAM_LOGON;
601
602 /* NET_Q_SAM_LOGON_EX */
603 typedef struct net_q_sam_logon_info_ex {
604         DOM_SAM_INFO_EX sam_id;
605         uint16          validation_level;
606         uint32 flags;
607 } NET_Q_SAM_LOGON_EX;
608
609 /* NET_R_SAM_LOGON */
610 typedef struct net_r_sam_logon_info {
611         uint32 buffer_creds; /* undocumented buffer pointer */
612         DOM_CRED srv_creds; /* server credentials.  server time stamp appears to be ignored. */
613     
614         uint16 switch_value; /* 3 - indicates type of USER INFO */
615         NET_USER_INFO_3 *user;
616
617         uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
618
619         NTSTATUS status; /* return code */
620 } NET_R_SAM_LOGON;
621
622 /* NET_R_SAM_LOGON_EX */
623 typedef struct net_r_sam_logon_info_ex {
624         uint16 switch_value; /* 3 - indicates type of USER INFO */
625         NET_USER_INFO_3 *user;
626
627         uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
628         uint32 flags;
629
630         NTSTATUS status; /* return code */
631 } NET_R_SAM_LOGON_EX;
632
633
634 /* NET_Q_SAM_LOGOFF */
635 typedef struct net_q_sam_logoff_info {
636         DOM_SAM_INFO sam_id;
637 } NET_Q_SAM_LOGOFF;
638
639 /* NET_R_SAM_LOGOFF */
640 typedef struct net_r_sam_logoff_info {
641         uint32 buffer_creds; /* undocumented buffer pointer */
642         DOM_CRED srv_creds; /* server credentials.  server time stamp appears to be ignored. */
643         NTSTATUS status; /* return code */
644 } NET_R_SAM_LOGOFF;
645
646 /* NET_Q_SAM_SYNC */
647 typedef struct net_q_sam_sync_info {
648         UNISTR2 uni_srv_name; /* \\PDC */
649         UNISTR2 uni_cli_name; /* BDC */
650         DOM_CRED cli_creds;
651         DOM_CRED ret_creds;
652
653         uint32 database_id;
654         uint32 restart_state;
655         uint32 sync_context;
656
657         uint32 max_size;       /* preferred maximum length */
658 } NET_Q_SAM_SYNC;
659
660 /* SAM_DELTA_HDR */
661 typedef struct sam_delta_hdr_info {
662         uint16 type;  /* type of structure attached */
663         uint16 type2;
664         uint32 target_rid;
665
666         uint32 type3;
667         uint32 ptr_delta;
668 } SAM_DELTA_HDR;
669
670 /* LOCKOUT_STRING */
671 typedef struct account_lockout_string {
672         uint32 array_size;
673         uint32 offset;
674         uint32 length;
675 /*      uint16 *bindata;        */
676         uint64 lockout_duration;
677         uint64 reset_count;
678         uint32 bad_attempt_lockout;
679         uint32 dummy;
680 } LOCKOUT_STRING;
681
682 /* HDR_LOCKOUT_STRING */
683 typedef struct hdr_account_lockout_string {
684         uint16 size;
685         uint16 length;
686         uint32 buffer;
687 } HDR_LOCKOUT_STRING;
688
689 /* SAM_DOMAIN_INFO (0x1) */
690 typedef struct sam_domain_info_info {
691         UNIHDR hdr_dom_name;
692         UNIHDR hdr_oem_info;
693
694         uint64 force_logoff;
695         uint16   min_pwd_len;
696         uint16   pwd_history_len;
697         uint64 max_pwd_age;
698         uint64 min_pwd_age;
699         uint64 dom_mod_count;
700         NTTIME   creation_time;
701         uint32   security_information;
702
703         BUFHDR4 hdr_sec_desc; /* security descriptor */
704
705         HDR_LOCKOUT_STRING hdr_account_lockout;
706
707         UNIHDR hdr_unknown2;
708         UNIHDR hdr_unknown3;
709         UNIHDR hdr_unknown4;
710
711         UNISTR2 uni_dom_name;
712         UNISTR2 buf_oem_info; 
713
714         RPC_DATA_BLOB buf_sec_desc;
715
716         LOCKOUT_STRING account_lockout;
717
718         UNISTR2 buf_unknown2;
719         UNISTR2 buf_unknown3;
720         UNISTR2 buf_unknown4;
721
722         uint32 logon_chgpass;
723         uint32 unknown6;
724         uint32 unknown7;
725         uint32 unknown8;
726 } SAM_DOMAIN_INFO;
727
728 /* SAM_GROUP_INFO (0x2) */
729 typedef struct sam_group_info_info {
730         UNIHDR hdr_grp_name;
731         DOM_GID gid;
732         UNIHDR hdr_grp_desc;
733         BUFHDR2 hdr_sec_desc;  /* security descriptor */
734         uint8 reserved[48];
735
736         UNISTR2 uni_grp_name;
737         UNISTR2 uni_grp_desc;
738         RPC_DATA_BLOB buf_sec_desc;
739 } SAM_GROUP_INFO;
740
741 /* SAM_PWD */
742 typedef struct sam_passwd_info {
743         /* this structure probably contains password history */
744         /* this is probably a count of lm/nt pairs */
745         uint32 unk_0; /* 0x0000 0002 */
746
747         UNIHDR hdr_lm_pwd;
748         uint8  buf_lm_pwd[16];
749
750         UNIHDR hdr_nt_pwd;
751         uint8  buf_nt_pwd[16];
752
753         UNIHDR hdr_empty_lm;
754         UNIHDR hdr_empty_nt;
755 } SAM_PWD;
756
757 /* SAM_ACCOUNT_INFO (0x5) */
758 typedef struct sam_account_info_info {
759         UNIHDR hdr_acct_name;
760         UNIHDR hdr_full_name;
761
762         uint32 user_rid;
763         uint32 group_rid;
764
765         UNIHDR hdr_home_dir;
766         UNIHDR hdr_dir_drive;
767         UNIHDR hdr_logon_script;
768         UNIHDR hdr_acct_desc;
769         UNIHDR hdr_workstations;
770
771         NTTIME logon_time;
772         NTTIME logoff_time;
773
774         uint32 logon_divs; /* 0xA8 */
775         uint32 ptr_logon_hrs;
776
777         uint16 bad_pwd_count;
778         uint16 logon_count;
779         NTTIME pwd_last_set_time;
780         NTTIME acct_expiry_time;
781
782         uint32 acb_info;
783         uint8 nt_pwd[16];
784         uint8 lm_pwd[16];
785         uint8 nt_pwd_present;
786         uint8 lm_pwd_present;
787         uint8 pwd_expired;
788
789         UNIHDR hdr_comment;
790         UNIHDR hdr_parameters;
791         uint16 country;
792         uint16 codepage;
793
794         BUFHDR2 hdr_sec_desc;  /* security descriptor */
795
796         UNIHDR  hdr_profile;
797         UNIHDR  hdr_reserved[3];  /* space for more strings */
798         uint32  dw_reserved[4];   /* space for more data - first two seem to
799                                      be an NTTIME */
800
801         UNISTR2 uni_acct_name;
802         UNISTR2 uni_full_name;
803         UNISTR2 uni_home_dir;
804         UNISTR2 uni_dir_drive;
805         UNISTR2 uni_logon_script;
806         UNISTR2 uni_acct_desc;
807         UNISTR2 uni_workstations;
808
809         uint32 unknown1; /* 0x4EC */
810         uint32 unknown2; /* 0 */
811
812         RPC_DATA_BLOB buf_logon_hrs;
813         UNISTR2 uni_comment;
814         UNISTR2 uni_parameters;
815         SAM_PWD pass;
816         RPC_DATA_BLOB buf_sec_desc;
817         UNISTR2 uni_profile;
818 } SAM_ACCOUNT_INFO;
819
820 /* SAM_GROUP_MEM_INFO (0x8) */
821 typedef struct sam_group_mem_info_info {
822         uint32 ptr_rids;
823         uint32 ptr_attribs;
824         uint32 num_members;
825         uint8 unknown[16];
826
827         uint32 num_members2;
828         uint32 *rids;
829
830         uint32 num_members3;
831         uint32 *attribs;
832
833 } SAM_GROUP_MEM_INFO;
834
835 /* SAM_ALIAS_INFO (0x9) */
836 typedef struct sam_alias_info_info {
837         UNIHDR hdr_als_name;
838         uint32 als_rid;
839         BUFHDR2 hdr_sec_desc;  /* security descriptor */
840         UNIHDR hdr_als_desc;
841         uint8 reserved[40];
842
843         UNISTR2 uni_als_name;
844         RPC_DATA_BLOB buf_sec_desc;
845         UNISTR2 uni_als_desc;
846 } SAM_ALIAS_INFO;
847
848 /* SAM_ALIAS_MEM_INFO (0xC) */
849 typedef struct sam_alias_mem_info_info {
850         uint32 num_members;
851         uint32 ptr_members;
852         uint8 unknown[16];
853
854         uint32 num_sids;
855         uint32 *ptr_sids;
856         DOM_SID2 *sids;
857 } SAM_ALIAS_MEM_INFO;
858
859
860 /* SAM_DELTA_POLICY (0x0D) */
861 typedef struct {
862         uint32   max_log_size; /* 0x5000 */
863         uint64 audit_retention_period; /* 0 */
864         uint32   auditing_mode; /* 0 */
865         uint32   num_events;
866         uint32   ptr_events;
867         UNIHDR   hdr_dom_name;
868         uint32   sid_ptr;
869
870         uint32   paged_pool_limit; /* 0x02000000 */
871         uint32   non_paged_pool_limit; /* 0x00100000 */
872         uint32   min_workset_size; /* 0x00010000 */
873         uint32   max_workset_size; /* 0x0f000000 */
874         uint32   page_file_limit; /* 0 */
875         uint64 time_limit; /* 0 */
876         NTTIME   modify_time; /* 0x3c*/
877         NTTIME   create_time; /* a7080110 */
878         BUFHDR2  hdr_sec_desc;
879
880         uint32   num_event_audit_options;
881         uint32   event_audit_option;
882
883         UNISTR2  domain_name;
884         DOM_SID2 domain_sid;
885
886         RPC_DATA_BLOB  buf_sec_desc;
887 } SAM_DELTA_POLICY;
888
889 /* SAM_DELTA_TRUST_DOMS */
890 typedef struct {
891         uint32 buf_size;
892         SEC_DESC *sec_desc;
893         DOM_SID2 sid;
894         UNIHDR hdr_domain;
895         
896         uint32 unknown0;
897         uint32 unknown1;
898         uint32 unknown2;
899         
900         uint32 buf_size2;
901         uint32 ptr;
902
903         uint32 unknown3;
904         UNISTR2 domain;
905 } SAM_DELTA_TRUSTDOMS;
906
907 /* SAM_DELTA_PRIVS (0x10) */
908 typedef struct {
909         DOM_SID2 sid;
910
911         uint32 priv_count;
912         uint32 priv_control;
913
914         uint32 priv_attr_ptr;
915         uint32 priv_name_ptr;
916
917         uint32   paged_pool_limit; /* 0x02000000 */
918         uint32   non_paged_pool_limit; /* 0x00100000 */
919         uint32   min_workset_size; /* 0x00010000 */
920         uint32   max_workset_size; /* 0x0f000000 */
921         uint32   page_file_limit; /* 0 */
922         uint64 time_limit; /* 0 */
923         uint32   system_flags; /* 1 */
924         BUFHDR2  hdr_sec_desc;
925         
926         uint32 buf_size2;
927         
928         uint32 attribute_count;
929         uint32 *attributes;
930         
931         uint32 privlist_count;
932         UNIHDR *hdr_privslist;
933         UNISTR2 *uni_privslist;
934
935         RPC_DATA_BLOB buf_sec_desc;
936 } SAM_DELTA_PRIVS;
937
938 /* SAM_DELTA_SECRET */
939 typedef struct {
940         uint32 buf_size;
941         SEC_DESC *sec_desc;
942         UNISTR2 secret;
943
944         uint32 count1;
945         uint32 count2;
946         uint32 ptr;
947         NTTIME time1;
948         uint32 count3;
949         uint32 count4;
950         uint32 ptr2;
951         NTTIME time2;
952         uint32 unknow1;
953
954         uint32 buf_size2;
955         uint32 ptr3;
956         uint32 unknow2; /* 0x0 12 times */
957
958         uint32 chal_len;
959         uint32 reserved1; /* 0 */
960         uint32 chal_len2;
961         uint8 chal[16];
962
963         uint32 key_len;
964         uint32 reserved2; /* 0 */
965         uint32 key_len2;
966         uint8 key[8];
967
968         uint32 buf_size3;
969         SEC_DESC *sec_desc2;
970 } SAM_DELTA_SECRET;
971
972 /* SAM_DELTA_MOD_COUNT (0x16) */
973 typedef struct {
974         uint32 seqnum;
975         uint32 dom_mod_count_ptr;
976         uint64 dom_mod_count;  /* domain mod count at last sync */
977 } SAM_DELTA_MOD_COUNT;
978
979 typedef union sam_delta_ctr_info {
980         SAM_DOMAIN_INFO    domain_info ;
981         SAM_GROUP_INFO     group_info  ;
982         SAM_ACCOUNT_INFO   account_info;
983         SAM_GROUP_MEM_INFO grp_mem_info;
984         SAM_ALIAS_INFO     alias_info  ;
985         SAM_ALIAS_MEM_INFO als_mem_info;
986         SAM_DELTA_POLICY   policy_info;
987         SAM_DELTA_PRIVS    privs_info;
988         SAM_DELTA_MOD_COUNT mod_count;
989         SAM_DELTA_TRUSTDOMS trustdoms_info;
990         SAM_DELTA_SECRET   secret_info;
991 } SAM_DELTA_CTR;
992
993 /* NET_R_SAM_SYNC */
994 typedef struct net_r_sam_sync_info {
995         DOM_CRED srv_creds;
996
997         uint32 sync_context;
998
999         uint32 ptr_deltas;
1000         uint32 num_deltas;
1001         uint32 ptr_deltas2;
1002         uint32 num_deltas2;
1003
1004         SAM_DELTA_HDR *hdr_deltas;
1005         SAM_DELTA_CTR *deltas;
1006
1007         NTSTATUS status;
1008 } NET_R_SAM_SYNC;
1009
1010 /* NET_Q_SAM_DELTAS */
1011 typedef struct net_q_sam_deltas_info {
1012         UNISTR2 uni_srv_name;
1013         UNISTR2 uni_cli_name;
1014         DOM_CRED cli_creds;
1015         DOM_CRED ret_creds;
1016
1017         uint32 database_id;
1018         uint64 dom_mod_count;  /* domain mod count at last sync */
1019
1020         uint32 max_size;       /* preferred maximum length */
1021 } NET_Q_SAM_DELTAS;
1022
1023 /* NET_R_SAM_DELTAS */
1024 typedef struct net_r_sam_deltas_info {
1025         DOM_CRED srv_creds;
1026
1027         uint64 dom_mod_count;   /* new domain mod count */
1028
1029         uint32 ptr_deltas;
1030         uint32 num_deltas;
1031         uint32 num_deltas2;
1032
1033         SAM_DELTA_HDR *hdr_deltas;
1034         SAM_DELTA_CTR *deltas;
1035
1036         NTSTATUS status;
1037 } NET_R_SAM_DELTAS;
1038
1039 #define DS_FORCE_REDISCOVERY            0x00000001
1040 #define DS_DIRECTORY_SERVICE_REQUIRED   0x00000010
1041 #define DS_DIRECTORY_SERVICE_PREFERRED  0x00000020
1042 #define DS_GC_SERVER_REQUIRED           0x00000040
1043 #define DS_PDC_REQUIRED                 0x00000080
1044 #define DS_BACKGROUND_ONLY              0x00000100
1045 #define DS_IP_REQUIRED                  0x00000200
1046 #define DS_KDC_REQUIRED                 0x00000400
1047 #define DS_TIMESERV_REQUIRED            0x00000800
1048 #define DS_WRITABLE_REQUIRED            0x00001000
1049 #define DS_GOOD_TIMESERV_PREFERRED      0x00002000
1050 #define DS_AVOID_SELF                   0x00004000
1051 #define DS_ONLY_LDAP_NEEDED             0x00008000
1052
1053 #define DS_IS_FLAT_NAME                 0x00010000
1054 #define DS_IS_DNS_NAME                  0x00020000
1055
1056 #define DS_RETURN_DNS_NAME              0x40000000
1057 #define DS_RETURN_FLAT_NAME             0x80000000
1058
1059 #if 0 /* unknown yet */
1060 #define DS_IP_VERSION_AGNOSTIC
1061 #define DS_TRY_NEXTCLOSEST_SITE
1062 #endif
1063
1064 #define DSGETDC_VALID_FLAGS ( \
1065     DS_FORCE_REDISCOVERY | \
1066     DS_DIRECTORY_SERVICE_REQUIRED | \
1067     DS_DIRECTORY_SERVICE_PREFERRED | \
1068     DS_GC_SERVER_REQUIRED | \
1069     DS_PDC_REQUIRED | \
1070     DS_BACKGROUND_ONLY | \
1071     DS_IP_REQUIRED | \
1072     DS_KDC_REQUIRED | \
1073     DS_TIMESERV_REQUIRED | \
1074     DS_WRITABLE_REQUIRED | \
1075     DS_GOOD_TIMESERV_PREFERRED | \
1076     DS_AVOID_SELF | \
1077     DS_ONLY_LDAP_NEEDED | \
1078     DS_IS_FLAT_NAME | \
1079     DS_IS_DNS_NAME | \
1080     DS_RETURN_FLAT_NAME  | \
1081     DS_RETURN_DNS_NAME )
1082
1083 struct DS_DOMAIN_CONTROLLER_INFO {
1084         const char *domain_controller_name;
1085         const char *domain_controller_address;
1086         int32 domain_controller_address_type;
1087         struct GUID *domain_guid;
1088         const char *domain_name;
1089         const char *dns_forest_name;
1090         uint32 flags;
1091         const char *dc_site_name;
1092         const char *client_site_name;
1093 };
1094
1095 /* NET_Q_DSR_GETDCNAME */
1096 typedef struct net_q_dsr_getdcname {
1097         uint32 ptr_server_unc;
1098         UNISTR2 uni_server_unc;
1099         uint32 ptr_domain_name;
1100         UNISTR2 uni_domain_name;
1101         uint32 ptr_domain_guid;
1102         struct GUID *domain_guid;
1103         uint32 ptr_site_guid;
1104         struct GUID *site_guid;
1105         uint32 flags;
1106 } NET_Q_DSR_GETDCNAME;
1107
1108 /* NET_R_DSR_GETDCNAME */
1109 typedef struct net_r_dsr_getdcname {
1110         uint32 ptr_dc_unc;
1111         UNISTR2 uni_dc_unc;
1112         uint32 ptr_dc_address;
1113         UNISTR2 uni_dc_address;
1114         int32 dc_address_type;
1115         struct GUID domain_guid;
1116         uint32 ptr_domain_name;
1117         UNISTR2 uni_domain_name;
1118         uint32 ptr_forest_name;
1119         UNISTR2 uni_forest_name;
1120         uint32 dc_flags;
1121         uint32 ptr_dc_site_name;
1122         UNISTR2 uni_dc_site_name;
1123         uint32 ptr_client_site_name;
1124         UNISTR2 uni_client_site_name;
1125         WERROR result;
1126 } NET_R_DSR_GETDCNAME;
1127
1128 /* NET_Q_DSR_GETDCNAMEEX */
1129 typedef struct net_q_dsr_getdcnameex {
1130         uint32 ptr_server_unc;
1131         UNISTR2 uni_server_unc;
1132         uint32 ptr_domain_name;
1133         UNISTR2 uni_domain_name;
1134         uint32 ptr_domain_guid;
1135         struct GUID *domain_guid;
1136         uint32 ptr_site_name;
1137         UNISTR2 uni_site_name;
1138         uint32 flags;
1139 } NET_Q_DSR_GETDCNAMEEX;
1140
1141 /* NET_R_DSR_GETDCNAMEEX */
1142 typedef struct NET_R_DSR_GETDCNAME NET_R_DSR_GETDCNAMEEX;
1143
1144 /* NET_Q_DSR_GETDCNAMEEX2 */
1145 typedef struct net_q_dsr_getdcnameex2 {
1146         uint32 ptr_server_unc;
1147         UNISTR2 uni_server_unc;
1148         uint32 ptr_client_account;
1149         UNISTR2 uni_client_account;
1150         uint32 mask;
1151         uint32 ptr_domain_name;
1152         UNISTR2 uni_domain_name;
1153         uint32 ptr_domain_guid;
1154         struct GUID *domain_guid;
1155         uint32 ptr_site_name;
1156         UNISTR2 uni_site_name;
1157         uint32 flags;
1158 } NET_Q_DSR_GETDCNAMEEX2;
1159
1160 /* NET_R_DSR_GETDCNAMEEX */
1161 typedef struct NET_R_DSR_GETDCNAME NET_R_DSR_GETDCNAMEEX2;
1162
1163 /* NET_Q_DSR_GESITENAME */
1164 typedef struct net_q_dsr_getsitename {
1165         uint32 ptr_computer_name;
1166         UNISTR2 uni_computer_name;
1167 } NET_Q_DSR_GETSITENAME;
1168
1169 /* NET_R_DSR_GETSITENAME */
1170 typedef struct net_r_dsr_getsitename {
1171         uint32 ptr_site_name;
1172         UNISTR2 uni_site_name;
1173         WERROR result;
1174 } NET_R_DSR_GETSITENAME;
1175
1176
1177 #endif /* _RPC_NETLOGON_H */