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