r11573: Adding Andrew Bartlett's patch to make machine account
[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 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_AUTH3               0x1a
42
43 /* Secure Channel types.  used in NetrServerAuthenticate negotiation */
44 #define SEC_CHAN_WKSTA   2
45 #define SEC_CHAN_DOMAIN  4
46 #define SEC_CHAN_BDC     6
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 /* SAM database types */
67 #define SAM_DATABASE_DOMAIN    0x00 /* Domain users and groups */
68 #define SAM_DATABASE_BUILTIN   0x01 /* BUILTIN users and groups */
69 #define SAM_DATABASE_PRIVS     0x02 /* Privileges */
70
71 /* flags use when sending a NETLOGON_CONTROL request */
72
73 #define NETLOGON_CONTROL_SYNC                   0x2
74 #define NETLOGON_CONTROL_REDISCOVER             0x5
75 #define NETLOGON_CONTROL_TC_QUERY               0x6
76 #define NETLOGON_CONTROL_TRANSPORT_NOTIFY       0x7
77 #define NETLOGON_CONTROL_SET_DBFLAG             0xfffe
78
79 /* Some flag values reverse engineered from NLTEST.EXE */
80 /* used in the NETLOGON_CONTROL[2] reply */
81
82 #define NL_CTRL_IN_SYNC          0x0000
83 #define NL_CTRL_REPL_NEEDED      0x0001
84 #define NL_CTRL_REPL_IN_PROGRESS 0x0002
85 #define NL_CTRL_FULL_SYNC        0x0004
86
87 #define LOGON_EXTRA_SIDS             0x0020
88 #define LOGON_RESOURCE_GROUPS        0x0200 
89
90 #define SE_GROUP_MANDATORY              0x00000001
91 #define SE_GROUP_ENABLED_BY_DEFAULT     0x00000002
92 #define SE_GROUP_ENABLED                0x00000004
93 #define SE_GROUP_OWNER                  0x00000008
94 #define SE_GROUP_USE_FOR_DENY_ONLY      0x00000010
95 #define SE_GROUP_LOGON_ID               0xC0000000
96 #define SE_GROUP_RESOURCE               0x20000000
97
98 /* Flags for controlling the behaviour of a particular logon */
99 #define MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT       ( 0x020 )
100 #define MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT  ( 0x800 )
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_3 */
162 typedef struct net_user_info_3 {
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         uint32 num_other_sids; /* number of foreign/trusted domain sids */
200         uint32 buffer_other_sids;
201         
202         /* The next three uint32 are not really part of user_info_3 but here
203          * for parsing convenience.  They are only valid in Kerberos PAC
204          * parsing - Guenther */
205         uint32 ptr_res_group_dom_sid;
206         uint32 res_group_count;
207         uint32 ptr_res_groups;
208
209         UNISTR2 uni_user_name;    /* username unicode string */
210         UNISTR2 uni_full_name;    /* user's full name unicode string */
211         UNISTR2 uni_logon_script; /* logon script unicode string */
212         UNISTR2 uni_profile_path; /* profile path unicode string */
213         UNISTR2 uni_home_dir;     /* home directory unicode string */
214         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
215
216         uint32 num_groups2;        /* num groups */
217         DOM_GID *gids; /* group info */
218
219         UNISTR2 uni_logon_srv; /* logon server unicode string */
220         UNISTR2 uni_logon_dom; /* logon domain unicode string */
221
222         DOM_SID2 dom_sid;           /* domain SID */
223
224         DOM_SID2 *other_sids; /* foreign/trusted domain SIDs */
225         uint32 *other_sids_attrib;
226 } NET_USER_INFO_3;
227
228
229 /* NETLOGON_INFO_1 - pdc status info, i presume */
230 typedef struct netlogon_1_info {
231         uint32 flags;            /* 0x0 - undocumented */
232         uint32 pdc_status;       /* 0x0 - undocumented */
233 } NETLOGON_INFO_1;
234
235 /* NETLOGON_INFO_2 - pdc status info, plus trusted domain info */
236 typedef struct netlogon_2_info {
237         uint32  flags;            /* 0x0 - undocumented */
238         uint32  pdc_status;       /* 0x0 - undocumented */
239         uint32  ptr_trusted_dc_name; /* pointer to trusted domain controller name */
240         uint32  tc_status;           
241         UNISTR2 uni_trusted_dc_name; /* unicode string - trusted dc name */
242 } NETLOGON_INFO_2;
243
244 /* NETLOGON_INFO_3 - logon status info, i presume */
245 typedef struct netlogon_3_info {
246         uint32 flags;            /* 0x0 - undocumented */
247         uint32 logon_attempts;   /* number of logon attempts */
248         uint32 reserved_1;       /* 0x0 - undocumented */
249         uint32 reserved_2;       /* 0x0 - undocumented */
250         uint32 reserved_3;       /* 0x0 - undocumented */
251         uint32 reserved_4;       /* 0x0 - undocumented */
252         uint32 reserved_5;       /* 0x0 - undocumented */
253 } NETLOGON_INFO_3;
254
255 /********************************************************
256  Logon Control Query
257
258  This is generated by a nltest /bdc_query:DOMAIN
259
260  query_level 0x1, function_code 0x1
261
262  ********************************************************/
263
264 /* NET_Q_LOGON_CTRL - LSA Netr Logon Control */
265
266 typedef struct net_q_logon_ctrl_info {
267         uint32 ptr;
268         UNISTR2 uni_server_name;
269         uint32 function_code;
270         uint32 query_level;
271 } NET_Q_LOGON_CTRL;
272
273 /* NET_R_LOGON_CTRL - LSA Netr Logon Control */
274
275 typedef struct net_r_logon_ctrl_info {
276         uint32 switch_value;
277         uint32 ptr;
278
279         union {
280                 NETLOGON_INFO_1 info1;
281         } logon;
282
283         NTSTATUS status;
284 } NET_R_LOGON_CTRL;
285
286
287 typedef struct ctrl_data_info_5 {
288         uint32          function_code;
289         
290         uint32          ptr_domain;
291         UNISTR2         domain;
292 } CTRL_DATA_INFO_5;
293
294 typedef struct ctrl_data_info_6 {
295         uint32          function_code;
296         
297         uint32          ptr_domain;
298         UNISTR2         domain;
299 } CTRL_DATA_INFO_6;
300
301
302 /********************************************************
303  Logon Control2 Query
304
305  query_level 0x1 - pdc status
306  query_level 0x3 - number of logon attempts.
307
308  ********************************************************/
309
310 /* NET_Q_LOGON_CTRL2 - LSA Netr Logon Control 2 */
311 typedef struct net_q_logon_ctrl2_info {
312         uint32          ptr;             /* undocumented buffer pointer */
313         UNISTR2         uni_server_name; /* server name, starting with two '\'s */
314         
315         uint32          function_code; 
316         uint32          query_level;   
317         union {
318                 CTRL_DATA_INFO_5 info5;
319                 CTRL_DATA_INFO_6 info6;
320         } info;
321 } NET_Q_LOGON_CTRL2;
322
323 /*******************************************************
324  Logon Control Response
325
326  switch_value is same as query_level in request 
327  *******************************************************/
328
329 /* NET_R_LOGON_CTRL2 - response to LSA Logon Control2 */
330 typedef struct net_r_logon_ctrl2_info {
331         uint32       switch_value;  /* 0x1, 0x3 */
332         uint32       ptr;
333
334         union
335         {
336                 NETLOGON_INFO_1 info1;
337                 NETLOGON_INFO_2 info2;
338                 NETLOGON_INFO_3 info3;
339
340         } logon;
341
342         NTSTATUS status; /* return code */
343 } NET_R_LOGON_CTRL2;
344
345 /* NET_Q_GETDCNAME - Ask a DC for a trusted DC name */
346
347 typedef struct net_q_getdcname {
348         uint32  ptr_logon_server;
349         UNISTR2 uni_logon_server;
350         uint32  ptr_domainname;
351         UNISTR2 uni_domainname;
352 } NET_Q_GETDCNAME;
353
354 /* NET_R_GETDCNAME - Ask a DC for a trusted DC name */
355
356 typedef struct net_r_getdcname {
357         uint32  ptr_dcname;
358         UNISTR2 uni_dcname;
359         NTSTATUS status;
360 } NET_R_GETDCNAME;
361
362 /* NET_Q_TRUST_DOM_LIST - LSA Query Trusted Domains */
363 typedef struct net_q_trust_dom_info {
364         uint32       ptr;             /* undocumented buffer pointer */
365         UNISTR2      uni_server_name; /* server name, starting with two '\'s */
366 } NET_Q_TRUST_DOM_LIST;
367
368 #define MAX_TRUST_DOMS 1
369
370 /* NET_R_TRUST_DOM_LIST - response to LSA Trusted Domains */
371 typedef struct net_r_trust_dom_info {
372         UNISTR2 uni_trust_dom_name[MAX_TRUST_DOMS];
373
374         NTSTATUS status; /* return code */
375 } NET_R_TRUST_DOM_LIST;
376
377
378 /* NEG_FLAGS */
379 typedef struct neg_flags_info {
380         uint32 neg_flags; /* negotiated flags */
381 } NEG_FLAGS;
382
383
384 /* NET_Q_REQ_CHAL */
385 typedef struct net_q_req_chal_info {
386         uint32  undoc_buffer; /* undocumented buffer pointer */
387         UNISTR2 uni_logon_srv; /* logon server unicode string */
388         UNISTR2 uni_logon_clnt; /* logon client unicode string */
389         DOM_CHAL clnt_chal; /* client challenge */
390 } NET_Q_REQ_CHAL;
391
392
393 /* NET_R_REQ_CHAL */
394 typedef struct net_r_req_chal_info {
395         DOM_CHAL srv_chal; /* server challenge */
396         NTSTATUS status; /* return code */
397 } NET_R_REQ_CHAL;
398
399 /* NET_Q_AUTH */
400 typedef struct net_q_auth_info {
401         DOM_LOG_INFO clnt_id; /* client identification info */
402         DOM_CHAL clnt_chal;     /* client-calculated credentials */
403 } NET_Q_AUTH;
404
405 /* NET_R_AUTH */
406 typedef struct net_r_auth_info {
407         DOM_CHAL srv_chal;     /* server-calculated credentials */
408         NTSTATUS status; /* return code */
409 } NET_R_AUTH;
410
411 /* NET_Q_AUTH_2 */
412 typedef struct net_q_auth2_info {
413         DOM_LOG_INFO clnt_id; /* client identification info */
414         DOM_CHAL clnt_chal;     /* client-calculated credentials */
415
416         NEG_FLAGS clnt_flgs; /* usually 0x0000 01ff */
417 } NET_Q_AUTH_2;
418
419
420 /* NET_R_AUTH_2 */
421 typedef struct net_r_auth2_info {
422         DOM_CHAL srv_chal;     /* server-calculated credentials */
423         NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */
424         NTSTATUS status; /* return code */
425 } NET_R_AUTH_2;
426
427 /* NET_Q_AUTH_3 */
428 typedef struct net_q_auth3_info {
429         DOM_LOG_INFO clnt_id;   /* client identification info */
430         DOM_CHAL clnt_chal;             /* client-calculated credentials */
431         NEG_FLAGS clnt_flgs;    /* usually 0x6007 ffff */
432 } NET_Q_AUTH_3;
433
434 /* NET_R_AUTH_3 */
435 typedef struct net_r_auth3_info {
436         DOM_CHAL srv_chal;      /* server-calculated credentials */
437         NEG_FLAGS srv_flgs;     /* usually 0x6007 ffff */
438         uint32 unknown;         /* 0x0000045b */
439         NTSTATUS status;        /* return code */
440 } NET_R_AUTH_3;
441
442
443 /* NET_Q_SRV_PWSET */
444 typedef struct net_q_srv_pwset_info {
445         DOM_CLNT_INFO clnt_id; /* client identification/authentication info */
446         uint8 pwd[16]; /* new password - undocumented. */
447 } NET_Q_SRV_PWSET;
448     
449 /* NET_R_SRV_PWSET */
450 typedef struct net_r_srv_pwset_info {
451         DOM_CRED srv_cred;     /* server-calculated credentials */
452
453         NTSTATUS status; /* return code */
454 } NET_R_SRV_PWSET;
455
456 /* NET_ID_INFO_2 */
457 typedef struct net_network_info_2 {
458         uint32            ptr_id_info2;        /* pointer to id_info_2 */
459         UNIHDR            hdr_domain_name;     /* domain name unicode header */
460         uint32            param_ctrl;          /* param control (0x2) */
461         DOM_LOGON_ID      logon_id;            /* logon ID */
462         UNIHDR            hdr_user_name;       /* user name unicode header */
463         UNIHDR            hdr_wksta_name;      /* workstation name unicode header */
464         uint8             lm_chal[8];          /* lan manager 8 byte challenge */
465         STRHDR            hdr_nt_chal_resp;    /* nt challenge response */
466         STRHDR            hdr_lm_chal_resp;    /* lm challenge response */
467
468         UNISTR2           uni_domain_name;     /* domain name unicode string */
469         UNISTR2           uni_user_name;       /* user name unicode string */
470         UNISTR2           uni_wksta_name;      /* workgroup name unicode string */
471         STRING2           nt_chal_resp;        /* nt challenge response */
472         STRING2           lm_chal_resp;        /* lm challenge response */
473 } NET_ID_INFO_2;
474
475 /* NET_ID_INFO_1 */
476 typedef struct id_info_1 {
477         uint32            ptr_id_info1;        /* pointer to id_info_1 */
478         UNIHDR            hdr_domain_name;     /* domain name unicode header */
479         uint32            param_ctrl;          /* param control */
480         DOM_LOGON_ID      logon_id;            /* logon ID */
481         UNIHDR            hdr_user_name;       /* user name unicode header */
482         UNIHDR            hdr_wksta_name;      /* workstation name unicode header */
483         OWF_INFO          lm_owf;              /* LM OWF Password */
484         OWF_INFO          nt_owf;              /* NT OWF Password */
485         UNISTR2           uni_domain_name;     /* domain name unicode string */
486         UNISTR2           uni_user_name;       /* user name unicode string */
487         UNISTR2           uni_wksta_name;      /* workgroup name unicode string */
488 } NET_ID_INFO_1;
489
490 #define INTERACTIVE_LOGON_TYPE 1
491 #define NET_LOGON_TYPE 2
492
493 /* NET_ID_INFO_CTR */
494 typedef struct net_id_info_ctr_info {
495         uint16         switch_value;
496   
497         union {
498                 NET_ID_INFO_1 id1; /* auth-level 1 - interactive user login */
499                 NET_ID_INFO_2 id2; /* auth-level 2 - workstation referred login */
500         } auth;
501 } NET_ID_INFO_CTR;
502
503 /* SAM_INFO - sam logon/off id structure */
504 typedef struct sam_info {
505         DOM_CLNT_INFO2  client;
506         uint32          ptr_rtn_cred; /* pointer to return credentials */
507         DOM_CRED        rtn_cred; /* return credentials */
508         uint16          logon_level;
509         NET_ID_INFO_CTR *ctr;
510 } DOM_SAM_INFO;
511
512 /* NET_Q_SAM_LOGON */
513 typedef struct net_q_sam_logon_info {
514         DOM_SAM_INFO sam_id;
515         uint16          validation_level;
516 } NET_Q_SAM_LOGON;
517
518 /* NET_R_SAM_LOGON */
519 typedef struct net_r_sam_logon_info {
520         uint32 buffer_creds; /* undocumented buffer pointer */
521         DOM_CRED srv_creds; /* server credentials.  server time stamp appears to be ignored. */
522     
523         uint16 switch_value; /* 3 - indicates type of USER INFO */
524         NET_USER_INFO_3 *user;
525
526         uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
527
528         NTSTATUS status; /* return code */
529 } NET_R_SAM_LOGON;
530
531
532 /* NET_Q_SAM_LOGOFF */
533 typedef struct net_q_sam_logoff_info {
534         DOM_SAM_INFO sam_id;
535 } NET_Q_SAM_LOGOFF;
536
537 /* NET_R_SAM_LOGOFF */
538 typedef struct net_r_sam_logoff_info {
539         uint32 buffer_creds; /* undocumented buffer pointer */
540         DOM_CRED srv_creds; /* server credentials.  server time stamp appears to be ignored. */
541         NTSTATUS status; /* return code */
542 } NET_R_SAM_LOGOFF;
543
544 /* NET_Q_SAM_SYNC */
545 typedef struct net_q_sam_sync_info {
546         UNISTR2 uni_srv_name; /* \\PDC */
547         UNISTR2 uni_cli_name; /* BDC */
548         DOM_CRED cli_creds;
549         DOM_CRED ret_creds;
550
551         uint32 database_id;
552         uint32 restart_state;
553         uint32 sync_context;
554
555         uint32 max_size;       /* preferred maximum length */
556 } NET_Q_SAM_SYNC;
557
558 /* SAM_DELTA_HDR */
559 typedef struct sam_delta_hdr_info {
560         uint16 type;  /* type of structure attached */
561         uint16 type2;
562         uint32 target_rid;
563
564         uint32 type3;
565         uint32 ptr_delta;
566 } SAM_DELTA_HDR;
567
568 /* LOCKOUT_STRING */
569 typedef struct account_lockout_string {
570         uint32 array_size;
571         uint32 offset;
572         uint32 length;
573 /*      uint16 *bindata;        */
574         UINT64_S lockout_duration;
575         UINT64_S reset_count;
576         uint32 bad_attempt_lockout;
577         uint32 dummy;
578 } LOCKOUT_STRING;
579
580 /* HDR_LOCKOUT_STRING */
581 typedef struct hdr_account_lockout_string {
582         uint16 size;
583         uint16 length;
584         uint32 buffer;
585 } HDR_LOCKOUT_STRING;
586
587 /* SAM_DOMAIN_INFO (0x1) */
588 typedef struct sam_domain_info_info {
589         UNIHDR hdr_dom_name;
590         UNIHDR hdr_oem_info;
591
592         UINT64_S force_logoff;
593         uint16   min_pwd_len;
594         uint16   pwd_history_len;
595         UINT64_S max_pwd_age;
596         UINT64_S min_pwd_age;
597         UINT64_S dom_mod_count;
598         NTTIME   creation_time;
599         uint32   security_information;
600
601         BUFHDR4 hdr_sec_desc; /* security descriptor */
602
603         HDR_LOCKOUT_STRING hdr_account_lockout;
604
605         UNIHDR hdr_unknown2;
606         UNIHDR hdr_unknown3;
607         UNIHDR hdr_unknown4;
608
609         UNISTR2 uni_dom_name;
610         UNISTR2 buf_oem_info; 
611
612         RPC_DATA_BLOB buf_sec_desc;
613
614         LOCKOUT_STRING account_lockout;
615
616         UNISTR2 buf_unknown2;
617         UNISTR2 buf_unknown3;
618         UNISTR2 buf_unknown4;
619
620         uint32 logon_chgpass;
621         uint32 unknown6;
622         uint32 unknown7;
623         uint32 unknown8;
624 } SAM_DOMAIN_INFO;
625
626 /* SAM_GROUP_INFO (0x2) */
627 typedef struct sam_group_info_info {
628         UNIHDR hdr_grp_name;
629         DOM_GID gid;
630         UNIHDR hdr_grp_desc;
631         BUFHDR2 hdr_sec_desc;  /* security descriptor */
632         uint8 reserved[48];
633
634         UNISTR2 uni_grp_name;
635         UNISTR2 uni_grp_desc;
636         RPC_DATA_BLOB buf_sec_desc;
637 } SAM_GROUP_INFO;
638
639 /* SAM_PWD */
640 typedef struct sam_passwd_info {
641         /* this structure probably contains password history */
642         /* this is probably a count of lm/nt pairs */
643         uint32 unk_0; /* 0x0000 0002 */
644
645         UNIHDR hdr_lm_pwd;
646         uint8  buf_lm_pwd[16];
647
648         UNIHDR hdr_nt_pwd;
649         uint8  buf_nt_pwd[16];
650
651         UNIHDR hdr_empty_lm;
652         UNIHDR hdr_empty_nt;
653 } SAM_PWD;
654
655 /* SAM_ACCOUNT_INFO (0x5) */
656 typedef struct sam_account_info_info {
657         UNIHDR hdr_acct_name;
658         UNIHDR hdr_full_name;
659
660         uint32 user_rid;
661         uint32 group_rid;
662
663         UNIHDR hdr_home_dir;
664         UNIHDR hdr_dir_drive;
665         UNIHDR hdr_logon_script;
666         UNIHDR hdr_acct_desc;
667         UNIHDR hdr_workstations;
668
669         NTTIME logon_time;
670         NTTIME logoff_time;
671
672         uint32 logon_divs; /* 0xA8 */
673         uint32 ptr_logon_hrs;
674
675         uint16 bad_pwd_count;
676         uint16 logon_count;
677         NTTIME pwd_last_set_time;
678         NTTIME acct_expiry_time;
679
680         uint32 acb_info;
681         uint8 nt_pwd[16];
682         uint8 lm_pwd[16];
683         uint8 nt_pwd_present;
684         uint8 lm_pwd_present;
685         uint8 pwd_expired;
686
687         UNIHDR hdr_comment;
688         UNIHDR hdr_parameters;
689         uint16 country;
690         uint16 codepage;
691
692         BUFHDR2 hdr_sec_desc;  /* security descriptor */
693
694         UNIHDR  hdr_profile;
695         UNIHDR  hdr_reserved[3];  /* space for more strings */
696         uint32  dw_reserved[4];   /* space for more data - first two seem to
697                                      be an NTTIME */
698
699         UNISTR2 uni_acct_name;
700         UNISTR2 uni_full_name;
701         UNISTR2 uni_home_dir;
702         UNISTR2 uni_dir_drive;
703         UNISTR2 uni_logon_script;
704         UNISTR2 uni_acct_desc;
705         UNISTR2 uni_workstations;
706
707         uint32 unknown1; /* 0x4EC */
708         uint32 unknown2; /* 0 */
709
710         RPC_DATA_BLOB buf_logon_hrs;
711         UNISTR2 uni_comment;
712         UNISTR2 uni_parameters;
713         SAM_PWD pass;
714         RPC_DATA_BLOB buf_sec_desc;
715         UNISTR2 uni_profile;
716 } SAM_ACCOUNT_INFO;
717
718 /* SAM_GROUP_MEM_INFO (0x8) */
719 typedef struct sam_group_mem_info_info {
720         uint32 ptr_rids;
721         uint32 ptr_attribs;
722         uint32 num_members;
723         uint8 unknown[16];
724
725         uint32 num_members2;
726         uint32 *rids;
727
728         uint32 num_members3;
729         uint32 *attribs;
730
731 } SAM_GROUP_MEM_INFO;
732
733 /* SAM_ALIAS_INFO (0x9) */
734 typedef struct sam_alias_info_info {
735         UNIHDR hdr_als_name;
736         uint32 als_rid;
737         BUFHDR2 hdr_sec_desc;  /* security descriptor */
738         UNIHDR hdr_als_desc;
739         uint8 reserved[40];
740
741         UNISTR2 uni_als_name;
742         RPC_DATA_BLOB buf_sec_desc;
743         UNISTR2 uni_als_desc;
744 } SAM_ALIAS_INFO;
745
746 /* SAM_ALIAS_MEM_INFO (0xC) */
747 typedef struct sam_alias_mem_info_info {
748         uint32 num_members;
749         uint32 ptr_members;
750         uint8 unknown[16];
751
752         uint32 num_sids;
753         uint32 *ptr_sids;
754         DOM_SID2 *sids;
755 } SAM_ALIAS_MEM_INFO;
756
757
758 /* SAM_DELTA_POLICY (0x0D) */
759 typedef struct {
760         uint32   max_log_size; /* 0x5000 */
761         UINT64_S audit_retention_period; /* 0 */
762         uint32   auditing_mode; /* 0 */
763         uint32   num_events;
764         uint32   ptr_events;
765         UNIHDR   hdr_dom_name;
766         uint32   sid_ptr;
767
768         uint32   paged_pool_limit; /* 0x02000000 */
769         uint32   non_paged_pool_limit; /* 0x00100000 */
770         uint32   min_workset_size; /* 0x00010000 */
771         uint32   max_workset_size; /* 0x0f000000 */
772         uint32   page_file_limit; /* 0 */
773         UINT64_S time_limit; /* 0 */
774         NTTIME   modify_time; /* 0x3c*/
775         NTTIME   create_time; /* a7080110 */
776         BUFHDR2  hdr_sec_desc;
777
778         uint32   num_event_audit_options;
779         uint32   event_audit_option;
780
781         UNISTR2  domain_name;
782         DOM_SID2 domain_sid;
783
784         RPC_DATA_BLOB  buf_sec_desc;
785 } SAM_DELTA_POLICY;
786
787 /* SAM_DELTA_TRUST_DOMS */
788 typedef struct {
789         uint32 buf_size;
790         SEC_DESC *sec_desc;
791         DOM_SID2 sid;
792         UNIHDR hdr_domain;
793         
794         uint32 unknown0;
795         uint32 unknown1;
796         uint32 unknown2;
797         
798         uint32 buf_size2;
799         uint32 ptr;
800
801         uint32 unknown3;
802         UNISTR2 domain;
803 } SAM_DELTA_TRUSTDOMS;
804
805 /* SAM_DELTA_PRIVS (0x10) */
806 typedef struct {
807         DOM_SID2 sid;
808
809         uint32 priv_count;
810         uint32 priv_control;
811
812         uint32 priv_attr_ptr;
813         uint32 priv_name_ptr;
814
815         uint32   paged_pool_limit; /* 0x02000000 */
816         uint32   non_paged_pool_limit; /* 0x00100000 */
817         uint32   min_workset_size; /* 0x00010000 */
818         uint32   max_workset_size; /* 0x0f000000 */
819         uint32   page_file_limit; /* 0 */
820         UINT64_S time_limit; /* 0 */
821         uint32   system_flags; /* 1 */
822         BUFHDR2  hdr_sec_desc;
823         
824         uint32 buf_size2;
825         
826         uint32 attribute_count;
827         uint32 *attributes;
828         
829         uint32 privlist_count;
830         UNIHDR *hdr_privslist;
831         UNISTR2 *uni_privslist;
832
833         RPC_DATA_BLOB buf_sec_desc;
834 } SAM_DELTA_PRIVS;
835
836 /* SAM_DELTA_SECRET */
837 typedef struct {
838         uint32 buf_size;
839         SEC_DESC *sec_desc;
840         UNISTR2 secret;
841
842         uint32 count1;
843         uint32 count2;
844         uint32 ptr;
845         NTTIME time1;
846         uint32 count3;
847         uint32 count4;
848         uint32 ptr2;
849         NTTIME time2;
850         uint32 unknow1;
851
852         uint32 buf_size2;
853         uint32 ptr3;
854         uint32 unknow2; /* 0x0 12 times */
855
856         uint32 chal_len;
857         uint32 reserved1; /* 0 */
858         uint32 chal_len2;
859         uint8 chal[16];
860
861         uint32 key_len;
862         uint32 reserved2; /* 0 */
863         uint32 key_len2;
864         uint8 key[8];
865
866         uint32 buf_size3;
867         SEC_DESC *sec_desc2;
868 } SAM_DELTA_SECRET;
869
870 /* SAM_DELTA_MOD_COUNT (0x16) */
871 typedef struct {
872         uint32 seqnum;
873         uint32 dom_mod_count_ptr;
874         UINT64_S dom_mod_count;  /* domain mod count at last sync */
875 } SAM_DELTA_MOD_COUNT;
876
877 typedef union sam_delta_ctr_info {
878         SAM_DOMAIN_INFO    domain_info ;
879         SAM_GROUP_INFO     group_info  ;
880         SAM_ACCOUNT_INFO   account_info;
881         SAM_GROUP_MEM_INFO grp_mem_info;
882         SAM_ALIAS_INFO     alias_info  ;
883         SAM_ALIAS_MEM_INFO als_mem_info;
884         SAM_DELTA_POLICY   policy_info;
885         SAM_DELTA_PRIVS    privs_info;
886         SAM_DELTA_MOD_COUNT mod_count;
887         SAM_DELTA_TRUSTDOMS trustdoms_info;
888         SAM_DELTA_SECRET   secret_info;
889 } SAM_DELTA_CTR;
890
891 /* NET_R_SAM_SYNC */
892 typedef struct net_r_sam_sync_info {
893         DOM_CRED srv_creds;
894
895         uint32 sync_context;
896
897         uint32 ptr_deltas;
898         uint32 num_deltas;
899         uint32 ptr_deltas2;
900         uint32 num_deltas2;
901
902         SAM_DELTA_HDR *hdr_deltas;
903         SAM_DELTA_CTR *deltas;
904
905         NTSTATUS status;
906 } NET_R_SAM_SYNC;
907
908 /* NET_Q_SAM_DELTAS */
909 typedef struct net_q_sam_deltas_info {
910         UNISTR2 uni_srv_name;
911         UNISTR2 uni_cli_name;
912         DOM_CRED cli_creds;
913         DOM_CRED ret_creds;
914
915         uint32 database_id;
916         UINT64_S dom_mod_count;  /* domain mod count at last sync */
917
918         uint32 max_size;       /* preferred maximum length */
919 } NET_Q_SAM_DELTAS;
920
921 /* NET_R_SAM_DELTAS */
922 typedef struct net_r_sam_deltas_info {
923         DOM_CRED srv_creds;
924
925         UINT64_S dom_mod_count;   /* new domain mod count */
926
927         uint32 ptr_deltas;
928         uint32 num_deltas;
929         uint32 num_deltas2;
930
931         SAM_DELTA_HDR *hdr_deltas;
932         SAM_DELTA_CTR *deltas;
933
934         NTSTATUS status;
935 } NET_R_SAM_DELTAS;
936
937 #endif /* _RPC_NETLOGON_H */