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