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