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