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