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