new logs use abbreviated month names. Add this to date conversion
[samba.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_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_AUTH2              0x0f
37 #define NET_LOGON_CTRL2        0x0e
38 #define NET_SAM_SYNC           0x10
39 #define NET_TRUST_DOM_LIST     0x13
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 #if 0
47 /* I think this is correct - it's what gets parsed on the wire. JRA. */
48 /* NET_USER_INFO_2 */
49 typedef struct net_user_info_2
50 {
51         uint32 ptr_user_info;
52
53         NTTIME logon_time;            /* logon time */
54         NTTIME logoff_time;           /* logoff time */
55         NTTIME kickoff_time;          /* kickoff time */
56         NTTIME pass_last_set_time;    /* password last set time */
57         NTTIME pass_can_change_time;  /* password can change time */
58         NTTIME pass_must_change_time; /* password must change time */
59
60         UNIHDR hdr_user_name;    /* username unicode string header */
61         UNIHDR hdr_full_name;    /* user's full name unicode string header */
62         UNIHDR hdr_logon_script; /* logon script unicode string header */
63         UNIHDR hdr_profile_path; /* profile path unicode string header */
64         UNIHDR hdr_home_dir;     /* home directory unicode string header */
65         UNIHDR hdr_dir_drive;    /* home directory drive unicode string header */
66
67         uint16 logon_count;  /* logon count */
68         uint16 bad_pw_count; /* bad password count */
69
70         uint32 user_id;       /* User ID */
71         uint32 group_id;      /* Group ID */
72         uint32 num_groups;    /* num groups */
73         uint32 buffer_groups; /* undocumented buffer pointer to groups. */
74         uint32 user_flgs;     /* user flags */
75
76         uint8 user_sess_key[16]; /* unused user session key */
77
78         UNIHDR hdr_logon_srv; /* logon server unicode string header */
79         UNIHDR hdr_logon_dom; /* logon domain unicode string header */
80
81         uint32 buffer_dom_id; /* undocumented logon domain id pointer */
82         uint8 padding[40];    /* unused padding bytes.  expansion room */
83
84         UNISTR2 uni_user_name;    /* username unicode string */
85         UNISTR2 uni_full_name;    /* user's full name unicode string */
86         UNISTR2 uni_logon_script; /* logon script unicode string */
87         UNISTR2 uni_profile_path; /* profile path unicode string */
88         UNISTR2 uni_home_dir;     /* home directory unicode string */
89         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
90
91         uint32 num_groups2;        /* num groups */
92         DOM_GID *gids; /* group info */
93
94         UNISTR2 uni_logon_srv; /* logon server unicode string */
95         UNISTR2 uni_logon_dom; /* logon domain unicode string */
96
97         DOM_SID2 dom_sid;           /* domain SID */
98
99         uint32 num_other_groups;        /* other groups */
100         DOM_GID *other_gids; /* group info */
101         DOM_SID2 *other_sids; /* undocumented - domain SIDs */
102
103 } NET_USER_INFO_2;
104 #endif
105
106 /* NET_USER_INFO_3 */
107 typedef struct net_user_info_3
108 {
109         uint32 ptr_user_info;
110
111         NTTIME logon_time;            /* logon time */
112         NTTIME logoff_time;           /* logoff time */
113         NTTIME kickoff_time;          /* kickoff time */
114         NTTIME pass_last_set_time;    /* password last set time */
115         NTTIME pass_can_change_time;  /* password can change time */
116         NTTIME pass_must_change_time; /* password must change time */
117
118         UNIHDR hdr_user_name;    /* username unicode string header */
119         UNIHDR hdr_full_name;    /* user's full name unicode string header */
120         UNIHDR hdr_logon_script; /* logon script unicode string header */
121         UNIHDR hdr_profile_path; /* profile path unicode string header */
122         UNIHDR hdr_home_dir;     /* home directory unicode string header */
123         UNIHDR hdr_dir_drive;    /* home directory drive unicode string header */
124
125         uint16 logon_count;  /* logon count */
126         uint16 bad_pw_count; /* bad password count */
127
128         uint32 user_id;       /* User ID */
129         uint32 group_id;      /* Group ID */
130         uint32 num_groups;    /* num groups */
131         uint32 buffer_groups; /* undocumented buffer pointer to groups. */
132         uint32 user_flgs;     /* user flags */
133
134         uint8 user_sess_key[16]; /* unused user session key */
135
136         UNIHDR hdr_logon_srv; /* logon server unicode string header */
137         UNIHDR hdr_logon_dom; /* logon domain unicode string header */
138
139         uint32 buffer_dom_id; /* undocumented logon domain id pointer */
140         uint8 padding[40];    /* unused padding bytes.  expansion room */
141
142         uint32 num_other_sids; /* 0 - num_sids */
143         uint32 buffer_other_sids; /* NULL - undocumented pointer to SIDs. */
144         
145         UNISTR2 uni_user_name;    /* username unicode string */
146         UNISTR2 uni_full_name;    /* user's full name unicode string */
147         UNISTR2 uni_logon_script; /* logon script unicode string */
148         UNISTR2 uni_profile_path; /* profile path unicode string */
149         UNISTR2 uni_home_dir;     /* home directory unicode string */
150         UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
151
152         uint32 num_groups2;        /* num groups */
153         DOM_GID *gids; /* group info */
154
155         UNISTR2 uni_logon_srv; /* logon server unicode string */
156         UNISTR2 uni_logon_dom; /* logon domain unicode string */
157
158         DOM_SID2 dom_sid;           /* domain SID */
159
160         uint32 num_other_groups;        /* other groups */
161         DOM_GID *other_gids; /* group info */
162         DOM_SID2 *other_sids; /* undocumented - domain SIDs */
163
164 } NET_USER_INFO_3;
165
166
167 /* NETLOGON_INFO_1 - pdc status info, i presume */
168 typedef struct netlogon_1_info
169 {
170         uint32 flags;            /* 0x0 - undocumented */
171         uint32 pdc_status;       /* 0x0 - undocumented */
172
173 } NETLOGON_INFO_1;
174
175 /* NETLOGON_INFO_2 - pdc status info, plus trusted domain info */
176 typedef struct netlogon_2_info
177 {
178         uint32  flags;            /* 0x0 - undocumented */
179         uint32  pdc_status;       /* 0x0 - undocumented */
180         uint32  ptr_trusted_dc_name; /* pointer to trusted domain controller name */
181         uint32  tc_status;           /* 0x051f - ERROR_NO_LOGON_SERVERS */
182         UNISTR2 uni_trusted_dc_name; /* unicode string - trusted dc name */
183
184 } NETLOGON_INFO_2;
185
186 /* NETLOGON_INFO_3 - logon status info, i presume */
187 typedef struct netlogon_3_info
188 {
189         uint32 flags;            /* 0x0 - undocumented */
190         uint32 logon_attempts;   /* number of logon attempts */
191         uint32 reserved_1;       /* 0x0 - undocumented */
192         uint32 reserved_2;       /* 0x0 - undocumented */
193         uint32 reserved_3;       /* 0x0 - undocumented */
194         uint32 reserved_4;       /* 0x0 - undocumented */
195         uint32 reserved_5;       /* 0x0 - undocumented */
196
197 } NETLOGON_INFO_3;
198
199 /********************************************************
200  Logon Control Query
201
202  This is generated by a nltest /bdc_query:DOMAIN
203
204  query_level 0x1, function_code 0x1
205
206  ********************************************************/
207
208 /* NET_Q_LOGON_CTRL - LSA Netr Logon Control */
209
210 typedef struct net_q_logon_ctrl_info
211 {
212         uint32 ptr;
213         UNISTR2 uni_server_name;
214         uint32 function_code;
215         uint32 query_level;
216 } NET_Q_LOGON_CTRL;
217
218 /* NET_R_LOGON_CTRL - LSA Netr Logon Control */
219
220 typedef struct net_r_logon_ctrl_info
221 {
222         uint32 switch_value;
223         uint32 ptr;
224
225         union {
226                 NETLOGON_INFO_1 info1;
227         } logon;
228
229         uint32 status;
230 } NET_R_LOGON_CTRL;
231
232 /********************************************************
233  Logon Control2 Query
234
235  query_level 0x1 - pdc status
236  query_level 0x3 - number of logon attempts.
237
238  ********************************************************/
239
240 /* NET_Q_LOGON_CTRL2 - LSA Netr Logon Control 2 */
241 typedef struct net_q_logon_ctrl2_info
242 {
243         uint32       ptr;             /* undocumented buffer pointer */
244         UNISTR2      uni_server_name; /* server name, starting with two '\'s */
245         
246         uint32       function_code; /* 0x1 */
247         uint32       query_level;   /* 0x1, 0x3 */
248         uint32       switch_value;  /* 0x1 */
249
250 } NET_Q_LOGON_CTRL2;
251
252 /*******************************************************
253  Logon Control Response
254
255  switch_value is same as query_level in request 
256  *******************************************************/
257
258 /* NET_R_LOGON_CTRL2 - response to LSA Logon Control2 */
259 typedef struct net_r_logon_ctrl2_info
260 {
261         uint32       switch_value;  /* 0x1, 0x3 */
262         uint32       ptr;
263
264         union
265         {
266                 NETLOGON_INFO_1 info1;
267                 NETLOGON_INFO_2 info2;
268                 NETLOGON_INFO_3 info3;
269
270         } logon;
271
272         uint32 status; /* return code */
273
274 } NET_R_LOGON_CTRL2;
275
276 /* NET_Q_TRUST_DOM_LIST - LSA Query Trusted Domains */
277 typedef struct net_q_trust_dom_info
278 {
279         uint32       ptr;             /* undocumented buffer pointer */
280         UNISTR2      uni_server_name; /* server name, starting with two '\'s */
281
282 } NET_Q_TRUST_DOM_LIST;
283
284 #define MAX_TRUST_DOMS 1
285
286 /* NET_R_TRUST_DOM_LIST - response to LSA Trusted Domains */
287 typedef struct net_r_trust_dom_info
288 {
289         UNISTR2 uni_trust_dom_name[MAX_TRUST_DOMS];
290
291         uint32 status; /* return code */
292
293 } NET_R_TRUST_DOM_LIST;
294
295
296 /* NEG_FLAGS */
297 typedef struct neg_flags_info
298 {
299     uint32 neg_flags; /* negotiated flags */
300
301 } NEG_FLAGS;
302
303
304 /* NET_Q_REQ_CHAL */
305 typedef struct net_q_req_chal_info
306 {
307     uint32  undoc_buffer; /* undocumented buffer pointer */
308     UNISTR2 uni_logon_srv; /* logon server unicode string */
309     UNISTR2 uni_logon_clnt; /* logon client unicode string */
310     DOM_CHAL clnt_chal; /* client challenge */
311
312 } NET_Q_REQ_CHAL;
313
314
315 /* NET_R_REQ_CHAL */
316 typedef struct net_r_req_chal_info
317 {
318     DOM_CHAL srv_chal; /* server challenge */
319
320   uint32 status; /* return code */
321
322 } NET_R_REQ_CHAL;
323
324 /* NET_Q_AUTH */
325 typedef struct net_q_auth_info
326 {
327         DOM_LOG_INFO clnt_id; /* client identification info */
328         DOM_CHAL clnt_chal;     /* client-calculated credentials */
329 } NET_Q_AUTH;
330
331 /* NET_R_AUTH */
332 typedef struct net_r_auth_info
333 {
334         DOM_CHAL srv_chal;     /* server-calculated credentials */
335         uint32 status; /* return code */
336 } NET_R_AUTH;
337
338 /* NET_Q_AUTH_2 */
339 typedef struct net_q_auth2_info
340 {
341     DOM_LOG_INFO clnt_id; /* client identification info */
342     DOM_CHAL clnt_chal;     /* client-calculated credentials */
343
344     NEG_FLAGS clnt_flgs; /* usually 0x0000 01ff */
345
346 } NET_Q_AUTH_2;
347
348
349 /* NET_R_AUTH_2 */
350 typedef struct net_r_auth2_info
351 {
352     DOM_CHAL srv_chal;     /* server-calculated credentials */
353     NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */
354
355   uint32 status; /* return code */
356
357 } NET_R_AUTH_2;
358
359
360 /* NET_Q_SRV_PWSET */
361 typedef struct net_q_srv_pwset_info
362 {
363     DOM_CLNT_INFO clnt_id; /* client identification/authentication info */
364     uint8 pwd[16]; /* new password - undocumented. */
365
366 } NET_Q_SRV_PWSET;
367     
368 /* NET_R_SRV_PWSET */
369 typedef struct net_r_srv_pwset_info
370 {
371     DOM_CRED srv_cred;     /* server-calculated credentials */
372
373   uint32 status; /* return code */
374
375 } NET_R_SRV_PWSET;
376
377 /* NET_ID_INFO_2 */
378 typedef struct net_network_info_2
379 {
380         uint32            ptr_id_info2;        /* pointer to id_info_2 */
381         UNIHDR            hdr_domain_name;     /* domain name unicode header */
382         uint32            param_ctrl;          /* param control (0x2) */
383         DOM_LOGON_ID      logon_id;            /* logon ID */
384         UNIHDR            hdr_user_name;       /* user name unicode header */
385         UNIHDR            hdr_wksta_name;      /* workstation name unicode header */
386         uint8             lm_chal[8];          /* lan manager 8 byte challenge */
387         STRHDR            hdr_nt_chal_resp;    /* nt challenge response */
388         STRHDR            hdr_lm_chal_resp;    /* lm challenge response */
389
390         UNISTR2           uni_domain_name;     /* domain name unicode string */
391         UNISTR2           uni_user_name;       /* user name unicode string */
392         UNISTR2           uni_wksta_name;      /* workgroup name unicode string */
393         STRING2           nt_chal_resp;        /* nt challenge response */
394         STRING2           lm_chal_resp;        /* lm challenge response */
395
396 } NET_ID_INFO_2;
397
398 /* NET_ID_INFO_1 */
399 typedef struct id_info_1
400 {
401         uint32            ptr_id_info1;        /* pointer to id_info_1 */
402         UNIHDR            hdr_domain_name;     /* domain name unicode header */
403         uint32            param_ctrl;          /* param control */
404         DOM_LOGON_ID      logon_id;            /* logon ID */
405         UNIHDR            hdr_user_name;       /* user name unicode header */
406         UNIHDR            hdr_wksta_name;      /* workstation name unicode header */
407         OWF_INFO          lm_owf;              /* LM OWF Password */
408         OWF_INFO          nt_owf;              /* NT OWF Password */
409         UNISTR2           uni_domain_name;     /* domain name unicode string */
410         UNISTR2           uni_user_name;       /* user name unicode string */
411         UNISTR2           uni_wksta_name;      /* workgroup name unicode string */
412
413 } NET_ID_INFO_1;
414
415 #define INTERACTIVE_LOGON_TYPE 1
416 #define NET_LOGON_TYPE 2
417
418 /* NET_ID_INFO_CTR */
419 typedef struct net_id_info_ctr_info
420 {
421   uint16         switch_value;
422   
423   union
424   {
425     NET_ID_INFO_1 id1; /* auth-level 1 - interactive user login */
426     NET_ID_INFO_2 id2; /* auth-level 2 - workstation referred login */
427
428   } auth;
429   
430 } NET_ID_INFO_CTR;
431
432 /* SAM_INFO - sam logon/off id structure */
433 typedef struct sam_info
434 {
435   DOM_CLNT_INFO2  client;
436   uint32          ptr_rtn_cred; /* pointer to return credentials */
437   DOM_CRED        rtn_cred; /* return credentials */
438   uint16          logon_level;
439   NET_ID_INFO_CTR *ctr;
440
441 } DOM_SAM_INFO;
442
443 /* NET_Q_SAM_LOGON */
444 typedef struct net_q_sam_logon_info
445 {
446     DOM_SAM_INFO sam_id;
447         uint16          validation_level;
448
449 } NET_Q_SAM_LOGON;
450
451 /* NET_R_SAM_LOGON */
452 typedef struct net_r_sam_logon_info
453 {
454     uint32 buffer_creds; /* undocumented buffer pointer */
455     DOM_CRED srv_creds; /* server credentials.  server time stamp appears to be ignored. */
456     
457         uint16 switch_value; /* 3 - indicates type of USER INFO */
458     NET_USER_INFO_3 *user;
459
460     uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
461
462   uint32 status; /* return code */
463
464 } NET_R_SAM_LOGON;
465
466
467 /* NET_Q_SAM_LOGOFF */
468 typedef struct net_q_sam_logoff_info
469 {
470     DOM_SAM_INFO sam_id;
471
472 } NET_Q_SAM_LOGOFF;
473
474 /* NET_R_SAM_LOGOFF */
475 typedef struct net_r_sam_logoff_info
476 {
477     uint32 buffer_creds; /* undocumented buffer pointer */
478     DOM_CRED srv_creds; /* server credentials.  server time stamp appears to be ignored. */
479     
480   uint32 status; /* return code */
481
482 } NET_R_SAM_LOGOFF;
483
484 #endif /* _RPC_NETLOGON_H */