Remove some unused/redundant set of netlogon headers.
[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, 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_KRB5_FAIL_CLOCK_SKEW      0x02000000
83
84 /* Flags for controlling the behaviour of a particular logon */
85
86 /* sets NETLOGON_SERVER_TRUST_ACCOUNT user_flag */
87 #if 0
88 #define MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT       0x00000020
89 #define MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT  0x00000800
90
91 /* updates the "logon time" on network logon */
92 #define MSV1_0_UPDATE_LOGON_STATISTICS          0x00000004
93
94 /* returns the user parameters in the driveletter */
95 #define MSV1_0_RETURN_USER_PARAMETERS           0x00000008
96
97 /* returns the profilepath in the driveletter and 
98  * sets LOGON_PROFILE_PATH_RETURNED user_flag */
99 #define MSV1_0_RETURN_PROFILE_PATH              0x00000200
100 #endif
101
102 #if 0
103 /* I think this is correct - it's what gets parsed on the wire. JRA. */
104 /* NET_USER_INFO_2 */
105 typedef struct net_user_info_2 {
106         uint32 ptr_user_info;
107
108         NTTIME logon_time;            /* logon time */
109         NTTIME logoff_time;           /* logoff time */
110         NTTIME kickoff_time;          /* kickoff time */
111         NTTIME pass_last_set_time;    /* password last set time */
112         NTTIME pass_can_change_time;  /* password can change time */
113         NTTIME pass_must_change_time; /* password must change time */
114
115         UNIHDR hdr_user_name;    /* username unicode string header */
116         UNIHDR hdr_full_name;    /* user's full name unicode string header */
117         UNIHDR hdr_logon_script; /* logon script unicode string header */
118         UNIHDR hdr_profile_path; /* profile path unicode string header */
119         UNIHDR hdr_home_dir;     /* home directory unicode string header */
120         UNIHDR hdr_dir_drive;    /* home directory drive unicode string header */
121
122         uint16 logon_count;  /* logon count */
123         uint16 bad_pw_count; /* bad password count */
124
125         uint32 user_id;       /* User ID */
126         uint32 group_id;      /* Group ID */
127         uint32 num_groups;    /* num groups */
128         uint32 buffer_groups; /* undocumented buffer pointer to groups. */
129         uint32 user_flgs;     /* user flags */
130
131         uint8 user_sess_key[16]; /* unused user session key */
132
133         UNIHDR hdr_logon_srv; /* logon server unicode string header */
134         UNIHDR hdr_logon_dom; /* logon domain unicode string header */
135
136         uint32 buffer_dom_id; /* undocumented logon domain id pointer */
137         uint8 padding[40];    /* unused padding bytes.  expansion room */
138
139         UNISTR2 uni_user_name;    /* username unicode string */
140         UNISTR2 uni_full_name;    /* user's full name unicode string */
141         UNISTR2 uni_logon_script; /* logon script unicode string */
142         UNISTR2 uni_profile_path; /* profile path unicode string */
143         UNISTR2 uni_home_dir;     /* home directory unicode string */
144         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
145
146         uint32 num_groups2;        /* num groups */
147         DOM_GID *gids; /* group info */
148
149         UNISTR2 uni_logon_srv; /* logon server unicode string */
150         UNISTR2 uni_logon_dom; /* logon domain unicode string */
151
152         DOM_SID2 dom_sid;           /* domain SID */
153
154         uint32 num_other_groups;        /* other groups */
155         DOM_GID *other_gids; /* group info */
156         DOM_SID2 *other_sids; /* undocumented - domain SIDs */
157
158 } NET_USER_INFO_2;
159 #endif
160
161 /* NET_USER_INFO_2 */
162 typedef struct net_user_info_2 {
163         uint32 ptr_user_info;
164
165         NTTIME logon_time;            /* logon time */
166         NTTIME logoff_time;           /* logoff time */
167         NTTIME kickoff_time;          /* kickoff time */
168         NTTIME pass_last_set_time;    /* password last set time */
169         NTTIME pass_can_change_time;  /* password can change time */
170         NTTIME pass_must_change_time; /* password must change time */
171
172         UNIHDR hdr_user_name;    /* username unicode string header */
173         UNIHDR hdr_full_name;    /* user's full name unicode string header */
174         UNIHDR hdr_logon_script; /* logon script unicode string header */
175         UNIHDR hdr_profile_path; /* profile path unicode string header */
176         UNIHDR hdr_home_dir;     /* home directory unicode string header */
177         UNIHDR hdr_dir_drive;    /* home directory drive unicode string header */
178
179         uint16 logon_count;  /* logon count */
180         uint16 bad_pw_count; /* bad password count */
181
182         uint32 user_rid;       /* User RID */
183         uint32 group_rid;      /* Group RID */
184
185         uint32 num_groups;    /* num groups */
186         uint32 buffer_groups; /* undocumented buffer pointer to groups. */
187         uint32 user_flgs;     /* user flags */
188
189         uint8 user_sess_key[16]; /* user session key */
190
191         UNIHDR hdr_logon_srv; /* logon server unicode string header */
192         UNIHDR hdr_logon_dom; /* logon domain unicode string header */
193
194         uint32 buffer_dom_id; /* undocumented logon domain id pointer */
195         uint8 lm_sess_key[8];   /* lm session key */
196         uint32 acct_flags;      /* account flags */
197         uint32 unknown[7];      /* unknown */
198
199         UNISTR2 uni_user_name;    /* username unicode string */
200         UNISTR2 uni_full_name;    /* user's full name unicode string */
201         UNISTR2 uni_logon_script; /* logon script unicode string */
202         UNISTR2 uni_profile_path; /* profile path unicode string */
203         UNISTR2 uni_home_dir;     /* home directory unicode string */
204         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
205
206         UNISTR2 uni_logon_srv; /* logon server unicode string */
207         UNISTR2 uni_logon_dom; /* logon domain unicode string */
208
209         DOM_SID2 dom_sid;           /* domain SID */
210 } NET_USER_INFO_2;
211
212 /* NET_USER_INFO_3 */
213 typedef struct net_user_info_3 {
214         uint32 ptr_user_info;
215
216         NTTIME logon_time;            /* logon time */
217         NTTIME logoff_time;           /* logoff time */
218         NTTIME kickoff_time;          /* kickoff time */
219         NTTIME pass_last_set_time;    /* password last set time */
220         NTTIME pass_can_change_time;  /* password can change time */
221         NTTIME pass_must_change_time; /* password must change time */
222
223         UNIHDR hdr_user_name;    /* username unicode string header */
224         UNIHDR hdr_full_name;    /* user's full name unicode string header */
225         UNIHDR hdr_logon_script; /* logon script unicode string header */
226         UNIHDR hdr_profile_path; /* profile path unicode string header */
227         UNIHDR hdr_home_dir;     /* home directory unicode string header */
228         UNIHDR hdr_dir_drive;    /* home directory drive unicode string header */
229
230         uint16 logon_count;  /* logon count */
231         uint16 bad_pw_count; /* bad password count */
232
233         uint32 user_rid;       /* User RID */
234         uint32 group_rid;      /* Group RID */
235
236         uint32 num_groups;    /* num groups */
237         uint32 buffer_groups; /* undocumented buffer pointer to groups. */
238         uint32 user_flgs;     /* user flags */
239
240         uint8 user_sess_key[16]; /* user session key */
241
242         UNIHDR hdr_logon_srv; /* logon server unicode string header */
243         UNIHDR hdr_logon_dom; /* logon domain unicode string header */
244
245         uint32 buffer_dom_id; /* undocumented logon domain id pointer */
246         uint8 lm_sess_key[8];   /* lm session key */
247         uint32 acct_flags;      /* account flags */
248         uint32 unknown[7];      /* unknown */
249
250         uint32 num_other_sids; /* number of foreign/trusted domain sids */
251         uint32 buffer_other_sids;
252         
253         /* The next three uint32 are not really part of user_info_3 but here
254          * for parsing convenience.  They are only valid in Kerberos PAC
255          * parsing - Guenther */
256         uint32 ptr_res_group_dom_sid;
257         uint32 res_group_count;
258         uint32 ptr_res_groups;
259
260         UNISTR2 uni_user_name;    /* username unicode string */
261         UNISTR2 uni_full_name;    /* user's full name unicode string */
262         UNISTR2 uni_logon_script; /* logon script unicode string */
263         UNISTR2 uni_profile_path; /* profile path unicode string */
264         UNISTR2 uni_home_dir;     /* home directory unicode string */
265         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
266
267         uint32 num_groups2;        /* num groups */
268         DOM_GID *gids; /* group info */
269
270         UNISTR2 uni_logon_srv; /* logon server unicode string */
271         UNISTR2 uni_logon_dom; /* logon domain unicode string */
272
273         DOM_SID2 dom_sid;           /* domain SID */
274
275         DOM_SID2 *other_sids; /* foreign/trusted domain SIDs */
276         uint32 *other_sids_attrib;
277 } NET_USER_INFO_3;
278
279 /* NEG_FLAGS */
280 typedef struct neg_flags_info {
281         uint32 neg_flags; /* negotiated flags */
282 } NEG_FLAGS;
283
284
285 /* NET_Q_REQ_CHAL */
286 typedef struct net_q_req_chal_info {
287         uint32  undoc_buffer; /* undocumented buffer pointer */
288         UNISTR2 uni_logon_srv; /* logon server unicode string */
289         UNISTR2 uni_logon_clnt; /* logon client unicode string */
290         DOM_CHAL clnt_chal; /* client challenge */
291 } NET_Q_REQ_CHAL;
292
293
294 /* NET_R_REQ_CHAL */
295 typedef struct net_r_req_chal_info {
296         DOM_CHAL srv_chal; /* server challenge */
297         NTSTATUS status; /* return code */
298 } NET_R_REQ_CHAL;
299
300 /* NET_Q_AUTH */
301 typedef struct net_q_auth_info {
302         DOM_LOG_INFO clnt_id; /* client identification info */
303         DOM_CHAL clnt_chal;     /* client-calculated credentials */
304 } NET_Q_AUTH;
305
306 /* NET_R_AUTH */
307 typedef struct net_r_auth_info {
308         DOM_CHAL srv_chal;     /* server-calculated credentials */
309         NTSTATUS status; /* return code */
310 } NET_R_AUTH;
311
312 /* NET_Q_AUTH_2 */
313 typedef struct net_q_auth2_info {
314         DOM_LOG_INFO clnt_id; /* client identification info */
315         DOM_CHAL clnt_chal;     /* client-calculated credentials */
316
317         NEG_FLAGS clnt_flgs; /* usually 0x0000 01ff */
318 } NET_Q_AUTH_2;
319
320
321 /* NET_R_AUTH_2 */
322 typedef struct net_r_auth2_info {
323         DOM_CHAL srv_chal;     /* server-calculated credentials */
324         NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */
325         NTSTATUS status; /* return code */
326 } NET_R_AUTH_2;
327
328 /* NET_Q_AUTH_3 */
329 typedef struct net_q_auth3_info {
330         DOM_LOG_INFO clnt_id;   /* client identification info */
331         DOM_CHAL clnt_chal;             /* client-calculated credentials */
332         NEG_FLAGS clnt_flgs;    /* usually 0x6007 ffff */
333 } NET_Q_AUTH_3;
334
335 /* NET_R_AUTH_3 */
336 typedef struct net_r_auth3_info {
337         DOM_CHAL srv_chal;      /* server-calculated credentials */
338         NEG_FLAGS srv_flgs;     /* usually 0x6007 ffff */
339         uint32 unknown;         /* 0x0000045b */
340         NTSTATUS status;        /* return code */
341 } NET_R_AUTH_3;
342
343
344 /* NET_Q_SRV_PWSET */
345 typedef struct net_q_srv_pwset_info {
346         DOM_CLNT_INFO clnt_id; /* client identification/authentication info */
347         uint8 pwd[16]; /* new password - undocumented. */
348 } NET_Q_SRV_PWSET;
349     
350 /* NET_R_SRV_PWSET */
351 typedef struct net_r_srv_pwset_info {
352         DOM_CRED srv_cred;     /* server-calculated credentials */
353
354         NTSTATUS status; /* return code */
355 } NET_R_SRV_PWSET;
356
357 /* NET_ID_INFO_2 */
358 typedef struct net_network_info_2 {
359         uint32            ptr_id_info2;        /* pointer to id_info_2 */
360         UNIHDR            hdr_domain_name;     /* domain name unicode header */
361         uint32            param_ctrl;          /* param control (0x2) */
362         DOM_LOGON_ID      logon_id;            /* logon ID */
363         UNIHDR            hdr_user_name;       /* user name unicode header */
364         UNIHDR            hdr_wksta_name;      /* workstation name unicode header */
365         uint8             lm_chal[8];          /* lan manager 8 byte challenge */
366         STRHDR            hdr_nt_chal_resp;    /* nt challenge response */
367         STRHDR            hdr_lm_chal_resp;    /* lm challenge response */
368
369         UNISTR2           uni_domain_name;     /* domain name unicode string */
370         UNISTR2           uni_user_name;       /* user name unicode string */
371         UNISTR2           uni_wksta_name;      /* workgroup name unicode string */
372         STRING2           nt_chal_resp;        /* nt challenge response */
373         STRING2           lm_chal_resp;        /* lm challenge response */
374 } NET_ID_INFO_2;
375
376 /* NET_ID_INFO_1 */
377 typedef struct id_info_1 {
378         uint32            ptr_id_info1;        /* pointer to id_info_1 */
379         UNIHDR            hdr_domain_name;     /* domain name unicode header */
380         uint32            param_ctrl;          /* param control */
381         DOM_LOGON_ID      logon_id;            /* logon ID */
382         UNIHDR            hdr_user_name;       /* user name unicode header */
383         UNIHDR            hdr_wksta_name;      /* workstation name unicode header */
384         OWF_INFO          lm_owf;              /* LM OWF Password */
385         OWF_INFO          nt_owf;              /* NT OWF Password */
386         UNISTR2           uni_domain_name;     /* domain name unicode string */
387         UNISTR2           uni_user_name;       /* user name unicode string */
388         UNISTR2           uni_wksta_name;      /* workgroup name unicode string */
389 } NET_ID_INFO_1;
390
391 #define INTERACTIVE_LOGON_TYPE 1
392 #define NET_LOGON_TYPE 2
393
394 /* NET_ID_INFO_CTR */
395 typedef struct net_id_info_ctr_info {
396         uint16         switch_value;
397   
398         union {
399                 NET_ID_INFO_1 id1; /* auth-level 1 - interactive user login */
400                 NET_ID_INFO_2 id2; /* auth-level 2 - workstation referred login */
401         } auth;
402 } NET_ID_INFO_CTR;
403
404 /* SAM_INFO - sam logon/off id structure */
405 typedef struct sam_info {
406         DOM_CLNT_INFO2  client;
407         uint32          ptr_rtn_cred; /* pointer to return credentials */
408         DOM_CRED        rtn_cred; /* return credentials */
409         uint16          logon_level;
410         NET_ID_INFO_CTR *ctr;
411 } DOM_SAM_INFO;
412
413 /* SAM_INFO - sam logon/off id structure - no creds */
414 typedef struct sam_info_ex {
415         DOM_CLNT_SRV    client;
416         uint16          logon_level;
417         NET_ID_INFO_CTR *ctr;
418 } DOM_SAM_INFO_EX;
419
420 /* NET_Q_SAM_LOGON */
421 typedef struct net_q_sam_logon_info {
422         DOM_SAM_INFO sam_id;
423         uint16          validation_level;
424 } NET_Q_SAM_LOGON;
425
426 /* NET_Q_SAM_LOGON_EX */
427 typedef struct net_q_sam_logon_info_ex {
428         DOM_SAM_INFO_EX sam_id;
429         uint16          validation_level;
430         uint32 flags;
431 } NET_Q_SAM_LOGON_EX;
432
433 /* NET_R_SAM_LOGON */
434 typedef struct net_r_sam_logon_info {
435         uint32 buffer_creds; /* undocumented buffer pointer */
436         DOM_CRED srv_creds; /* server credentials.  server time stamp appears to be ignored. */
437     
438         uint16 switch_value; /* 3 - indicates type of USER INFO */
439         NET_USER_INFO_3 *user;
440
441         uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
442
443         NTSTATUS status; /* return code */
444 } NET_R_SAM_LOGON;
445
446 /* NET_R_SAM_LOGON_EX */
447 typedef struct net_r_sam_logon_info_ex {
448         uint16 switch_value; /* 3 - indicates type of USER INFO */
449         NET_USER_INFO_3 *user;
450
451         uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
452         uint32 flags;
453
454         NTSTATUS status; /* return code */
455 } NET_R_SAM_LOGON_EX;
456
457
458 /* NET_Q_SAM_LOGOFF */
459 typedef struct net_q_sam_logoff_info {
460         DOM_SAM_INFO sam_id;
461 } NET_Q_SAM_LOGOFF;
462
463 /* NET_R_SAM_LOGOFF */
464 typedef struct net_r_sam_logoff_info {
465         uint32 buffer_creds; /* undocumented buffer pointer */
466         DOM_CRED srv_creds; /* server credentials.  server time stamp appears to be ignored. */
467         NTSTATUS status; /* return code */
468 } NET_R_SAM_LOGOFF;
469
470 /* NET_Q_SAM_SYNC */
471 typedef struct net_q_sam_sync_info {
472         UNISTR2 uni_srv_name; /* \\PDC */
473         UNISTR2 uni_cli_name; /* BDC */
474         DOM_CRED cli_creds;
475         DOM_CRED ret_creds;
476
477         uint32 database_id;
478         uint32 restart_state;
479         uint32 sync_context;
480
481         uint32 max_size;       /* preferred maximum length */
482 } NET_Q_SAM_SYNC;
483
484 /* SAM_DELTA_HDR */
485 typedef struct sam_delta_hdr_info {
486         uint16 type;  /* type of structure attached */
487         uint16 type2;
488         uint32 target_rid;
489
490         uint32 type3;
491         uint32 ptr_delta;
492 } SAM_DELTA_HDR;
493
494 /* LOCKOUT_STRING */
495 typedef struct account_lockout_string {
496         uint32 array_size;
497         uint32 offset;
498         uint32 length;
499 /*      uint16 *bindata;        */
500         uint64 lockout_duration;
501         uint64 reset_count;
502         uint32 bad_attempt_lockout;
503         uint32 dummy;
504 } LOCKOUT_STRING;
505
506 /* HDR_LOCKOUT_STRING */
507 typedef struct hdr_account_lockout_string {
508         uint16 size;
509         uint16 length;
510         uint32 buffer;
511 } HDR_LOCKOUT_STRING;
512
513 /* SAM_DOMAIN_INFO (0x1) */
514 typedef struct sam_domain_info_info {
515         UNIHDR hdr_dom_name;
516         UNIHDR hdr_oem_info;
517
518         uint64 force_logoff;
519         uint16   min_pwd_len;
520         uint16   pwd_history_len;
521         uint64 max_pwd_age;
522         uint64 min_pwd_age;
523         uint64 dom_mod_count;
524         NTTIME   creation_time;
525         uint32   security_information;
526
527         BUFHDR4 hdr_sec_desc; /* security descriptor */
528
529         HDR_LOCKOUT_STRING hdr_account_lockout;
530
531         UNIHDR hdr_unknown2;
532         UNIHDR hdr_unknown3;
533         UNIHDR hdr_unknown4;
534
535         UNISTR2 uni_dom_name;
536         UNISTR2 buf_oem_info; 
537
538         RPC_DATA_BLOB buf_sec_desc;
539
540         LOCKOUT_STRING account_lockout;
541
542         UNISTR2 buf_unknown2;
543         UNISTR2 buf_unknown3;
544         UNISTR2 buf_unknown4;
545
546         uint32 logon_chgpass;
547         uint32 unknown6;
548         uint32 unknown7;
549         uint32 unknown8;
550 } SAM_DOMAIN_INFO;
551
552 /* SAM_GROUP_INFO (0x2) */
553 typedef struct sam_group_info_info {
554         UNIHDR hdr_grp_name;
555         DOM_GID gid;
556         UNIHDR hdr_grp_desc;
557         BUFHDR2 hdr_sec_desc;  /* security descriptor */
558         uint8 reserved[48];
559
560         UNISTR2 uni_grp_name;
561         UNISTR2 uni_grp_desc;
562         RPC_DATA_BLOB buf_sec_desc;
563 } SAM_GROUP_INFO;
564
565 /* SAM_PWD */
566 typedef struct sam_passwd_info {
567         /* this structure probably contains password history */
568         /* this is probably a count of lm/nt pairs */
569         uint32 unk_0; /* 0x0000 0002 */
570
571         UNIHDR hdr_lm_pwd;
572         uint8  buf_lm_pwd[16];
573
574         UNIHDR hdr_nt_pwd;
575         uint8  buf_nt_pwd[16];
576
577         UNIHDR hdr_empty_lm;
578         UNIHDR hdr_empty_nt;
579 } SAM_PWD;
580
581 /* SAM_ACCOUNT_INFO (0x5) */
582 typedef struct sam_account_info_info {
583         UNIHDR hdr_acct_name;
584         UNIHDR hdr_full_name;
585
586         uint32 user_rid;
587         uint32 group_rid;
588
589         UNIHDR hdr_home_dir;
590         UNIHDR hdr_dir_drive;
591         UNIHDR hdr_logon_script;
592         UNIHDR hdr_acct_desc;
593         UNIHDR hdr_workstations;
594
595         NTTIME logon_time;
596         NTTIME logoff_time;
597
598         uint32 logon_divs; /* 0xA8 */
599         uint32 ptr_logon_hrs;
600
601         uint16 bad_pwd_count;
602         uint16 logon_count;
603         NTTIME pwd_last_set_time;
604         NTTIME acct_expiry_time;
605
606         uint32 acb_info;
607         uint8 nt_pwd[16];
608         uint8 lm_pwd[16];
609         uint8 nt_pwd_present;
610         uint8 lm_pwd_present;
611         uint8 pwd_expired;
612
613         UNIHDR hdr_comment;
614         UNIHDR hdr_parameters;
615         uint16 country;
616         uint16 codepage;
617
618         BUFHDR2 hdr_sec_desc;  /* security descriptor */
619
620         UNIHDR  hdr_profile;
621         UNIHDR  hdr_reserved[3];  /* space for more strings */
622         uint32  dw_reserved[4];   /* space for more data - first two seem to
623                                      be an NTTIME */
624
625         UNISTR2 uni_acct_name;
626         UNISTR2 uni_full_name;
627         UNISTR2 uni_home_dir;
628         UNISTR2 uni_dir_drive;
629         UNISTR2 uni_logon_script;
630         UNISTR2 uni_acct_desc;
631         UNISTR2 uni_workstations;
632
633         uint32 unknown1; /* 0x4EC */
634         uint32 unknown2; /* 0 */
635
636         RPC_DATA_BLOB buf_logon_hrs;
637         UNISTR2 uni_comment;
638         UNISTR2 uni_parameters;
639         SAM_PWD pass;
640         RPC_DATA_BLOB buf_sec_desc;
641         UNISTR2 uni_profile;
642 } SAM_ACCOUNT_INFO;
643
644 /* SAM_GROUP_MEM_INFO (0x8) */
645 typedef struct sam_group_mem_info_info {
646         uint32 ptr_rids;
647         uint32 ptr_attribs;
648         uint32 num_members;
649         uint8 unknown[16];
650
651         uint32 num_members2;
652         uint32 *rids;
653
654         uint32 num_members3;
655         uint32 *attribs;
656
657 } SAM_GROUP_MEM_INFO;
658
659 /* SAM_ALIAS_INFO (0x9) */
660 typedef struct sam_alias_info_info {
661         UNIHDR hdr_als_name;
662         uint32 als_rid;
663         BUFHDR2 hdr_sec_desc;  /* security descriptor */
664         UNIHDR hdr_als_desc;
665         uint8 reserved[40];
666
667         UNISTR2 uni_als_name;
668         RPC_DATA_BLOB buf_sec_desc;
669         UNISTR2 uni_als_desc;
670 } SAM_ALIAS_INFO;
671
672 /* SAM_ALIAS_MEM_INFO (0xC) */
673 typedef struct sam_alias_mem_info_info {
674         uint32 num_members;
675         uint32 ptr_members;
676         uint8 unknown[16];
677
678         uint32 num_sids;
679         uint32 *ptr_sids;
680         DOM_SID2 *sids;
681 } SAM_ALIAS_MEM_INFO;
682
683
684 /* SAM_DELTA_POLICY (0x0D) */
685 typedef struct {
686         uint32   max_log_size; /* 0x5000 */
687         uint64 audit_retention_period; /* 0 */
688         uint32   auditing_mode; /* 0 */
689         uint32   num_events;
690         uint32   ptr_events;
691         UNIHDR   hdr_dom_name;
692         uint32   sid_ptr;
693
694         uint32   paged_pool_limit; /* 0x02000000 */
695         uint32   non_paged_pool_limit; /* 0x00100000 */
696         uint32   min_workset_size; /* 0x00010000 */
697         uint32   max_workset_size; /* 0x0f000000 */
698         uint32   page_file_limit; /* 0 */
699         uint64 time_limit; /* 0 */
700         NTTIME   modify_time; /* 0x3c*/
701         NTTIME   create_time; /* a7080110 */
702         BUFHDR2  hdr_sec_desc;
703
704         uint32   num_event_audit_options;
705         uint32   event_audit_option;
706
707         UNISTR2  domain_name;
708         DOM_SID2 domain_sid;
709
710         RPC_DATA_BLOB  buf_sec_desc;
711 } SAM_DELTA_POLICY;
712
713 /* SAM_DELTA_TRUST_DOMS */
714 typedef struct {
715         uint32 buf_size;
716         SEC_DESC *sec_desc;
717         DOM_SID2 sid;
718         UNIHDR hdr_domain;
719         
720         uint32 unknown0;
721         uint32 unknown1;
722         uint32 unknown2;
723         
724         uint32 buf_size2;
725         uint32 ptr;
726
727         uint32 unknown3;
728         UNISTR2 domain;
729 } SAM_DELTA_TRUSTDOMS;
730
731 /* SAM_DELTA_PRIVS (0x10) */
732 typedef struct {
733         DOM_SID2 sid;
734
735         uint32 priv_count;
736         uint32 priv_control;
737
738         uint32 priv_attr_ptr;
739         uint32 priv_name_ptr;
740
741         uint32   paged_pool_limit; /* 0x02000000 */
742         uint32   non_paged_pool_limit; /* 0x00100000 */
743         uint32   min_workset_size; /* 0x00010000 */
744         uint32   max_workset_size; /* 0x0f000000 */
745         uint32   page_file_limit; /* 0 */
746         uint64 time_limit; /* 0 */
747         uint32   system_flags; /* 1 */
748         BUFHDR2  hdr_sec_desc;
749         
750         uint32 buf_size2;
751         
752         uint32 attribute_count;
753         uint32 *attributes;
754         
755         uint32 privlist_count;
756         UNIHDR *hdr_privslist;
757         UNISTR2 *uni_privslist;
758
759         RPC_DATA_BLOB buf_sec_desc;
760 } SAM_DELTA_PRIVS;
761
762 /* SAM_DELTA_SECRET */
763 typedef struct {
764         uint32 buf_size;
765         SEC_DESC *sec_desc;
766         UNISTR2 secret;
767
768         uint32 count1;
769         uint32 count2;
770         uint32 ptr;
771         NTTIME time1;
772         uint32 count3;
773         uint32 count4;
774         uint32 ptr2;
775         NTTIME time2;
776         uint32 unknow1;
777
778         uint32 buf_size2;
779         uint32 ptr3;
780         uint32 unknow2; /* 0x0 12 times */
781
782         uint32 chal_len;
783         uint32 reserved1; /* 0 */
784         uint32 chal_len2;
785         uint8 chal[16];
786
787         uint32 key_len;
788         uint32 reserved2; /* 0 */
789         uint32 key_len2;
790         uint8 key[8];
791
792         uint32 buf_size3;
793         SEC_DESC *sec_desc2;
794 } SAM_DELTA_SECRET;
795
796 /* SAM_DELTA_MOD_COUNT (0x16) */
797 typedef struct {
798         uint32 seqnum;
799         uint32 dom_mod_count_ptr;
800         uint64 dom_mod_count;  /* domain mod count at last sync */
801 } SAM_DELTA_MOD_COUNT;
802
803 typedef union sam_delta_ctr_info {
804         SAM_DOMAIN_INFO    domain_info ;
805         SAM_GROUP_INFO     group_info  ;
806         SAM_ACCOUNT_INFO   account_info;
807         SAM_GROUP_MEM_INFO grp_mem_info;
808         SAM_ALIAS_INFO     alias_info  ;
809         SAM_ALIAS_MEM_INFO als_mem_info;
810         SAM_DELTA_POLICY   policy_info;
811         SAM_DELTA_PRIVS    privs_info;
812         SAM_DELTA_MOD_COUNT mod_count;
813         SAM_DELTA_TRUSTDOMS trustdoms_info;
814         SAM_DELTA_SECRET   secret_info;
815 } SAM_DELTA_CTR;
816
817 /* NET_R_SAM_SYNC */
818 typedef struct net_r_sam_sync_info {
819         DOM_CRED srv_creds;
820
821         uint32 sync_context;
822
823         uint32 ptr_deltas;
824         uint32 num_deltas;
825         uint32 ptr_deltas2;
826         uint32 num_deltas2;
827
828         SAM_DELTA_HDR *hdr_deltas;
829         SAM_DELTA_CTR *deltas;
830
831         NTSTATUS status;
832 } NET_R_SAM_SYNC;
833
834 /* NET_Q_SAM_DELTAS */
835 typedef struct net_q_sam_deltas_info {
836         UNISTR2 uni_srv_name;
837         UNISTR2 uni_cli_name;
838         DOM_CRED cli_creds;
839         DOM_CRED ret_creds;
840
841         uint32 database_id;
842         uint64 dom_mod_count;  /* domain mod count at last sync */
843
844         uint32 max_size;       /* preferred maximum length */
845 } NET_Q_SAM_DELTAS;
846
847 /* NET_R_SAM_DELTAS */
848 typedef struct net_r_sam_deltas_info {
849         DOM_CRED srv_creds;
850
851         uint64 dom_mod_count;   /* new domain mod count */
852
853         uint32 ptr_deltas;
854         uint32 num_deltas;
855         uint32 num_deltas2;
856
857         SAM_DELTA_HDR *hdr_deltas;
858         SAM_DELTA_CTR *deltas;
859
860         NTSTATUS status;
861 } NET_R_SAM_DELTAS;
862
863 #define DSGETDC_VALID_FLAGS ( \
864     DS_FORCE_REDISCOVERY | \
865     DS_DIRECTORY_SERVICE_REQUIRED | \
866     DS_DIRECTORY_SERVICE_PREFERRED | \
867     DS_GC_SERVER_REQUIRED | \
868     DS_PDC_REQUIRED | \
869     DS_BACKGROUND_ONLY | \
870     DS_IP_REQUIRED | \
871     DS_KDC_REQUIRED | \
872     DS_TIMESERV_REQUIRED | \
873     DS_WRITABLE_REQUIRED | \
874     DS_GOOD_TIMESERV_PREFERRED | \
875     DS_AVOID_SELF | \
876     DS_ONLY_LDAP_NEEDED | \
877     DS_IS_FLAT_NAME | \
878     DS_IS_DNS_NAME | \
879     DS_RETURN_FLAT_NAME  | \
880     DS_RETURN_DNS_NAME )
881
882 struct DS_DOMAIN_CONTROLLER_INFO {
883         const char *domain_controller_name;
884         const char *domain_controller_address;
885         int32 domain_controller_address_type;
886         struct GUID *domain_guid;
887         const char *domain_name;
888         const char *dns_forest_name;
889         uint32 flags;
890         const char *dc_site_name;
891         const char *client_site_name;
892 };
893
894 #endif /* _RPC_NETLOGON_H */