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