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