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