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