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