Changes to implement NET_AUTH based on NET_AUTH2, to get Win2000
[sfrench/samba-autobuild/.git] / source3 / include / rpc_netlogon.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    SMB parameters and setup
5    Copyright (C) Andrew Tridgell 1992-1997
6    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
7    Copyright (C) Paul Ashton 1997
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_REQCHAL            0x04
30 #define NET_SRVPWSET           0x06
31 #define NET_SAMLOGON           0x02
32 #define NET_SAMLOGOFF          0x03
33 #define NET_AUTH               0x05
34 #define NET_AUTH2              0x0f
35 #define NET_LOGON_CTRL2        0x0e
36 #define NET_TRUST_DOM_LIST     0x13
37
38 #define NET_SAM_SYNC           0x10
39 #define NET_SAM_DELTAS         0x07
40
41 /* Secure Channel types.  used in NetrServerAuthenticate negotiation */
42 #define SEC_CHAN_WKSTA   2
43 #define SEC_CHAN_DOMAIN  4
44 #define SEC_CHAN_BDC     6
45
46         
47 /* NET_USER_INFO_3 */
48 typedef struct net_user_info_3
49 {
50         uint32 ptr_user_info;
51
52         NTTIME logon_time;            /* logon time */
53         NTTIME logoff_time;           /* logoff time */
54         NTTIME kickoff_time;          /* kickoff time */
55         NTTIME pass_last_set_time;    /* password last set time */
56         NTTIME pass_can_change_time;  /* password can change time */
57         NTTIME pass_must_change_time; /* password must change time */
58
59         UNIHDR hdr_user_name;    /* username unicode string header */
60         UNIHDR hdr_full_name;    /* user's full name unicode string header */
61         UNIHDR hdr_logon_script; /* logon script unicode string header */
62         UNIHDR hdr_profile_path; /* profile path unicode string header */
63         UNIHDR hdr_home_dir;     /* home directory unicode string header */
64         UNIHDR hdr_dir_drive;    /* home directory drive unicode string header */
65
66         uint16 logon_count;  /* logon count */
67         uint16 bad_pw_count; /* bad password count */
68
69         uint32 user_id;       /* User ID */
70         uint32 group_id;      /* Group ID */
71         uint32 num_groups;    /* num groups */
72         uint32 buffer_groups; /* undocumented buffer pointer to groups. */
73         uint32 user_flgs;     /* user flags */
74
75         uint8 user_sess_key[16]; /* unused user session key */
76
77         UNIHDR hdr_logon_srv; /* logon server unicode string header */
78         UNIHDR hdr_logon_dom; /* logon domain unicode string header */
79
80         uint32 buffer_dom_id; /* undocumented logon domain id pointer */
81         uint8 padding[40];    /* unused padding bytes.  expansion room */
82
83         uint32 num_other_sids; /* 0 - num_sids */
84         uint32 buffer_other_sids; /* NULL - undocumented pointer to SIDs. */
85         
86         UNISTR2 uni_user_name;    /* username unicode string */
87         UNISTR2 uni_full_name;    /* user's full name unicode string */
88         UNISTR2 uni_logon_script; /* logon script unicode string */
89         UNISTR2 uni_profile_path; /* profile path unicode string */
90         UNISTR2 uni_home_dir;     /* home directory unicode string */
91         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
92
93         uint32 num_groups2;        /* num groups */
94         DOM_GID gids[LSA_MAX_GROUPS]; /* group info */
95
96         UNISTR2 uni_logon_srv; /* logon server unicode string */
97         UNISTR2 uni_logon_dom; /* logon domain unicode string */
98
99         DOM_SID2 dom_sid;           /* domain SID */
100         DOM_SID2 other_sids[LSA_MAX_SIDS]; /* undocumented - domain SIDs */
101
102 } NET_USER_INFO_3;
103
104
105 /********************************************************
106  Logon Control Query
107
108  query_level 0x1 - pdc status
109  query_level 0x3 - number of logon attempts.
110
111  ********************************************************/
112 /* NET_Q_LOGON_CTRL2 - LSA Netr Logon Control 2*/
113 typedef struct net_q_logon_ctrl2_info
114 {
115         uint32       ptr;             /* undocumented buffer pointer */
116         UNISTR2      uni_server_name; /* server name, starting with two '\'s */
117         
118         uint32       function_code; /* 0x1 */
119         uint32       query_level;   /* 0x1, 0x3 */
120         uint32       switch_value;  /* 0x1 */
121
122 } NET_Q_LOGON_CTRL2;
123
124 /* NETLOGON_INFO_1 - pdc status info, i presume */
125 typedef struct netlogon_1_info
126 {
127         uint32 flags;            /* 0x0 - undocumented */
128         uint32 pdc_status;       /* 0x0 - undocumented */
129
130 } NETLOGON_INFO_1;
131
132 /* NETLOGON_INFO_2 - pdc status info, plus trusted domain info */
133 typedef struct netlogon_2_info
134 {
135         uint32  flags;            /* 0x0 - undocumented */
136         uint32  pdc_status;       /* 0x0 - undocumented */
137         uint32  ptr_trusted_dc_name; /* pointer to trusted domain controller name */
138         uint32  tc_status;           /* 0x051f - ERROR_NO_LOGON_SERVERS */
139         UNISTR2 uni_trusted_dc_name; /* unicode string - trusted dc name */
140
141 } NETLOGON_INFO_2;
142
143 /* NETLOGON_INFO_3 - logon status info, i presume */
144 typedef struct netlogon_3_info
145 {
146         uint32 flags;            /* 0x0 - undocumented */
147         uint32 logon_attempts;   /* number of logon attempts */
148         uint32 reserved_1;       /* 0x0 - undocumented */
149         uint32 reserved_2;       /* 0x0 - undocumented */
150         uint32 reserved_3;       /* 0x0 - undocumented */
151         uint32 reserved_4;       /* 0x0 - undocumented */
152         uint32 reserved_5;       /* 0x0 - undocumented */
153
154 } NETLOGON_INFO_3;
155
156 /*******************************************************
157  Logon Control Response
158
159  switch_value is same as query_level in request 
160  *******************************************************/
161
162 /* NET_R_LOGON_CTRL2 - response to LSA Logon Control2 */
163 typedef struct net_r_logon_ctrl2_info
164 {
165         uint32       switch_value;  /* 0x1, 0x3 */
166         uint32       ptr;
167
168         union
169         {
170                 NETLOGON_INFO_1 info1;
171                 NETLOGON_INFO_2 info2;
172                 NETLOGON_INFO_3 info3;
173
174         } logon;
175
176         uint32 status; /* return code */
177
178 } NET_R_LOGON_CTRL2;
179
180 /* NET_Q_TRUST_DOM_LIST - LSA Query Trusted Domains */
181 typedef struct net_q_trust_dom_info
182 {
183         uint32       ptr;             /* undocumented buffer pointer */
184         UNISTR2      uni_server_name; /* server name, starting with two '\'s */
185         
186         uint32       function_code; /* 0x31 */
187
188 } NET_Q_TRUST_DOM_LIST;
189
190 #define MAX_TRUST_DOMS 1
191
192 /* NET_R_TRUST_DOM_LIST - response to LSA Trusted Domains */
193 typedef struct net_r_trust_dom_info
194 {
195         UNISTR2 uni_trust_dom_name[MAX_TRUST_DOMS];
196
197         uint32 status; /* return code */
198
199 } NET_R_TRUST_DOM_LIST;
200
201
202 /* NEG_FLAGS */
203 typedef struct neg_flags_info
204 {
205     uint32 neg_flags; /* negotiated flags */
206
207 } NEG_FLAGS;
208
209
210 /* NET_Q_REQ_CHAL */
211 typedef struct net_q_req_chal_info
212 {
213     uint32  undoc_buffer; /* undocumented buffer pointer */
214     UNISTR2 uni_logon_srv; /* logon server unicode string */
215     UNISTR2 uni_logon_clnt; /* logon client unicode string */
216     DOM_CHAL clnt_chal; /* client challenge */
217
218 } NET_Q_REQ_CHAL;
219
220
221 /* NET_R_REQ_CHAL */
222 typedef struct net_r_req_chal_info
223 {
224     DOM_CHAL srv_chal; /* server challenge */
225
226   uint32 status; /* return code */
227
228 } NET_R_REQ_CHAL;
229
230 /* NET_Q_AUTH */
231 typedef struct net_q_auth_info
232 {
233     DOM_LOG_INFO clnt_id; /* client identification info */
234     DOM_CHAL clnt_chal;     /* client-calculated credentials */
235
236
237 } NET_Q_AUTH;
238
239 /* NET_R_AUTH */
240 typedef struct net_r_auth_info
241 {
242     DOM_CHAL srv_chal;     /* server-calculated credentials */
243
244   uint32 status; /* return code */
245
246 } NET_R_AUTH;
247
248 /* NET_Q_AUTH_2 */
249 typedef struct net_q_auth2_info
250 {
251     DOM_LOG_INFO clnt_id; /* client identification info */
252     DOM_CHAL clnt_chal;     /* client-calculated credentials */
253
254     NEG_FLAGS clnt_flgs; /* usually 0x0000 01ff */
255
256 } NET_Q_AUTH_2;
257
258 /* NET_R_AUTH_2 */
259 typedef struct net_r_auth2_info
260 {
261     DOM_CHAL srv_chal;     /* server-calculated credentials */
262     NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */
263
264   uint32 status; /* return code */
265
266 } NET_R_AUTH_2;
267
268 /* NET_Q_SRV_PWSET */
269 typedef struct net_q_srv_pwset_info
270 {
271     DOM_CLNT_INFO clnt_id; /* client identification/authentication info */
272     uint8 pwd[16]; /* new password - undocumented. */
273
274 } NET_Q_SRV_PWSET;
275     
276 /* NET_R_SRV_PWSET */
277 typedef struct net_r_srv_pwset_info
278 {
279     DOM_CRED srv_cred;     /* server-calculated credentials */
280
281   uint32 status; /* return code */
282
283 } NET_R_SRV_PWSET;
284
285 /* NET_ID_INFO_2 */
286 typedef struct net_network_info_2
287 {
288         uint32            ptr_id_info2;        /* pointer to id_info_2 */
289         UNIHDR            hdr_domain_name;     /* domain name unicode header */
290         uint32            param_ctrl;          /* param control (0x2) */
291         BIGINT            logon_id;            /* logon ID */
292         UNIHDR            hdr_user_name;       /* user name unicode header */
293         UNIHDR            hdr_wksta_name;      /* workstation name unicode header */
294         uint8             lm_chal[8];          /* lan manager 8 byte challenge */
295         STRHDR            hdr_nt_chal_resp;    /* nt challenge response */
296         STRHDR            hdr_lm_chal_resp;    /* lm challenge response */
297
298         UNISTR2           uni_domain_name;     /* domain name unicode string */
299         UNISTR2           uni_user_name;       /* user name unicode string */
300         UNISTR2           uni_wksta_name;      /* workgroup name unicode string */
301         STRING2           nt_chal_resp;        /* nt challenge response */
302         STRING2           lm_chal_resp;        /* lm challenge response */
303
304 } NET_ID_INFO_2;
305
306 /* NET_ID_INFO_1 */
307 typedef struct id_info_1
308 {
309         uint32            ptr_id_info1;        /* pointer to id_info_1 */
310         UNIHDR            hdr_domain_name;     /* domain name unicode header */
311         uint32            param_ctrl;          /* param control */
312         BIGINT            logon_id;            /* logon ID */
313         UNIHDR            hdr_user_name;       /* user name unicode header */
314         UNIHDR            hdr_wksta_name;      /* workstation name unicode header */
315         OWF_INFO          lm_owf;              /* LM OWF Password */
316         OWF_INFO          nt_owf;              /* NT OWF Password */
317         UNISTR2           uni_domain_name;     /* domain name unicode string */
318         UNISTR2           uni_user_name;       /* user name unicode string */
319         UNISTR2           uni_wksta_name;      /* workgroup name unicode string */
320
321 } NET_ID_INFO_1;
322
323 #define INTERACTIVE_LOGON_TYPE 1
324 #define NET_LOGON_TYPE 2
325
326 /* NET_ID_INFO_CTR */
327 typedef struct net_id_info_ctr_info
328 {
329   uint16         switch_value;
330   
331   union
332   {
333     NET_ID_INFO_1 id1; /* auth-level 1 - interactive user login */
334     NET_ID_INFO_2 id2; /* auth-level 2 - workstation referred login */
335
336   } auth;
337   
338 } NET_ID_INFO_CTR;
339
340 /* SAM_INFO - sam logon/off id structure */
341 typedef struct sam_info
342 {
343   DOM_CLNT_INFO2  client;
344   uint32          ptr_rtn_cred; /* pointer to return credentials */
345   DOM_CRED        rtn_cred; /* return credentials */
346   uint16          logon_level;
347   NET_ID_INFO_CTR *ctr;
348   uint16          validation_level;
349
350 } DOM_SAM_INFO;
351
352 /* NET_Q_SAM_LOGON */
353 typedef struct net_q_sam_logon_info
354 {
355     DOM_SAM_INFO sam_id;
356
357 } NET_Q_SAM_LOGON;
358
359 /* NET_R_SAM_LOGON */
360 typedef struct net_r_sam_logon_info
361 {
362     uint32 buffer_creds; /* undocumented buffer pointer */
363     DOM_CRED srv_creds; /* server credentials.  server time stamp appears to be ignored. */
364     
365         uint16 switch_value; /* 3 - indicates type of USER INFO */
366     NET_USER_INFO_3 *user;
367
368     uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
369
370   uint32 status; /* return code */
371
372 } NET_R_SAM_LOGON;
373
374
375 /* NET_Q_SAM_LOGOFF */
376 typedef struct net_q_sam_logoff_info
377 {
378     DOM_SAM_INFO sam_id;
379
380 } NET_Q_SAM_LOGOFF;
381
382 /* NET_R_SAM_LOGOFF */
383 typedef struct net_r_sam_logoff_info
384 {
385     uint32 buffer_creds; /* undocumented buffer pointer */
386     DOM_CRED srv_creds; /* server credentials.  server time stamp appears to be ignored. */
387     
388   uint32 status; /* return code */
389
390 } NET_R_SAM_LOGOFF;
391
392
393 /* NET_Q_SAM_SYNC */
394 typedef struct net_q_sam_sync_info
395 {
396         UNISTR2 uni_srv_name; /* \\PDC */
397         UNISTR2 uni_cli_name; /* BDC */
398         DOM_CRED cli_creds;
399         DOM_CRED ret_creds;
400
401         uint32 database_id;
402         uint32 restart_state;
403         uint32 sync_context;
404
405         uint32 max_size;       /* preferred maximum length */
406
407 } NET_Q_SAM_SYNC;
408
409 #define MAX_GROUP_MEM  256
410 #define MAX_SAM_DELTAS 256
411
412 /* SAM_DELTA_HDR */
413 typedef struct sam_delta_hdr_info
414 {
415         uint16 type;  /* type of structure attached, see below */
416         uint16 type2;
417         uint32 target_rid;
418
419         uint32 type3;
420         uint32 ptr_delta;
421
422 } SAM_DELTA_HDR;
423
424 /* SAM_DOMAIN_INFO (0x1) */
425 typedef struct sam_domain_info_info
426 {
427         UNIHDR hdr_dom_name;
428         UNIHDR hdr_oem_info;
429
430         BIGINT force_logoff;
431         uint16 min_pwd_len;
432         uint16 pwd_history_len;
433         BIGINT max_pwd_age;
434         BIGINT min_pwd_age;
435         BIGINT dom_mod_count;
436         NTTIME creation_time;
437
438         BUFHDR2 hdr_sec_desc; /* security descriptor */
439         UNIHDR hdr_unknown;
440         uint8 reserved[40];
441
442         UNISTR2 uni_dom_name;
443         UNISTR2 buf_oem_info; /* never seen */
444
445         BUFFER4 buf_sec_desc;
446         UNISTR2 buf_unknown;
447
448 } SAM_DOMAIN_INFO;
449
450 /* SAM_GROUP_INFO (0x2) */
451 typedef struct sam_group_info_info
452 {
453         UNIHDR hdr_grp_name;
454         DOM_GID gid;
455         UNIHDR hdr_grp_desc;
456         BUFHDR2 hdr_sec_desc;  /* security descriptor */
457         uint8 reserved[48];
458
459         UNISTR2 uni_grp_name;
460         UNISTR2 uni_grp_desc;
461         BUFFER4 buf_sec_desc;
462
463 } SAM_GROUP_INFO;
464
465 /* SAM_PWD */
466 typedef struct sam_passwd_info
467 {
468         /* this structure probably contains password history */
469         /* this is probably a count of lm/nt pairs */
470         uint32 unk_0; /* 0x0000 0002 */
471
472         UNIHDR hdr_lm_pwd;
473         uint8  buf_lm_pwd[16];
474
475         UNIHDR hdr_nt_pwd;
476         uint8  buf_nt_pwd[16];
477
478         UNIHDR hdr_empty_lm;
479         UNIHDR hdr_empty_nt;
480
481 } SAM_PWD;
482
483 /* SAM_ACCOUNT_INFO (0x5) */
484 typedef struct sam_account_info_info
485 {
486         UNIHDR hdr_acct_name;
487         UNIHDR hdr_full_name;
488
489         uint32 user_rid;
490         uint32 group_rid;
491
492         UNIHDR hdr_home_dir;
493         UNIHDR hdr_dir_drive;
494         UNIHDR hdr_logon_script;
495         UNIHDR hdr_acct_desc;
496         UNIHDR hdr_workstations;
497
498         NTTIME logon_time;
499         NTTIME logoff_time;
500
501         uint32 logon_divs; /* 0xA8 */
502         uint32 ptr_logon_hrs;
503
504         uint16 bad_pwd_count;
505         uint16 logon_count;
506         NTTIME pwd_last_set_time;
507         NTTIME acct_expiry_time;
508
509         uint32 acb_info;
510         uint8 nt_pwd[16];
511         uint8 lm_pwd[16];
512         uint8 nt_pwd_present;
513         uint8 lm_pwd_present;
514         uint8 pwd_expired;
515
516         UNIHDR hdr_comment;
517         UNIHDR hdr_parameters;
518         uint16 country;
519         uint16 codepage;
520
521         BUFHDR2 hdr_sec_desc;  /* security descriptor */
522
523         UNIHDR  hdr_profile;
524         UNIHDR  hdr_reserved[3];  /* space for more strings */
525         uint32  dw_reserved[4];   /* space for more data - first two seem to
526                                      be an NTTIME */
527
528         UNISTR2 uni_acct_name;
529         UNISTR2 uni_full_name;
530         UNISTR2 uni_home_dir;
531         UNISTR2 uni_dir_drive;
532         UNISTR2 uni_logon_script;
533         UNISTR2 uni_acct_desc;
534         UNISTR2 uni_workstations;
535
536         uint32 unknown1; /* 0x4EC */
537         uint32 unknown2; /* 0 */
538
539         BUFFER4 buf_logon_hrs;
540         UNISTR2 uni_comment;
541         UNISTR2 uni_parameters;
542         SAM_PWD pass;
543         BUFFER4 buf_sec_desc;
544         UNISTR2 uni_profile;
545
546 } SAM_ACCOUNT_INFO;
547
548 /* SAM_GROUP_MEM_INFO (0x8) */
549 typedef struct sam_group_mem_info_info
550 {
551         uint32 ptr_rids;
552         uint32 ptr_attribs;
553         uint32 num_members;
554         uint8 unknown[16];
555
556         uint32 num_members2;
557         uint32 rids[MAX_GROUP_MEM];
558
559         uint32 num_members3;
560         uint32 attribs[MAX_GROUP_MEM];
561
562 } SAM_GROUP_MEM_INFO;
563
564 /* SAM_ALIAS_INFO (0x9) */
565 typedef struct sam_alias_info_info
566 {
567         UNIHDR hdr_als_name;
568         uint32 als_rid;
569         BUFHDR2 hdr_sec_desc;  /* security descriptor */
570         UNIHDR hdr_als_desc;
571         uint8 reserved[40];
572
573         UNISTR2 uni_als_name;
574         BUFFER4 buf_sec_desc;
575         UNISTR2 uni_als_desc;
576
577 } SAM_ALIAS_INFO;
578
579 /* SAM_ALIAS_MEM_INFO (0xC) */
580 typedef struct sam_alias_mem_info_info
581 {
582         uint32 num_members;
583         uint32 ptr_members;
584         uint8 unknown[16];
585
586         uint32 num_sids;
587         uint32 ptr_sids[MAX_GROUP_MEM];
588         DOM_SID2 sids[MAX_GROUP_MEM];
589
590 } SAM_ALIAS_MEM_INFO;
591
592 /* SAM_DELTA_CTR */
593 typedef union sam_delta_ctr_info
594 {
595         SAM_DOMAIN_INFO    domain_info ;
596         SAM_GROUP_INFO     group_info  ;
597         SAM_ACCOUNT_INFO   account_info;
598         SAM_GROUP_MEM_INFO grp_mem_info;
599         SAM_ALIAS_INFO     alias_info  ;
600         SAM_ALIAS_MEM_INFO als_mem_info;
601
602 } SAM_DELTA_CTR;
603
604 /* NET_R_SAM_SYNC */
605 typedef struct net_r_sam_sync_info
606 {
607         DOM_CRED srv_creds;
608
609         uint32 sync_context;
610
611         uint32 ptr_deltas;
612         uint32 num_deltas;
613         uint32 ptr_deltas2;
614         uint32 num_deltas2;
615
616         SAM_DELTA_HDR *hdr_deltas;
617         SAM_DELTA_CTR *deltas;
618
619         uint32 status;
620
621 } NET_R_SAM_SYNC;
622
623
624 /* NET_Q_SAM_DELTAS */
625 typedef struct net_q_sam_deltas_info
626 {
627         UNISTR2 uni_srv_name;
628         UNISTR2 uni_cli_name;
629         DOM_CRED cli_creds;
630         DOM_CRED ret_creds;
631
632         uint32 database_id;
633         BIGINT dom_mod_count;  /* domain mod count at last sync */
634
635         uint32 max_size;       /* preferred maximum length */
636
637 } NET_Q_SAM_DELTAS;
638
639 /* NET_R_SAM_DELTAS */
640 typedef struct net_r_sam_deltas_info
641 {
642         DOM_CRED srv_creds;
643
644         BIGINT dom_mod_count;   /* new domain mod count */
645
646         uint32 num_deltas;
647         uint32 ptr_deltas;
648         uint32 num_deltas2;
649
650         SAM_DELTA_HDR *hdr_deltas;
651         SAM_DELTA_CTR *deltas;
652
653         uint32 status;
654
655 } NET_R_SAM_DELTAS;
656
657
658 #endif /* _RPC_NETLOGON_H */
659