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