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