2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
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.
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.
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.
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.
27 #define DBGC_CLASS DBGC_RPC_PARSE
29 /*******************************************************************
30 Reads or writes a structure.
31 ********************************************************************/
33 static BOOL
net_io_neg_flags(const char *desc
, NEG_FLAGS
*neg
, prs_struct
*ps
, int depth
)
38 prs_debug(ps
, depth
, desc
, "net_io_neg_flags");
44 if(!prs_uint32("neg_flags", ps
, depth
, &neg
->neg_flags
))
50 /*******************************************************************
51 Inits a NETLOGON_INFO_3 structure.
52 ********************************************************************/
54 static void init_netinfo_3(NETLOGON_INFO_3
*info
, uint32 flags
, uint32 logon_attempts
)
57 info
->logon_attempts
= logon_attempts
;
58 info
->reserved_1
= 0x0;
59 info
->reserved_2
= 0x0;
60 info
->reserved_3
= 0x0;
61 info
->reserved_4
= 0x0;
62 info
->reserved_5
= 0x0;
65 /*******************************************************************
66 Reads or writes a NETLOGON_INFO_3 structure.
67 ********************************************************************/
69 static BOOL
net_io_netinfo_3(const char *desc
, NETLOGON_INFO_3
*info
, prs_struct
*ps
, int depth
)
74 prs_debug(ps
, depth
, desc
, "net_io_netinfo_3");
80 if(!prs_uint32("flags ", ps
, depth
, &info
->flags
))
82 if(!prs_uint32("logon_attempts", ps
, depth
, &info
->logon_attempts
))
84 if(!prs_uint32("reserved_1 ", ps
, depth
, &info
->reserved_1
))
86 if(!prs_uint32("reserved_2 ", ps
, depth
, &info
->reserved_2
))
88 if(!prs_uint32("reserved_3 ", ps
, depth
, &info
->reserved_3
))
90 if(!prs_uint32("reserved_4 ", ps
, depth
, &info
->reserved_4
))
92 if(!prs_uint32("reserved_5 ", ps
, depth
, &info
->reserved_5
))
99 /*******************************************************************
100 Inits a NETLOGON_INFO_1 structure.
101 ********************************************************************/
103 static void init_netinfo_1(NETLOGON_INFO_1
*info
, uint32 flags
, uint32 pdc_status
)
106 info
->pdc_status
= pdc_status
;
109 /*******************************************************************
110 Reads or writes a NETLOGON_INFO_1 structure.
111 ********************************************************************/
113 static BOOL
net_io_netinfo_1(const char *desc
, NETLOGON_INFO_1
*info
, prs_struct
*ps
, int depth
)
118 prs_debug(ps
, depth
, desc
, "net_io_netinfo_1");
124 if(!prs_uint32("flags ", ps
, depth
, &info
->flags
))
126 if(!prs_uint32("pdc_status", ps
, depth
, &info
->pdc_status
))
132 /*******************************************************************
133 Inits a NETLOGON_INFO_2 structure.
134 ********************************************************************/
136 static void init_netinfo_2(NETLOGON_INFO_2
*info
, uint32 flags
, uint32 pdc_status
,
137 uint32 tc_status
, const char *trusted_dc_name
)
140 info
->pdc_status
= pdc_status
;
141 info
->ptr_trusted_dc_name
= 1;
142 info
->tc_status
= tc_status
;
144 if (trusted_dc_name
!= NULL
)
145 init_unistr2(&info
->uni_trusted_dc_name
, trusted_dc_name
, UNI_STR_TERMINATE
);
147 init_unistr2(&info
->uni_trusted_dc_name
, "", UNI_STR_TERMINATE
);
150 /*******************************************************************
151 Reads or writes a NETLOGON_INFO_2 structure.
152 ********************************************************************/
154 static BOOL
net_io_netinfo_2(const char *desc
, NETLOGON_INFO_2
*info
, prs_struct
*ps
, int depth
)
159 prs_debug(ps
, depth
, desc
, "net_io_netinfo_2");
165 if(!prs_uint32("flags ", ps
, depth
, &info
->flags
))
167 if(!prs_uint32("pdc_status ", ps
, depth
, &info
->pdc_status
))
169 if(!prs_uint32("ptr_trusted_dc_name", ps
, depth
, &info
->ptr_trusted_dc_name
))
171 if(!prs_uint32("tc_status ", ps
, depth
, &info
->tc_status
))
174 if (info
->ptr_trusted_dc_name
!= 0) {
175 if(!smb_io_unistr2("unistr2", &info
->uni_trusted_dc_name
, info
->ptr_trusted_dc_name
, ps
, depth
))
185 static BOOL
net_io_ctrl_data_info_5(const char *desc
, CTRL_DATA_INFO_5
*info
, prs_struct
*ps
, int depth
)
190 prs_debug(ps
, depth
, desc
, "net_io_ctrl_data_info_5");
193 if ( !prs_uint32( "function_code", ps
, depth
, &info
->function_code
) )
196 if(!prs_uint32("ptr_domain", ps
, depth
, &info
->ptr_domain
))
199 if ( info
->ptr_domain
) {
200 if(!smb_io_unistr2("domain", &info
->domain
, info
->ptr_domain
, ps
, depth
))
207 static BOOL
net_io_ctrl_data_info_6(const char *desc
, CTRL_DATA_INFO_6
*info
, prs_struct
*ps
, int depth
)
212 prs_debug(ps
, depth
, desc
, "net_io_ctrl_data_info_6");
215 if ( !prs_uint32( "function_code", ps
, depth
, &info
->function_code
) )
218 if(!prs_uint32("ptr_domain", ps
, depth
, &info
->ptr_domain
))
221 if ( info
->ptr_domain
) {
222 if(!smb_io_unistr2("domain", &info
->domain
, info
->ptr_domain
, ps
, depth
))
229 /*******************************************************************
230 Reads or writes an NET_Q_LOGON_CTRL2 structure.
231 ********************************************************************/
233 BOOL
net_io_q_logon_ctrl2(const char *desc
, NET_Q_LOGON_CTRL2
*q_l
, prs_struct
*ps
, int depth
)
238 prs_debug(ps
, depth
, desc
, "net_io_q_logon_ctrl2");
244 if(!prs_uint32("ptr ", ps
, depth
, &q_l
->ptr
))
247 if(!smb_io_unistr2 ("", &q_l
->uni_server_name
, q_l
->ptr
, ps
, depth
))
253 if(!prs_uint32("function_code", ps
, depth
, &q_l
->function_code
))
255 if(!prs_uint32("query_level ", ps
, depth
, &q_l
->query_level
))
257 switch ( q_l
->function_code
) {
258 case NETLOGON_CONTROL_REDISCOVER
:
259 if ( !net_io_ctrl_data_info_5( "ctrl_data_info5", &q_l
->info
.info5
, ps
, depth
) )
263 case NETLOGON_CONTROL_TC_QUERY
:
264 if ( !net_io_ctrl_data_info_6( "ctrl_data_info6", &q_l
->info
.info6
, ps
, depth
) )
269 DEBUG(0,("net_io_q_logon_ctrl2: unknown function_code [%d]\n",
270 q_l
->function_code
));
277 /*******************************************************************
278 Inits an NET_Q_LOGON_CTRL2 structure.
279 ********************************************************************/
281 void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2
*q_l
, const char *srv_name
,
284 DEBUG(5,("init_q_logon_ctrl2\n"));
286 q_l
->function_code
= 0x01;
287 q_l
->query_level
= query_level
;
289 init_unistr2(&q_l
->uni_server_name
, srv_name
, UNI_STR_TERMINATE
);
292 /*******************************************************************
293 Inits an NET_R_LOGON_CTRL2 structure.
294 ********************************************************************/
296 void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2
*r_l
, uint32 query_level
,
297 uint32 flags
, uint32 pdc_status
,
298 uint32 logon_attempts
, uint32 tc_status
,
299 const char *trusted_domain_name
)
301 r_l
->switch_value
= query_level
;
303 switch (query_level
) {
305 r_l
->ptr
= 1; /* undocumented pointer */
306 init_netinfo_1(&r_l
->logon
.info1
, flags
, pdc_status
);
307 r_l
->status
= NT_STATUS_OK
;
310 r_l
->ptr
= 1; /* undocumented pointer */
311 init_netinfo_2(&r_l
->logon
.info2
, flags
, pdc_status
,
312 tc_status
, trusted_domain_name
);
313 r_l
->status
= NT_STATUS_OK
;
316 r_l
->ptr
= 1; /* undocumented pointer */
317 init_netinfo_3(&r_l
->logon
.info3
, flags
, logon_attempts
);
318 r_l
->status
= NT_STATUS_OK
;
321 DEBUG(2,("init_r_logon_ctrl2: unsupported switch value %d\n",
323 r_l
->ptr
= 0; /* undocumented pointer */
325 /* take a guess at an error code... */
326 r_l
->status
= NT_STATUS_INVALID_INFO_CLASS
;
331 /*******************************************************************
332 Reads or writes an NET_R_LOGON_CTRL2 structure.
333 ********************************************************************/
335 BOOL
net_io_r_logon_ctrl2(const char *desc
, NET_R_LOGON_CTRL2
*r_l
, prs_struct
*ps
, int depth
)
340 prs_debug(ps
, depth
, desc
, "net_io_r_logon_ctrl2");
343 if(!prs_uint32("switch_value ", ps
, depth
, &r_l
->switch_value
))
345 if(!prs_uint32("ptr ", ps
, depth
, &r_l
->ptr
))
349 switch (r_l
->switch_value
) {
351 if(!net_io_netinfo_1("", &r_l
->logon
.info1
, ps
, depth
))
355 if(!net_io_netinfo_2("", &r_l
->logon
.info2
, ps
, depth
))
359 if(!net_io_netinfo_3("", &r_l
->logon
.info3
, ps
, depth
))
363 DEBUG(2,("net_io_r_logon_ctrl2: unsupported switch value %d\n",
369 if(!prs_ntstatus("status ", ps
, depth
, &r_l
->status
))
375 /*******************************************************************
376 Reads or writes an NET_Q_LOGON_CTRL structure.
377 ********************************************************************/
379 BOOL
net_io_q_logon_ctrl(const char *desc
, NET_Q_LOGON_CTRL
*q_l
, prs_struct
*ps
,
382 prs_debug(ps
, depth
, desc
, "net_io_q_logon_ctrl");
388 if(!prs_uint32("ptr ", ps
, depth
, &q_l
->ptr
))
391 if(!smb_io_unistr2 ("", &q_l
->uni_server_name
, q_l
->ptr
, ps
, depth
))
397 if(!prs_uint32("function_code", ps
, depth
, &q_l
->function_code
))
399 if(!prs_uint32("query_level ", ps
, depth
, &q_l
->query_level
))
405 /*******************************************************************
406 Inits an NET_Q_LOGON_CTRL structure.
407 ********************************************************************/
409 void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL
*q_l
, const char *srv_name
,
412 DEBUG(5,("init_q_logon_ctrl\n"));
414 q_l
->function_code
= 0x01; /* ??? */
415 q_l
->query_level
= query_level
;
417 init_unistr2(&q_l
->uni_server_name
, srv_name
, UNI_STR_TERMINATE
);
420 /*******************************************************************
421 Inits an NET_R_LOGON_CTRL structure.
422 ********************************************************************/
424 void init_net_r_logon_ctrl(NET_R_LOGON_CTRL
*r_l
, uint32 query_level
,
425 uint32 flags
, uint32 pdc_status
)
427 DEBUG(5,("init_r_logon_ctrl\n"));
429 r_l
->switch_value
= query_level
; /* should only be 0x1 */
431 switch (query_level
) {
433 r_l
->ptr
= 1; /* undocumented pointer */
434 init_netinfo_1(&r_l
->logon
.info1
, flags
, pdc_status
);
435 r_l
->status
= NT_STATUS_OK
;
438 DEBUG(2,("init_r_logon_ctrl: unsupported switch value %d\n",
440 r_l
->ptr
= 0; /* undocumented pointer */
442 /* take a guess at an error code... */
443 r_l
->status
= NT_STATUS_INVALID_INFO_CLASS
;
448 /*******************************************************************
449 Reads or writes an NET_R_LOGON_CTRL structure.
450 ********************************************************************/
452 BOOL
net_io_r_logon_ctrl(const char *desc
, NET_R_LOGON_CTRL
*r_l
, prs_struct
*ps
,
455 prs_debug(ps
, depth
, desc
, "net_io_r_logon_ctrl");
458 if(!prs_uint32("switch_value ", ps
, depth
, &r_l
->switch_value
))
460 if(!prs_uint32("ptr ", ps
, depth
, &r_l
->ptr
))
464 switch (r_l
->switch_value
) {
466 if(!net_io_netinfo_1("", &r_l
->logon
.info1
, ps
, depth
))
470 DEBUG(2,("net_io_r_logon_ctrl: unsupported switch value %d\n",
476 if(!prs_ntstatus("status ", ps
, depth
, &r_l
->status
))
482 /*******************************************************************
483 Inits an NET_R_GETDCNAME structure.
484 ********************************************************************/
485 void init_net_q_getdcname(NET_Q_GETDCNAME
*r_t
, const char *logon_server
,
486 const char *domainname
)
488 DEBUG(5,("init_r_getdcname\n"));
490 r_t
->ptr_logon_server
= (logon_server
!= NULL
);
491 init_unistr2(&r_t
->uni_logon_server
, logon_server
, UNI_STR_TERMINATE
);
492 r_t
->ptr_domainname
= (domainname
!= NULL
);
493 init_unistr2(&r_t
->uni_domainname
, domainname
, UNI_STR_TERMINATE
);
496 /*******************************************************************
497 Reads or writes an NET_Q_GETDCNAME structure.
498 ********************************************************************/
500 BOOL
net_io_q_getdcname(const char *desc
, NET_Q_GETDCNAME
*r_t
, prs_struct
*ps
,
506 prs_debug(ps
, depth
, desc
, "net_io_q_getdcname");
509 if (!prs_uint32("ptr_logon_server", ps
, depth
, &r_t
->ptr_logon_server
))
512 if (!smb_io_unistr2("logon_server", &r_t
->uni_logon_server
,
513 r_t
->ptr_logon_server
, ps
, depth
))
519 if (!prs_uint32("ptr_domainname", ps
, depth
, &r_t
->ptr_domainname
))
522 if (!smb_io_unistr2("domainname", &r_t
->uni_domainname
,
523 r_t
->ptr_domainname
, ps
, depth
))
530 /*******************************************************************
531 Inits an NET_R_GETDCNAME structure.
532 ********************************************************************/
533 void init_net_r_getdcname(NET_R_GETDCNAME
*r_t
, const char *dcname
)
535 DEBUG(5,("init_r_getdcname\n"));
537 init_unistr2(&r_t
->uni_dcname
, dcname
, UNI_STR_TERMINATE
);
540 /*******************************************************************
541 Reads or writes an NET_R_GETDCNAME structure.
542 ********************************************************************/
544 BOOL
net_io_r_getdcname(const char *desc
, NET_R_GETDCNAME
*r_t
, prs_struct
*ps
,
550 prs_debug(ps
, depth
, desc
, "net_io_r_getdcname");
553 if (!prs_uint32("ptr_dcname", ps
, depth
, &r_t
->ptr_dcname
))
556 if (!smb_io_unistr2("dcname", &r_t
->uni_dcname
,
557 r_t
->ptr_dcname
, ps
, depth
))
563 if (!prs_ntstatus("status", ps
, depth
, &r_t
->status
))
569 /*******************************************************************
570 Inits an NET_R_TRUST_DOM_LIST structure.
571 ********************************************************************/
573 void init_r_trust_dom(NET_R_TRUST_DOM_LIST
*r_t
,
574 uint32 num_doms
, const char *dom_name
)
578 DEBUG(5,("init_r_trust_dom\n"));
580 for (i
= 0; i
< MAX_TRUST_DOMS
; i
++) {
581 r_t
->uni_trust_dom_name
[i
].uni_str_len
= 0;
582 r_t
->uni_trust_dom_name
[i
].uni_max_len
= 0;
584 if (num_doms
> MAX_TRUST_DOMS
)
585 num_doms
= MAX_TRUST_DOMS
;
587 for (i
= 0; i
< num_doms
; i
++) {
589 fstrcpy(domain_name
, dom_name
);
590 strupper_m(domain_name
);
591 init_unistr2(&r_t
->uni_trust_dom_name
[i
], domain_name
, UNI_STR_TERMINATE
);
592 /* the use of UNISTR2 here is non-standard. */
593 r_t
->uni_trust_dom_name
[i
].offset
= 0x1;
596 r_t
->status
= NT_STATUS_OK
;
599 /*******************************************************************
600 Reads or writes an NET_R_TRUST_DOM_LIST structure.
601 ********************************************************************/
603 BOOL
net_io_r_trust_dom(const char *desc
, NET_R_TRUST_DOM_LIST
*r_t
, prs_struct
*ps
, int depth
)
610 prs_debug(ps
, depth
, desc
, "net_io_r_trust_dom");
613 /* temporary code to give a valid response */
615 if(!prs_uint32("status", ps
, depth
, &value
))
619 if(!prs_uint32("status", ps
, depth
, &value
))
622 if(!prs_uint32("status", ps
, depth
, &value
))
626 if(!prs_uint32("status", ps
, depth
, &value
))
630 if(!prs_uint32("status", ps
, depth
, &value
))
633 /* old non working code */
637 for (i
= 0; i
< MAX_TRUST_DOMS
; i
++) {
638 if (r_t
->uni_trust_dom_name
[i
].uni_str_len
== 0)
640 if(!smb_io_unistr2("", &r_t
->uni_trust_dom_name
[i
], True
, ps
, depth
))
644 if(!prs_ntstatus("status", ps
, depth
, &r_t
->status
))
651 /*******************************************************************
652 Reads or writes an NET_Q_TRUST_DOM_LIST structure.
653 ********************************************************************/
655 BOOL
net_io_q_trust_dom(const char *desc
, NET_Q_TRUST_DOM_LIST
*q_l
, prs_struct
*ps
, int depth
)
660 prs_debug(ps
, depth
, desc
, "net_io_q_trust_dom");
663 if(!prs_uint32("ptr ", ps
, depth
, &q_l
->ptr
))
665 if(!smb_io_unistr2 ("", &q_l
->uni_server_name
, q_l
->ptr
, ps
, depth
))
671 /*******************************************************************
672 Inits an NET_Q_REQ_CHAL structure.
673 ********************************************************************/
675 void init_q_req_chal(NET_Q_REQ_CHAL
*q_c
,
676 const char *logon_srv
, const char *logon_clnt
,
677 const DOM_CHAL
*clnt_chal
)
679 DEBUG(5,("init_q_req_chal: %d\n", __LINE__
));
681 q_c
->undoc_buffer
= 1; /* don't know what this buffer is */
683 init_unistr2(&q_c
->uni_logon_srv
, logon_srv
, UNI_STR_TERMINATE
);
684 init_unistr2(&q_c
->uni_logon_clnt
, logon_clnt
, UNI_STR_TERMINATE
);
686 memcpy(q_c
->clnt_chal
.data
, clnt_chal
->data
, sizeof(clnt_chal
->data
));
688 DEBUG(5,("init_q_req_chal: %d\n", __LINE__
));
691 /*******************************************************************
692 Reads or writes an NET_Q_REQ_CHAL structure.
693 ********************************************************************/
695 BOOL
net_io_q_req_chal(const char *desc
, NET_Q_REQ_CHAL
*q_c
, prs_struct
*ps
, int depth
)
700 prs_debug(ps
, depth
, desc
, "net_io_q_req_chal");
706 if(!prs_uint32("undoc_buffer", ps
, depth
, &q_c
->undoc_buffer
))
709 if(!smb_io_unistr2("", &q_c
->uni_logon_srv
, True
, ps
, depth
)) /* logon server unicode string */
711 if(!smb_io_unistr2("", &q_c
->uni_logon_clnt
, True
, ps
, depth
)) /* logon client unicode string */
714 if(!smb_io_chal("", &q_c
->clnt_chal
, ps
, depth
))
720 /*******************************************************************
721 Reads or writes a structure.
722 ********************************************************************/
724 BOOL
net_io_r_req_chal(const char *desc
, NET_R_REQ_CHAL
*r_c
, prs_struct
*ps
, int depth
)
729 prs_debug(ps
, depth
, desc
, "net_io_r_req_chal");
735 if(!smb_io_chal("", &r_c
->srv_chal
, ps
, depth
)) /* server challenge */
738 if(!prs_ntstatus("status", ps
, depth
, &r_c
->status
))
745 /*******************************************************************
746 Reads or writes a structure.
747 ********************************************************************/
749 BOOL
net_io_q_auth(const char *desc
, NET_Q_AUTH
*q_a
, prs_struct
*ps
, int depth
)
754 prs_debug(ps
, depth
, desc
, "net_io_q_auth");
760 if(!smb_io_log_info ("", &q_a
->clnt_id
, ps
, depth
)) /* client identification info */
762 if(!smb_io_chal("", &q_a
->clnt_chal
, ps
, depth
))
768 /*******************************************************************
769 Reads or writes a structure.
770 ********************************************************************/
772 BOOL
net_io_r_auth(const char *desc
, NET_R_AUTH
*r_a
, prs_struct
*ps
, int depth
)
777 prs_debug(ps
, depth
, desc
, "net_io_r_auth");
783 if(!smb_io_chal("", &r_a
->srv_chal
, ps
, depth
)) /* server challenge */
786 if(!prs_ntstatus("status", ps
, depth
, &r_a
->status
))
792 /*******************************************************************
793 Inits a NET_Q_AUTH_2 struct.
794 ********************************************************************/
796 void init_q_auth_2(NET_Q_AUTH_2
*q_a
,
797 const char *logon_srv
, const char *acct_name
, uint16 sec_chan
, const char *comp_name
,
798 const DOM_CHAL
*clnt_chal
, uint32 clnt_flgs
)
800 DEBUG(5,("init_q_auth_2: %d\n", __LINE__
));
802 init_log_info(&q_a
->clnt_id
, logon_srv
, acct_name
, sec_chan
, comp_name
);
803 memcpy(q_a
->clnt_chal
.data
, clnt_chal
->data
, sizeof(clnt_chal
->data
));
804 q_a
->clnt_flgs
.neg_flags
= clnt_flgs
;
806 DEBUG(5,("init_q_auth_2: %d\n", __LINE__
));
809 /*******************************************************************
810 Reads or writes a structure.
811 ********************************************************************/
813 BOOL
net_io_q_auth_2(const char *desc
, NET_Q_AUTH_2
*q_a
, prs_struct
*ps
, int depth
)
818 prs_debug(ps
, depth
, desc
, "net_io_q_auth_2");
824 if(!smb_io_log_info ("", &q_a
->clnt_id
, ps
, depth
)) /* client identification info */
826 if(!smb_io_chal("", &q_a
->clnt_chal
, ps
, depth
))
828 if(!net_io_neg_flags("", &q_a
->clnt_flgs
, ps
, depth
))
834 /*******************************************************************
835 Reads or writes a structure.
836 ********************************************************************/
838 BOOL
net_io_r_auth_2(const char *desc
, NET_R_AUTH_2
*r_a
, prs_struct
*ps
, int depth
)
843 prs_debug(ps
, depth
, desc
, "net_io_r_auth_2");
849 if(!smb_io_chal("", &r_a
->srv_chal
, ps
, depth
)) /* server challenge */
851 if(!net_io_neg_flags("", &r_a
->srv_flgs
, ps
, depth
))
854 if(!prs_ntstatus("status", ps
, depth
, &r_a
->status
))
860 /*******************************************************************
861 Inits a NET_Q_AUTH_3 struct.
862 ********************************************************************/
864 void init_q_auth_3(NET_Q_AUTH_3
*q_a
,
865 const char *logon_srv
, const char *acct_name
, uint16 sec_chan
, const char *comp_name
,
866 const DOM_CHAL
*clnt_chal
, uint32 clnt_flgs
)
868 DEBUG(5,("init_q_auth_3: %d\n", __LINE__
));
870 init_log_info(&q_a
->clnt_id
, logon_srv
, acct_name
, sec_chan
, comp_name
);
871 memcpy(q_a
->clnt_chal
.data
, clnt_chal
->data
, sizeof(clnt_chal
->data
));
872 q_a
->clnt_flgs
.neg_flags
= clnt_flgs
;
874 DEBUG(5,("init_q_auth_3: %d\n", __LINE__
));
877 /*******************************************************************
878 Reads or writes a structure.
879 ********************************************************************/
881 BOOL
net_io_q_auth_3(const char *desc
, NET_Q_AUTH_3
*q_a
, prs_struct
*ps
, int depth
)
886 prs_debug(ps
, depth
, desc
, "net_io_q_auth_3");
892 if(!smb_io_log_info ("", &q_a
->clnt_id
, ps
, depth
)) /* client identification info */
894 if(!smb_io_chal("", &q_a
->clnt_chal
, ps
, depth
))
896 if(!net_io_neg_flags("", &q_a
->clnt_flgs
, ps
, depth
))
902 /*******************************************************************
903 Reads or writes a structure.
904 ********************************************************************/
906 BOOL
net_io_r_auth_3(const char *desc
, NET_R_AUTH_3
*r_a
, prs_struct
*ps
, int depth
)
911 prs_debug(ps
, depth
, desc
, "net_io_r_auth_3");
917 if(!smb_io_chal("srv_chal", &r_a
->srv_chal
, ps
, depth
)) /* server challenge */
919 if(!net_io_neg_flags("srv_flgs", &r_a
->srv_flgs
, ps
, depth
))
921 if (!prs_uint32("unknown", ps
, depth
, &r_a
->unknown
))
924 if(!prs_ntstatus("status", ps
, depth
, &r_a
->status
))
931 /*******************************************************************
932 Inits a NET_Q_SRV_PWSET.
933 ********************************************************************/
935 void init_q_srv_pwset(NET_Q_SRV_PWSET
*q_s
,
936 const char *logon_srv
, const char *sess_key
, const char *acct_name
,
937 uint16 sec_chan
, const char *comp_name
,
938 DOM_CRED
*cred
, const uchar hashed_mach_pwd
[16])
940 unsigned char nt_cypher
[16];
942 DEBUG(5,("init_q_srv_pwset\n"));
944 /* Process the new password. */
945 cred_hash3( nt_cypher
, hashed_mach_pwd
, (const unsigned char *)sess_key
, 1);
947 init_clnt_info(&q_s
->clnt_id
, logon_srv
, acct_name
, sec_chan
, comp_name
, cred
);
949 memcpy(q_s
->pwd
, nt_cypher
, sizeof(q_s
->pwd
));
952 /*******************************************************************
953 Reads or writes a structure.
954 ********************************************************************/
956 BOOL
net_io_q_srv_pwset(const char *desc
, NET_Q_SRV_PWSET
*q_s
, prs_struct
*ps
, int depth
)
961 prs_debug(ps
, depth
, desc
, "net_io_q_srv_pwset");
967 if(!smb_io_clnt_info("", &q_s
->clnt_id
, ps
, depth
)) /* client identification/authentication info */
969 if(!prs_uint8s (False
, "pwd", ps
, depth
, q_s
->pwd
, 16)) /* new password - undocumented */
975 /*******************************************************************
976 Reads or writes a structure.
977 ********************************************************************/
979 BOOL
net_io_r_srv_pwset(const char *desc
, NET_R_SRV_PWSET
*r_s
, prs_struct
*ps
, int depth
)
984 prs_debug(ps
, depth
, desc
, "net_io_r_srv_pwset");
990 if(!smb_io_cred("", &r_s
->srv_cred
, ps
, depth
)) /* server challenge */
993 if(!prs_ntstatus("status", ps
, depth
, &r_s
->status
))
999 /*************************************************************************
1000 Init DOM_SID2 array from a string containing multiple sids
1001 *************************************************************************/
1003 static int init_dom_sid2s(TALLOC_CTX
*ctx
, const char *sids_str
, DOM_SID2
**ppsids
)
1009 DEBUG(4,("init_dom_sid2s: %s\n", sids_str
? sids_str
:""));
1017 /* Count the number of valid SIDs. */
1018 for (count
= 0, ptr
= sids_str
; next_token(&ptr
, s2
, NULL
, sizeof(s2
)); ) {
1020 if (string_to_sid(&tmpsid
, s2
))
1024 /* Now allocate space for them. */
1025 *ppsids
= TALLOC_ZERO_ARRAY(ctx
, DOM_SID2
, count
);
1026 if (*ppsids
== NULL
)
1031 for (number
= 0, ptr
= sids_str
; next_token(&ptr
, s2
, NULL
, sizeof(s2
)); ) {
1033 if (string_to_sid(&tmpsid
, s2
)) {
1034 /* count only valid sids */
1035 init_dom_sid2(&sids
[number
], &tmpsid
);
1044 /*******************************************************************
1045 Inits a NET_ID_INFO_1 structure.
1046 ********************************************************************/
1048 void init_id_info1(NET_ID_INFO_1
*id
, const char *domain_name
,
1049 uint32 param_ctrl
, uint32 log_id_low
, uint32 log_id_high
,
1050 const char *user_name
, const char *wksta_name
,
1051 const char *sess_key
,
1052 unsigned char lm_cypher
[16], unsigned char nt_cypher
[16])
1054 unsigned char lm_owf
[16];
1055 unsigned char nt_owf
[16];
1057 DEBUG(5,("init_id_info1: %d\n", __LINE__
));
1059 id
->ptr_id_info1
= 1;
1061 id
->param_ctrl
= param_ctrl
;
1062 init_logon_id(&id
->logon_id
, log_id_low
, log_id_high
);
1065 if (lm_cypher
&& nt_cypher
) {
1066 unsigned char key
[16];
1067 #ifdef DEBUG_PASSWORD
1068 DEBUG(100,("lm cypher:"));
1069 dump_data(100, (char *)lm_cypher
, 16);
1071 DEBUG(100,("nt cypher:"));
1072 dump_data(100, (char *)nt_cypher
, 16);
1076 memcpy(key
, sess_key
, 8);
1078 memcpy(lm_owf
, lm_cypher
, 16);
1079 SamOEMhash(lm_owf
, key
, 16);
1080 memcpy(nt_owf
, nt_cypher
, 16);
1081 SamOEMhash(nt_owf
, key
, 16);
1083 #ifdef DEBUG_PASSWORD
1084 DEBUG(100,("encrypt of lm owf password:"));
1085 dump_data(100, (char *)lm_owf
, 16);
1087 DEBUG(100,("encrypt of nt owf password:"));
1088 dump_data(100, (char *)nt_owf
, 16);
1090 /* set up pointers to cypher blocks */
1095 init_owf_info(&id
->lm_owf
, lm_cypher
);
1096 init_owf_info(&id
->nt_owf
, nt_cypher
);
1098 init_unistr2(&id
->uni_domain_name
, domain_name
, UNI_FLAGS_NONE
);
1099 init_uni_hdr(&id
->hdr_domain_name
, &id
->uni_domain_name
);
1100 init_unistr2(&id
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
1101 init_uni_hdr(&id
->hdr_user_name
, &id
->uni_user_name
);
1102 init_unistr2(&id
->uni_wksta_name
, wksta_name
, UNI_FLAGS_NONE
);
1103 init_uni_hdr(&id
->hdr_wksta_name
, &id
->uni_wksta_name
);
1106 /*******************************************************************
1107 Reads or writes an NET_ID_INFO_1 structure.
1108 ********************************************************************/
1110 static BOOL
net_io_id_info1(const char *desc
, NET_ID_INFO_1
*id
, prs_struct
*ps
, int depth
)
1115 prs_debug(ps
, depth
, desc
, "net_io_id_info1");
1121 if(!prs_uint32("ptr_id_info1", ps
, depth
, &id
->ptr_id_info1
))
1124 if (id
->ptr_id_info1
!= 0) {
1125 if(!smb_io_unihdr("unihdr", &id
->hdr_domain_name
, ps
, depth
))
1128 if(!prs_uint32("param_ctrl", ps
, depth
, &id
->param_ctrl
))
1130 if(!smb_io_logon_id("", &id
->logon_id
, ps
, depth
))
1133 if(!smb_io_unihdr("unihdr", &id
->hdr_user_name
, ps
, depth
))
1135 if(!smb_io_unihdr("unihdr", &id
->hdr_wksta_name
, ps
, depth
))
1138 if(!smb_io_owf_info("", &id
->lm_owf
, ps
, depth
))
1140 if(!smb_io_owf_info("", &id
->nt_owf
, ps
, depth
))
1143 if(!smb_io_unistr2("unistr2", &id
->uni_domain_name
,
1144 id
->hdr_domain_name
.buffer
, ps
, depth
))
1146 if(!smb_io_unistr2("unistr2", &id
->uni_user_name
,
1147 id
->hdr_user_name
.buffer
, ps
, depth
))
1149 if(!smb_io_unistr2("unistr2", &id
->uni_wksta_name
,
1150 id
->hdr_wksta_name
.buffer
, ps
, depth
))
1157 /*******************************************************************
1158 Inits a NET_ID_INFO_2 structure.
1160 This is a network logon packet. The log_id parameters
1161 are what an NT server would generate for LUID once the
1162 user is logged on. I don't think we care about them.
1164 Note that this has no access to the NT and LM hashed passwords,
1165 so it forwards the challenge, and the NT and LM responses (24
1166 bytes each) over the secure channel to the Domain controller
1167 for it to say yea or nay. This is the preferred method of
1168 checking for a logon as it doesn't export the password
1169 hashes to anyone who has compromised the secure channel. JRA.
1170 ********************************************************************/
1172 void init_id_info2(NET_ID_INFO_2
* id
, const char *domain_name
,
1174 uint32 log_id_low
, uint32 log_id_high
,
1175 const char *user_name
, const char *wksta_name
,
1176 const uchar lm_challenge
[8],
1177 const uchar
* lm_chal_resp
, size_t lm_chal_resp_len
,
1178 const uchar
* nt_chal_resp
, size_t nt_chal_resp_len
)
1181 DEBUG(5,("init_id_info2: %d\n", __LINE__
));
1183 id
->ptr_id_info2
= 1;
1185 id
->param_ctrl
= param_ctrl
;
1186 init_logon_id(&id
->logon_id
, log_id_low
, log_id_high
);
1188 memcpy(id
->lm_chal
, lm_challenge
, sizeof(id
->lm_chal
));
1189 init_str_hdr(&id
->hdr_nt_chal_resp
, nt_chal_resp_len
, nt_chal_resp_len
, (nt_chal_resp
!= NULL
) ? 1 : 0);
1190 init_str_hdr(&id
->hdr_lm_chal_resp
, lm_chal_resp_len
, lm_chal_resp_len
, (lm_chal_resp
!= NULL
) ? 1 : 0);
1192 init_unistr2(&id
->uni_domain_name
, domain_name
, UNI_FLAGS_NONE
);
1193 init_uni_hdr(&id
->hdr_domain_name
, &id
->uni_domain_name
);
1194 init_unistr2(&id
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
1195 init_uni_hdr(&id
->hdr_user_name
, &id
->uni_user_name
);
1196 init_unistr2(&id
->uni_wksta_name
, wksta_name
, UNI_FLAGS_NONE
);
1197 init_uni_hdr(&id
->hdr_wksta_name
, &id
->uni_wksta_name
);
1199 init_string2(&id
->nt_chal_resp
, (const char *)nt_chal_resp
, nt_chal_resp_len
, nt_chal_resp_len
);
1200 init_string2(&id
->lm_chal_resp
, (const char *)lm_chal_resp
, lm_chal_resp_len
, lm_chal_resp_len
);
1204 /*******************************************************************
1205 Reads or writes an NET_ID_INFO_2 structure.
1206 ********************************************************************/
1208 static BOOL
net_io_id_info2(const char *desc
, NET_ID_INFO_2
*id
, prs_struct
*ps
, int depth
)
1213 prs_debug(ps
, depth
, desc
, "net_io_id_info2");
1219 if(!prs_uint32("ptr_id_info2", ps
, depth
, &id
->ptr_id_info2
))
1222 if (id
->ptr_id_info2
!= 0) {
1223 if(!smb_io_unihdr("unihdr", &id
->hdr_domain_name
, ps
, depth
))
1226 if(!prs_uint32("param_ctrl", ps
, depth
, &id
->param_ctrl
))
1228 if(!smb_io_logon_id("", &id
->logon_id
, ps
, depth
))
1231 if(!smb_io_unihdr("unihdr", &id
->hdr_user_name
, ps
, depth
))
1233 if(!smb_io_unihdr("unihdr", &id
->hdr_wksta_name
, ps
, depth
))
1236 if(!prs_uint8s (False
, "lm_chal", ps
, depth
, id
->lm_chal
, 8)) /* lm 8 byte challenge */
1239 if(!smb_io_strhdr("hdr_nt_chal_resp", &id
->hdr_nt_chal_resp
, ps
, depth
))
1241 if(!smb_io_strhdr("hdr_lm_chal_resp", &id
->hdr_lm_chal_resp
, ps
, depth
))
1244 if(!smb_io_unistr2("uni_domain_name", &id
->uni_domain_name
,
1245 id
->hdr_domain_name
.buffer
, ps
, depth
))
1247 if(!smb_io_unistr2("uni_user_name ", &id
->uni_user_name
,
1248 id
->hdr_user_name
.buffer
, ps
, depth
))
1250 if(!smb_io_unistr2("uni_wksta_name ", &id
->uni_wksta_name
,
1251 id
->hdr_wksta_name
.buffer
, ps
, depth
))
1253 if(!smb_io_string2("nt_chal_resp", &id
->nt_chal_resp
,
1254 id
->hdr_nt_chal_resp
.buffer
, ps
, depth
))
1256 if(!smb_io_string2("lm_chal_resp", &id
->lm_chal_resp
,
1257 id
->hdr_lm_chal_resp
.buffer
, ps
, depth
))
1265 /*******************************************************************
1266 Inits a DOM_SAM_INFO structure.
1267 ********************************************************************/
1269 void init_sam_info(DOM_SAM_INFO
*sam
,
1270 const char *logon_srv
, const char *comp_name
,
1271 DOM_CRED
*clnt_cred
,
1272 DOM_CRED
*rtn_cred
, uint16 logon_level
,
1273 NET_ID_INFO_CTR
*ctr
)
1275 DEBUG(5,("init_sam_info: %d\n", __LINE__
));
1277 init_clnt_info2(&sam
->client
, logon_srv
, comp_name
, clnt_cred
);
1279 if (rtn_cred
!= NULL
) {
1280 sam
->ptr_rtn_cred
= 1;
1281 memcpy(&sam
->rtn_cred
, rtn_cred
, sizeof(sam
->rtn_cred
));
1283 sam
->ptr_rtn_cred
= 0;
1286 sam
->logon_level
= logon_level
;
1290 /*******************************************************************
1291 Reads or writes a DOM_SAM_INFO structure.
1292 ********************************************************************/
1294 static BOOL
net_io_id_info_ctr(const char *desc
, NET_ID_INFO_CTR
**pp_ctr
, prs_struct
*ps
, int depth
)
1296 NET_ID_INFO_CTR
*ctr
= *pp_ctr
;
1298 prs_debug(ps
, depth
, desc
, "smb_io_sam_info_ctr");
1301 if (UNMARSHALLING(ps
)) {
1302 ctr
= *pp_ctr
= PRS_ALLOC_MEM(ps
, NET_ID_INFO_CTR
, 1);
1310 /* don't 4-byte align here! */
1312 if(!prs_uint16("switch_value ", ps
, depth
, &ctr
->switch_value
))
1315 switch (ctr
->switch_value
) {
1317 if(!net_io_id_info1("", &ctr
->auth
.id1
, ps
, depth
))
1321 if(!net_io_id_info2("", &ctr
->auth
.id2
, ps
, depth
))
1326 DEBUG(4,("smb_io_sam_info_ctr: unknown switch_value!\n"));
1333 /*******************************************************************
1334 Reads or writes a DOM_SAM_INFO structure.
1335 ********************************************************************/
1337 static BOOL
smb_io_sam_info(const char *desc
, DOM_SAM_INFO
*sam
, prs_struct
*ps
, int depth
)
1342 prs_debug(ps
, depth
, desc
, "smb_io_sam_info");
1348 if(!smb_io_clnt_info2("", &sam
->client
, ps
, depth
))
1351 if(!prs_uint32("ptr_rtn_cred ", ps
, depth
, &sam
->ptr_rtn_cred
))
1353 if (sam
->ptr_rtn_cred
) {
1354 if(!smb_io_cred("", &sam
->rtn_cred
, ps
, depth
))
1358 if(!prs_uint16("logon_level ", ps
, depth
, &sam
->logon_level
))
1361 if (sam
->logon_level
!= 0) {
1362 if(!net_io_id_info_ctr("logon_info", &sam
->ctr
, ps
, depth
))
1369 /*******************************************************************
1370 Reads or writes a DOM_SAM_INFO_EX structure.
1371 ********************************************************************/
1373 static BOOL
smb_io_sam_info_ex(const char *desc
, DOM_SAM_INFO_EX
*sam
, prs_struct
*ps
, int depth
)
1378 prs_debug(ps
, depth
, desc
, "smb_io_sam_info_ex");
1384 if(!smb_io_clnt_srv("", &sam
->client
, ps
, depth
))
1387 if(!prs_uint16("logon_level ", ps
, depth
, &sam
->logon_level
))
1390 if (sam
->logon_level
!= 0) {
1391 if(!net_io_id_info_ctr("logon_info", &sam
->ctr
, ps
, depth
))
1398 /*************************************************************************
1399 Inits a NET_USER_INFO_3 structure.
1401 This is a network logon reply packet, and contains much information about
1402 the user. This information is passed as a (very long) paramater list
1403 to avoid having to link in the PASSDB code to every program that deals
1405 *************************************************************************/
1407 void init_net_user_info3(TALLOC_CTX
*ctx
, NET_USER_INFO_3
*usr
,
1411 const char* user_name
,
1412 const char* full_name
,
1413 const char* home_dir
,
1414 const char* dir_drive
,
1415 const char* logon_script
,
1416 const char* profile_path
,
1418 time_t unix_logon_time
,
1419 time_t unix_logoff_time
,
1420 time_t unix_kickoff_time
,
1421 time_t unix_pass_last_set_time
,
1422 time_t unix_pass_can_change_time
,
1423 time_t unix_pass_must_change_time
,
1425 uint16 logon_count
, uint16 bad_pw_count
,
1426 uint32 num_groups
, const DOM_GID
*gids
,
1427 uint32 user_flgs
, uchar user_session_key
[16],
1428 uchar lm_session_key
[16],
1429 const char *logon_srv
, const char *logon_dom
,
1430 const DOM_SID
*dom_sid
)
1432 /* only cope with one "other" sid, right now. */
1433 /* need to count the number of space-delimited sids */
1435 int num_other_sids
= 0;
1437 NTTIME logon_time
, logoff_time
, kickoff_time
,
1438 pass_last_set_time
, pass_can_change_time
,
1439 pass_must_change_time
;
1443 usr
->ptr_user_info
= 1; /* yes, we're bothering to put USER_INFO data here */
1445 /* Create NTTIME structs */
1446 unix_to_nt_time (&logon_time
, unix_logon_time
);
1447 unix_to_nt_time (&logoff_time
, unix_logoff_time
);
1448 unix_to_nt_time (&kickoff_time
, unix_kickoff_time
);
1449 unix_to_nt_time (&pass_last_set_time
, unix_pass_last_set_time
);
1450 unix_to_nt_time (&pass_can_change_time
, unix_pass_can_change_time
);
1451 unix_to_nt_time (&pass_must_change_time
, unix_pass_must_change_time
);
1453 usr
->logon_time
= logon_time
;
1454 usr
->logoff_time
= logoff_time
;
1455 usr
->kickoff_time
= kickoff_time
;
1456 usr
->pass_last_set_time
= pass_last_set_time
;
1457 usr
->pass_can_change_time
= pass_can_change_time
;
1458 usr
->pass_must_change_time
= pass_must_change_time
;
1460 usr
->logon_count
= logon_count
;
1461 usr
->bad_pw_count
= bad_pw_count
;
1463 usr
->user_rid
= user_rid
;
1464 usr
->group_rid
= group_rid
;
1465 usr
->num_groups
= num_groups
;
1467 usr
->buffer_groups
= 1; /* indicates fill in groups, below, even if there are none */
1468 usr
->user_flgs
= user_flgs
;
1470 if (user_session_key
!= NULL
)
1471 memcpy(usr
->user_sess_key
, user_session_key
, sizeof(usr
->user_sess_key
));
1473 memset((char *)usr
->user_sess_key
, '\0', sizeof(usr
->user_sess_key
));
1475 usr
->buffer_dom_id
= dom_sid
? 1 : 0; /* yes, we're bothering to put a domain SID in */
1477 memset((char *)usr
->lm_sess_key
, '\0', sizeof(usr
->lm_sess_key
));
1478 memset(&usr
->acct_flags
, '\0', sizeof(usr
->acct_flags
));
1480 for (i
=0; i
<7; i
++) {
1481 memset(&usr
->unknown
[i
], '\0', sizeof(usr
->unknown
));
1484 if (lm_session_key
!= NULL
) {
1485 memcpy(usr
->lm_sess_key
, lm_session_key
, sizeof(usr
->lm_sess_key
));
1488 num_other_sids
= init_dom_sid2s(ctx
, NULL
, &usr
->other_sids
);
1490 usr
->num_other_sids
= num_other_sids
;
1491 usr
->buffer_other_sids
= (num_other_sids
!= 0) ? 1 : 0;
1493 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
1494 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
1495 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_FLAGS_NONE
);
1496 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
1497 init_unistr2(&usr
->uni_logon_script
, logon_script
, UNI_FLAGS_NONE
);
1498 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
1499 init_unistr2(&usr
->uni_profile_path
, profile_path
, UNI_FLAGS_NONE
);
1500 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
1501 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_FLAGS_NONE
);
1502 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
1503 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_FLAGS_NONE
);
1504 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
1506 usr
->num_groups2
= num_groups
;
1508 usr
->gids
= TALLOC_ZERO_ARRAY(ctx
,DOM_GID
,num_groups
);
1509 if (usr
->gids
== NULL
&& num_groups
>0)
1512 for (i
= 0; i
< num_groups
; i
++)
1513 usr
->gids
[i
] = gids
[i
];
1515 init_unistr2(&usr
->uni_logon_srv
, logon_srv
, UNI_FLAGS_NONE
);
1516 init_uni_hdr(&usr
->hdr_logon_srv
, &usr
->uni_logon_srv
);
1517 init_unistr2(&usr
->uni_logon_dom
, logon_dom
, UNI_FLAGS_NONE
);
1518 init_uni_hdr(&usr
->hdr_logon_dom
, &usr
->uni_logon_dom
);
1520 init_dom_sid2(&usr
->dom_sid
, dom_sid
);
1521 /* "other" sids are set up above */
1524 void dump_acct_flags(uint32 acct_flags
) {
1527 DEBUG(lvl
,("dump_acct_flags\n"));
1528 if (acct_flags
& ACB_NORMAL
) {
1529 DEBUGADD(lvl
,("\taccount has UF_NORMAL_ACCOUNT\n"));
1531 if (acct_flags
& ACB_PWNOEXP
) {
1532 DEBUGADD(lvl
,("\taccount has UF_DONT_EXPIRE_PASSWD\n"));
1534 if (acct_flags
& ACB_ENC_TXT_PWD_ALLOWED
) {
1535 DEBUGADD(lvl
,("\taccount has UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED\n"));
1537 if (acct_flags
& ACB_NOT_DELEGATED
) {
1538 DEBUGADD(lvl
,("\taccount has UF_NOT_DELEGATED\n"));
1540 if (acct_flags
& ACB_USE_DES_KEY_ONLY
) {
1541 DEBUGADD(lvl
,("\taccount has UF_USE_DES_KEY_ONLY set, sig verify wont work\n"));
1545 void dump_user_flgs(uint32 user_flags
) {
1548 DEBUG(lvl
,("dump_user_flgs\n"));
1549 if (user_flags
& LOGON_EXTRA_SIDS
) {
1550 DEBUGADD(lvl
,("\taccount has LOGON_EXTRA_SIDS\n"));
1552 if (user_flags
& LOGON_RESOURCE_GROUPS
) {
1553 DEBUGADD(lvl
,("\taccount has LOGON_RESOURCE_GROUPS\n"));
1555 if (user_flags
& LOGON_NTLMV2_ENABLED
) {
1556 DEBUGADD(lvl
,("\taccount has LOGON_NTLMV2_ENABLED\n"));
1558 if (user_flags
& LOGON_CACHED_ACCOUNT
) {
1559 DEBUGADD(lvl
,("\taccount has LOGON_CACHED_ACCOUNT\n"));
1565 /*******************************************************************
1566 This code has been modified to cope with a NET_USER_INFO_2 - which is
1567 exactly the same as a NET_USER_INFO_3, minus the other sids parameters.
1568 We use validation level to determine if we're marshalling a info 2 or
1569 INFO_3 - be we always return an INFO_3. Based on code donated by Marc
1570 Jacobsen at HP. JRA.
1571 ********************************************************************/
1573 BOOL
net_io_user_info3(const char *desc
, NET_USER_INFO_3
*usr
, prs_struct
*ps
,
1574 int depth
, uint16 validation_level
, BOOL kerb_validation_level
)
1581 prs_debug(ps
, depth
, desc
, "net_io_user_info3");
1584 if (UNMARSHALLING(ps
))
1590 if(!prs_uint32("ptr_user_info ", ps
, depth
, &usr
->ptr_user_info
))
1593 if (usr
->ptr_user_info
== 0)
1596 if(!smb_io_time("logon time", &usr
->logon_time
, ps
, depth
)) /* logon time */
1598 if(!smb_io_time("logoff time", &usr
->logoff_time
, ps
, depth
)) /* logoff time */
1600 if(!smb_io_time("kickoff time", &usr
->kickoff_time
, ps
, depth
)) /* kickoff time */
1602 if(!smb_io_time("last set time", &usr
->pass_last_set_time
, ps
, depth
)) /* password last set time */
1604 if(!smb_io_time("can change time", &usr
->pass_can_change_time
, ps
, depth
)) /* password can change time */
1606 if(!smb_io_time("must change time", &usr
->pass_must_change_time
, ps
, depth
)) /* password must change time */
1609 if(!smb_io_unihdr("hdr_user_name", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
1611 if(!smb_io_unihdr("hdr_full_name", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
1613 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
1615 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
1617 if(!smb_io_unihdr("hdr_home_dir", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
1619 if(!smb_io_unihdr("hdr_dir_drive", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive unicode string header */
1622 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
)) /* logon count */
1624 if(!prs_uint16("bad_pw_count ", ps
, depth
, &usr
->bad_pw_count
)) /* bad password count */
1627 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User RID */
1629 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group RID */
1631 if(!prs_uint32("num_groups ", ps
, depth
, &usr
->num_groups
)) /* num groups */
1633 if(!prs_uint32("buffer_groups ", ps
, depth
, &usr
->buffer_groups
)) /* undocumented buffer pointer to groups. */
1635 if(!prs_uint32("user_flgs ", ps
, depth
, &usr
->user_flgs
)) /* user flags */
1637 dump_user_flgs(usr
->user_flgs
);
1638 if(!prs_uint8s(False
, "user_sess_key", ps
, depth
, usr
->user_sess_key
, 16)) /* user session key */
1641 if(!smb_io_unihdr("hdr_logon_srv", &usr
->hdr_logon_srv
, ps
, depth
)) /* logon server unicode string header */
1643 if(!smb_io_unihdr("hdr_logon_dom", &usr
->hdr_logon_dom
, ps
, depth
)) /* logon domain unicode string header */
1646 if(!prs_uint32("buffer_dom_id ", ps
, depth
, &usr
->buffer_dom_id
)) /* undocumented logon domain id pointer */
1649 if(!prs_uint8s(False
, "lm_sess_key", ps
, depth
, usr
->lm_sess_key
, 8)) /* lm session key */
1652 if(!prs_uint32("acct_flags ", ps
, depth
, &usr
->acct_flags
)) /* Account flags */
1654 dump_acct_flags(usr
->acct_flags
);
1655 for (i
= 0; i
< 7; i
++)
1657 if (!prs_uint32("unkown", ps
, depth
, &usr
->unknown
[i
])) /* unknown */
1661 if (validation_level
== 3) {
1662 if(!prs_uint32("num_other_sids", ps
, depth
, &usr
->num_other_sids
)) /* 0 - num_sids */
1664 if(!prs_uint32("buffer_other_sids", ps
, depth
, &usr
->buffer_other_sids
)) /* NULL - undocumented pointer to SIDs. */
1667 if (UNMARSHALLING(ps
)) {
1668 usr
->num_other_sids
= 0;
1669 usr
->buffer_other_sids
= 0;
1673 /* get kerb validation info (not really part of user_info_3) - Guenther */
1675 if (kerb_validation_level
) {
1677 if(!prs_uint32("ptr_res_group_dom_sid", ps
, depth
, &usr
->ptr_res_group_dom_sid
))
1679 if(!prs_uint32("res_group_count", ps
, depth
, &usr
->res_group_count
))
1681 if(!prs_uint32("ptr_res_groups", ps
, depth
, &usr
->ptr_res_groups
))
1685 if(!smb_io_unistr2("uni_user_name", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
1687 if(!smb_io_unistr2("uni_full_name", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
1689 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
1691 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
1693 if(!smb_io_unistr2("uni_home_dir", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
1695 if(!smb_io_unistr2("uni_dir_drive", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
1701 if (usr
->num_groups
> 0) {
1703 if(!prs_uint32("num_groups2 ", ps
, depth
, &usr
->num_groups2
)) /* num groups2 */
1706 if (usr
->num_groups
!= usr
->num_groups2
) {
1707 DEBUG(3,("net_io_user_info3: num_groups mismatch! (%d != %d)\n",
1708 usr
->num_groups
, usr
->num_groups2
));
1713 if (UNMARSHALLING(ps
)) {
1714 usr
->gids
= PRS_ALLOC_MEM(ps
, DOM_GID
, usr
->num_groups
);
1715 if (usr
->gids
== NULL
)
1719 for (i
= 0; i
< usr
->num_groups
; i
++) {
1720 if(!smb_io_gid("", &usr
->gids
[i
], ps
, depth
)) /* group info */
1726 if(!smb_io_unistr2("uni_logon_srv", &usr
->uni_logon_srv
, usr
->hdr_logon_srv
.buffer
, ps
, depth
)) /* logon server unicode string */
1728 if(!smb_io_unistr2("uni_logon_dom", &usr
->uni_logon_dom
, usr
->hdr_logon_dom
.buffer
, ps
, depth
)) /* logon domain unicode string */
1731 if(!smb_io_dom_sid2("", &usr
->dom_sid
, ps
, depth
)) /* domain SID */
1734 if (validation_level
== 3 && usr
->buffer_other_sids
) {
1736 uint32 num_other_sids
= usr
->num_other_sids
;
1738 if (!(usr
->user_flgs
& LOGON_EXTRA_SIDS
)) {
1739 DEBUG(10,("net_io_user_info3: user_flgs attribute does not have LOGON_EXTRA_SIDS\n"));
1743 if (!prs_uint32("num_other_sids", ps
, depth
,
1747 if (num_other_sids
!= usr
->num_other_sids
)
1750 if (UNMARSHALLING(ps
)) {
1751 usr
->other_sids
= PRS_ALLOC_MEM(ps
, DOM_SID2
, usr
->num_other_sids
);
1752 usr
->other_sids_attrib
=
1753 PRS_ALLOC_MEM(ps
, uint32
, usr
->num_other_sids
);
1755 if ((num_other_sids
!= 0) &&
1756 ((usr
->other_sids
== NULL
) ||
1757 (usr
->other_sids_attrib
== NULL
)))
1761 /* First the pointers to the SIDS and attributes */
1765 for (i
=0; i
<usr
->num_other_sids
; i
++) {
1768 if (!prs_uint32("sid_ptr", ps
, depth
, &ptr
))
1771 if (UNMARSHALLING(ps
) && (ptr
== 0))
1774 if (!prs_uint32("attribute", ps
, depth
,
1775 &usr
->other_sids_attrib
[i
]))
1779 for (i
= 0; i
< usr
->num_other_sids
; i
++) {
1780 if(!smb_io_dom_sid2("", &usr
->other_sids
[i
], ps
, depth
)) /* other domain SIDs */
1790 /*******************************************************************
1791 Reads or writes a structure.
1792 ********************************************************************/
1794 BOOL
net_io_q_sam_logon(const char *desc
, NET_Q_SAM_LOGON
*q_l
, prs_struct
*ps
, int depth
)
1799 prs_debug(ps
, depth
, desc
, "net_io_q_sam_logon");
1805 if(!smb_io_sam_info("", &q_l
->sam_id
, ps
, depth
))
1808 if(!prs_align_uint16(ps
))
1811 if(!prs_uint16("validation_level", ps
, depth
, &q_l
->validation_level
))
1817 /*******************************************************************
1818 Reads or writes a structure.
1819 ********************************************************************/
1821 BOOL
net_io_r_sam_logon(const char *desc
, NET_R_SAM_LOGON
*r_l
, prs_struct
*ps
, int depth
)
1826 prs_debug(ps
, depth
, desc
, "net_io_r_sam_logon");
1829 if(!prs_uint32("buffer_creds", ps
, depth
, &r_l
->buffer_creds
)) /* undocumented buffer pointer */
1831 if (&r_l
->buffer_creds
) {
1832 if(!smb_io_cred("", &r_l
->srv_creds
, ps
, depth
)) /* server credentials. server time stamp appears to be ignored. */
1836 if(!prs_uint16("switch_value", ps
, depth
, &r_l
->switch_value
))
1841 #if 1 /* W2k always needs this - even for bad passwd. JRA */
1842 if(!net_io_user_info3("", r_l
->user
, ps
, depth
, r_l
->switch_value
, False
))
1845 if (r_l
->switch_value
!= 0) {
1846 if(!net_io_user_info3("", r_l
->user
, ps
, depth
, r_l
->switch_value
, False
))
1851 if(!prs_uint32("auth_resp ", ps
, depth
, &r_l
->auth_resp
)) /* 1 - Authoritative response; 0 - Non-Auth? */
1854 if(!prs_ntstatus("status ", ps
, depth
, &r_l
->status
))
1863 /*******************************************************************
1864 Reads or writes a structure.
1865 ********************************************************************/
1867 BOOL
net_io_q_sam_logon_ex(const char *desc
, NET_Q_SAM_LOGON_EX
*q_l
, prs_struct
*ps
, int depth
)
1872 prs_debug(ps
, depth
, desc
, "net_io_q_sam_logon_ex");
1878 if(!smb_io_sam_info_ex("", &q_l
->sam_id
, ps
, depth
))
1881 if(!prs_align_uint16(ps
))
1884 if(!prs_uint16("validation_level", ps
, depth
, &q_l
->validation_level
))
1887 if(!prs_uint32("flags ", ps
, depth
, &q_l
->flags
))
1893 /*******************************************************************
1894 Reads or writes a structure.
1895 ********************************************************************/
1897 BOOL
net_io_r_sam_logon_ex(const char *desc
, NET_R_SAM_LOGON_EX
*r_l
, prs_struct
*ps
, int depth
)
1902 prs_debug(ps
, depth
, desc
, "net_io_r_sam_logon_ex");
1905 if(!prs_uint16("switch_value", ps
, depth
, &r_l
->switch_value
))
1910 #if 1 /* W2k always needs this - even for bad passwd. JRA */
1911 if(!net_io_user_info3("", r_l
->user
, ps
, depth
, r_l
->switch_value
, False
))
1914 if (r_l
->switch_value
!= 0) {
1915 if(!net_io_user_info3("", r_l
->user
, ps
, depth
, r_l
->switch_value
, False
))
1920 if(!prs_uint32("auth_resp ", ps
, depth
, &r_l
->auth_resp
)) /* 1 - Authoritative response; 0 - Non-Auth? */
1923 if(!prs_uint32("flags ", ps
, depth
, &r_l
->flags
))
1926 if(!prs_ntstatus("status ", ps
, depth
, &r_l
->status
))
1936 /*******************************************************************
1937 Reads or writes a structure.
1938 ********************************************************************/
1940 BOOL
net_io_q_sam_logoff(const char *desc
, NET_Q_SAM_LOGOFF
*q_l
, prs_struct
*ps
, int depth
)
1945 prs_debug(ps
, depth
, desc
, "net_io_q_sam_logoff");
1951 if(!smb_io_sam_info("", &q_l
->sam_id
, ps
, depth
)) /* domain SID */
1957 /*******************************************************************
1958 Reads or writes a structure.
1959 ********************************************************************/
1961 BOOL
net_io_r_sam_logoff(const char *desc
, NET_R_SAM_LOGOFF
*r_l
, prs_struct
*ps
, int depth
)
1966 prs_debug(ps
, depth
, desc
, "net_io_r_sam_logoff");
1972 if(!prs_uint32("buffer_creds", ps
, depth
, &r_l
->buffer_creds
)) /* undocumented buffer pointer */
1974 if(!smb_io_cred("", &r_l
->srv_creds
, ps
, depth
)) /* server credentials. server time stamp appears to be ignored. */
1977 if(!prs_ntstatus("status ", ps
, depth
, &r_l
->status
))
1983 /*******************************************************************
1984 makes a NET_Q_SAM_SYNC structure.
1985 ********************************************************************/
1986 BOOL
init_net_q_sam_sync(NET_Q_SAM_SYNC
* q_s
, const char *srv_name
,
1987 const char *cli_name
, DOM_CRED
*cli_creds
,
1988 DOM_CRED
*ret_creds
, uint32 database_id
,
1991 DEBUG(5, ("init_q_sam_sync\n"));
1993 init_unistr2(&q_s
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
1994 init_unistr2(&q_s
->uni_cli_name
, cli_name
, UNI_STR_TERMINATE
);
1997 memcpy(&q_s
->cli_creds
, cli_creds
, sizeof(q_s
->cli_creds
));
2000 memcpy(&q_s
->ret_creds
, ret_creds
, sizeof(q_s
->ret_creds
));
2002 memset(&q_s
->ret_creds
, 0, sizeof(q_s
->ret_creds
));
2004 q_s
->database_id
= database_id
;
2005 q_s
->restart_state
= 0;
2006 q_s
->sync_context
= next_rid
;
2007 q_s
->max_size
= 0xffff;
2012 /*******************************************************************
2013 reads or writes a structure.
2014 ********************************************************************/
2015 BOOL
net_io_q_sam_sync(const char *desc
, NET_Q_SAM_SYNC
* q_s
, prs_struct
*ps
,
2018 prs_debug(ps
, depth
, desc
, "net_io_q_sam_sync");
2021 if (!smb_io_unistr2("", &q_s
->uni_srv_name
, True
, ps
, depth
))
2023 if (!smb_io_unistr2("", &q_s
->uni_cli_name
, True
, ps
, depth
))
2026 if (!smb_io_cred("", &q_s
->cli_creds
, ps
, depth
))
2028 if (!smb_io_cred("", &q_s
->ret_creds
, ps
, depth
))
2031 if (!prs_uint32("database_id ", ps
, depth
, &q_s
->database_id
))
2033 if (!prs_uint32("restart_state", ps
, depth
, &q_s
->restart_state
))
2035 if (!prs_uint32("sync_context ", ps
, depth
, &q_s
->sync_context
))
2038 if (!prs_uint32("max_size", ps
, depth
, &q_s
->max_size
))
2044 /*******************************************************************
2045 reads or writes a structure.
2046 ********************************************************************/
2047 static BOOL
net_io_sam_delta_hdr(const char *desc
, SAM_DELTA_HDR
* delta
,
2048 prs_struct
*ps
, int depth
)
2050 prs_debug(ps
, depth
, desc
, "net_io_sam_delta_hdr");
2053 if (!prs_uint16("type", ps
, depth
, &delta
->type
))
2055 if (!prs_uint16("type2", ps
, depth
, &delta
->type2
))
2057 if (!prs_uint32("target_rid", ps
, depth
, &delta
->target_rid
))
2060 if (!prs_uint32("type3", ps
, depth
, &delta
->type3
))
2063 /* Not sure why we need this but it seems to be necessary to get
2064 sam deltas working. */
2066 if (delta
->type
!= 0x16) {
2067 if (!prs_uint32("ptr_delta", ps
, depth
, &delta
->ptr_delta
))
2074 /*******************************************************************
2075 reads or writes a structure.
2076 ********************************************************************/
2077 static BOOL
net_io_sam_delta_mod_count(const char *desc
, SAM_DELTA_MOD_COUNT
*info
,
2078 prs_struct
*ps
, int depth
)
2080 prs_debug(ps
, depth
, desc
, "net_io_sam_delta_stamp");
2083 if (!prs_uint32("seqnum", ps
, depth
, &info
->seqnum
))
2085 if (!prs_uint32("dom_mod_count_ptr", ps
, depth
,
2086 &info
->dom_mod_count_ptr
))
2089 if (info
->dom_mod_count_ptr
) {
2090 if (!prs_uint64("dom_mod_count", ps
, depth
,
2091 &info
->dom_mod_count
))
2098 /*******************************************************************
2099 reads or writes a structure.
2100 ********************************************************************/
2101 static BOOL
net_io_sam_domain_info(const char *desc
, SAM_DOMAIN_INFO
* info
,
2102 prs_struct
*ps
, int depth
)
2104 prs_debug(ps
, depth
, desc
, "net_io_sam_domain_info");
2107 if (!smb_io_unihdr("hdr_dom_name", &info
->hdr_dom_name
, ps
, depth
))
2109 if (!smb_io_unihdr("hdr_oem_info", &info
->hdr_oem_info
, ps
, depth
))
2112 if (!prs_uint64("force_logoff", ps
, depth
, &info
->force_logoff
))
2114 if (!prs_uint16("min_pwd_len", ps
, depth
, &info
->min_pwd_len
))
2116 if (!prs_uint16("pwd_history_len", ps
, depth
, &info
->pwd_history_len
))
2118 if (!prs_uint64("max_pwd_age", ps
, depth
, &info
->max_pwd_age
))
2120 if (!prs_uint64("min_pwd_age", ps
, depth
, &info
->min_pwd_age
))
2122 if (!prs_uint64("dom_mod_count", ps
, depth
, &info
->dom_mod_count
))
2124 if (!smb_io_time("creation_time", &info
->creation_time
, ps
, depth
))
2126 if (!prs_uint32("security_information", ps
, depth
, &info
->security_information
))
2128 if (!smb_io_bufhdr4("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
2130 if (!smb_io_lockout_string_hdr("hdr_account_lockout_string", &info
->hdr_account_lockout
, ps
, depth
))
2132 if (!smb_io_unihdr("hdr_unknown2", &info
->hdr_unknown2
, ps
, depth
))
2134 if (!smb_io_unihdr("hdr_unknown3", &info
->hdr_unknown3
, ps
, depth
))
2136 if (!smb_io_unihdr("hdr_unknown4", &info
->hdr_unknown4
, ps
, depth
))
2138 if (!prs_uint32("logon_chgpass", ps
, depth
, &info
->logon_chgpass
))
2140 if (!prs_uint32("unknown6", ps
, depth
, &info
->unknown6
))
2142 if (!prs_uint32("unknown7", ps
, depth
, &info
->unknown7
))
2144 if (!prs_uint32("unknown8", ps
, depth
, &info
->unknown8
))
2147 if (!smb_io_unistr2("uni_dom_name", &info
->uni_dom_name
,
2148 info
->hdr_dom_name
.buffer
, ps
, depth
))
2150 if (!smb_io_unistr2("buf_oem_info", &info
->buf_oem_info
,
2151 info
->hdr_oem_info
.buffer
, ps
, depth
))
2154 if (!smb_io_rpc_blob("buf_sec_desc", &info
->buf_sec_desc
, ps
, depth
))
2157 if (!smb_io_account_lockout_str("account_lockout", &info
->account_lockout
,
2158 info
->hdr_account_lockout
.buffer
, ps
, depth
))
2161 if (!smb_io_unistr2("buf_unknown2", &info
->buf_unknown2
,
2162 info
->hdr_unknown2
.buffer
, ps
, depth
))
2164 if (!smb_io_unistr2("buf_unknown3", &info
->buf_unknown3
,
2165 info
->hdr_unknown3
.buffer
, ps
, depth
))
2167 if (!smb_io_unistr2("buf_unknown4", &info
->buf_unknown4
,
2168 info
->hdr_unknown4
.buffer
, ps
, depth
))
2174 /*******************************************************************
2175 reads or writes a structure.
2176 ********************************************************************/
2177 static BOOL
net_io_sam_group_info(const char *desc
, SAM_GROUP_INFO
* info
,
2178 prs_struct
*ps
, int depth
)
2180 prs_debug(ps
, depth
, desc
, "net_io_sam_group_info");
2183 if (!smb_io_unihdr("hdr_grp_name", &info
->hdr_grp_name
, ps
, depth
))
2185 if (!smb_io_gid("gid", &info
->gid
, ps
, depth
))
2187 if (!smb_io_unihdr("hdr_grp_desc", &info
->hdr_grp_desc
, ps
, depth
))
2189 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
2192 if (ps
->data_offset
+ 48 > ps
->buffer_size
)
2194 ps
->data_offset
+= 48;
2196 if (!smb_io_unistr2("uni_grp_name", &info
->uni_grp_name
,
2197 info
->hdr_grp_name
.buffer
, ps
, depth
))
2199 if (!smb_io_unistr2("uni_grp_desc", &info
->uni_grp_desc
,
2200 info
->hdr_grp_desc
.buffer
, ps
, depth
))
2202 if (!smb_io_rpc_blob("buf_sec_desc", &info
->buf_sec_desc
, ps
, depth
))
2208 /*******************************************************************
2209 reads or writes a structure.
2210 ********************************************************************/
2211 static BOOL
net_io_sam_passwd_info(const char *desc
, SAM_PWD
* pwd
,
2212 prs_struct
*ps
, int depth
)
2214 prs_debug(ps
, depth
, desc
, "net_io_sam_passwd_info");
2217 if (!prs_uint32("unk_0 ", ps
, depth
, &pwd
->unk_0
))
2220 if (!smb_io_unihdr("hdr_lm_pwd", &pwd
->hdr_lm_pwd
, ps
, depth
))
2222 if (!prs_uint8s(False
, "buf_lm_pwd", ps
, depth
, pwd
->buf_lm_pwd
, 16))
2225 if (!smb_io_unihdr("hdr_nt_pwd", &pwd
->hdr_nt_pwd
, ps
, depth
))
2227 if (!prs_uint8s(False
, "buf_nt_pwd", ps
, depth
, pwd
->buf_nt_pwd
, 16))
2230 if (!smb_io_unihdr("", &pwd
->hdr_empty_lm
, ps
, depth
))
2232 if (!smb_io_unihdr("", &pwd
->hdr_empty_nt
, ps
, depth
))
2238 /*******************************************************************
2239 makes a SAM_ACCOUNT_INFO structure.
2240 ********************************************************************/
2241 BOOL
make_sam_account_info(SAM_ACCOUNT_INFO
* info
,
2242 const UNISTR2
*user_name
,
2243 const UNISTR2
*full_name
,
2244 uint32 user_rid
, uint32 group_rid
,
2245 const UNISTR2
*home_dir
,
2246 const UNISTR2
*dir_drive
,
2247 const UNISTR2
*log_scr
,
2248 const UNISTR2
*desc
,
2250 const UNISTR2
*prof_path
,
2251 const UNISTR2
*wkstas
,
2252 const UNISTR2
*unk_str
, const UNISTR2
*mung_dial
)
2254 int len_user_name
= user_name
!= NULL
? user_name
->uni_str_len
: 0;
2255 int len_full_name
= full_name
!= NULL
? full_name
->uni_str_len
: 0;
2256 int len_home_dir
= home_dir
!= NULL
? home_dir
->uni_str_len
: 0;
2257 int len_dir_drive
= dir_drive
!= NULL
? dir_drive
->uni_str_len
: 0;
2258 int len_logon_script
= log_scr
!= NULL
? log_scr
->uni_str_len
: 0;
2259 int len_profile_path
= prof_path
!= NULL
? prof_path
->uni_str_len
: 0;
2260 int len_description
= desc
!= NULL
? desc
->uni_str_len
: 0;
2261 int len_workstations
= wkstas
!= NULL
? wkstas
->uni_str_len
: 0;
2262 int len_unknown_str
= unk_str
!= NULL
? unk_str
->uni_str_len
: 0;
2263 int len_munged_dial
= mung_dial
!= NULL
? mung_dial
->uni_str_len
: 0;
2265 DEBUG(5, ("make_sam_account_info\n"));
2267 make_uni_hdr(&info
->hdr_acct_name
, len_user_name
);
2268 make_uni_hdr(&info
->hdr_full_name
, len_full_name
);
2269 make_uni_hdr(&info
->hdr_home_dir
, len_home_dir
);
2270 make_uni_hdr(&info
->hdr_dir_drive
, len_dir_drive
);
2271 make_uni_hdr(&info
->hdr_logon_script
, len_logon_script
);
2272 make_uni_hdr(&info
->hdr_profile
, len_profile_path
);
2273 make_uni_hdr(&info
->hdr_acct_desc
, len_description
);
2274 make_uni_hdr(&info
->hdr_workstations
, len_workstations
);
2275 make_uni_hdr(&info
->hdr_comment
, len_unknown_str
);
2276 make_uni_hdr(&info
->hdr_parameters
, len_munged_dial
);
2279 make_bufhdr2(&info
->hdr_sec_desc
, 0, 0, 0);
2281 info
->user_rid
= user_rid
;
2282 info
->group_rid
= group_rid
;
2284 init_nt_time(&info
->logon_time
);
2285 init_nt_time(&info
->logoff_time
);
2286 init_nt_time(&info
->pwd_last_set_time
);
2287 init_nt_time(&info
->acct_expiry_time
);
2289 info
->logon_divs
= 0xA8;
2290 info
->ptr_logon_hrs
= 0; /* Don't care right now */
2292 info
->bad_pwd_count
= 0;
2293 info
->logon_count
= 0;
2294 info
->acb_info
= acb_info
;
2295 info
->nt_pwd_present
= 0;
2296 info
->lm_pwd_present
= 0;
2297 info
->pwd_expired
= 0;
2301 info
->unknown1
= 0x4EC;
2304 copy_unistr2(&info
->uni_acct_name
, user_name
);
2305 copy_unistr2(&info
->uni_full_name
, full_name
);
2306 copy_unistr2(&info
->uni_home_dir
, home_dir
);
2307 copy_unistr2(&info
->uni_dir_drive
, dir_drive
);
2308 copy_unistr2(&info
->uni_logon_script
, log_scr
);
2309 copy_unistr2(&info
->uni_profile
, prof_path
);
2310 copy_unistr2(&info
->uni_acct_desc
, desc
);
2311 copy_unistr2(&info
->uni_workstations
, wkstas
);
2312 copy_unistr2(&info
->uni_comment
, unk_str
);
2313 copy_unistr2(&info
->uni_parameters
, mung_dial
);
2318 /*******************************************************************
2319 reads or writes a structure.
2320 ********************************************************************/
2321 static BOOL
net_io_sam_account_info(const char *desc
, SAM_ACCOUNT_INFO
*info
,
2322 prs_struct
*ps
, int depth
)
2324 BUFHDR2 hdr_priv_data
;
2327 prs_debug(ps
, depth
, desc
, "net_io_sam_account_info");
2330 if (!smb_io_unihdr("hdr_acct_name", &info
->hdr_acct_name
, ps
, depth
))
2332 if (!smb_io_unihdr("hdr_full_name", &info
->hdr_full_name
, ps
, depth
))
2335 if (!prs_uint32("user_rid ", ps
, depth
, &info
->user_rid
))
2337 if (!prs_uint32("group_rid", ps
, depth
, &info
->group_rid
))
2340 if (!smb_io_unihdr("hdr_home_dir ", &info
->hdr_home_dir
, ps
, depth
))
2342 if (!smb_io_unihdr("hdr_dir_drive", &info
->hdr_dir_drive
, ps
, depth
))
2344 if (!smb_io_unihdr("hdr_logon_script", &info
->hdr_logon_script
, ps
,
2348 if (!smb_io_unihdr("hdr_acct_desc", &info
->hdr_acct_desc
, ps
, depth
))
2350 if (!smb_io_unihdr("hdr_workstations", &info
->hdr_workstations
, ps
,
2354 if (!smb_io_time("logon_time", &info
->logon_time
, ps
, depth
))
2356 if (!smb_io_time("logoff_time", &info
->logoff_time
, ps
, depth
))
2359 if (!prs_uint32("logon_divs ", ps
, depth
, &info
->logon_divs
))
2361 if (!prs_uint32("ptr_logon_hrs", ps
, depth
, &info
->ptr_logon_hrs
))
2364 if (!prs_uint16("bad_pwd_count", ps
, depth
, &info
->bad_pwd_count
))
2366 if (!prs_uint16("logon_count", ps
, depth
, &info
->logon_count
))
2368 if (!smb_io_time("pwd_last_set_time", &info
->pwd_last_set_time
, ps
,
2371 if (!smb_io_time("acct_expiry_time", &info
->acct_expiry_time
, ps
,
2375 if (!prs_uint32("acb_info", ps
, depth
, &info
->acb_info
))
2377 if (!prs_uint8s(False
, "nt_pwd", ps
, depth
, info
->nt_pwd
, 16))
2379 if (!prs_uint8s(False
, "lm_pwd", ps
, depth
, info
->lm_pwd
, 16))
2381 if (!prs_uint8("lm_pwd_present", ps
, depth
, &info
->lm_pwd_present
))
2383 if (!prs_uint8("nt_pwd_present", ps
, depth
, &info
->nt_pwd_present
))
2385 if (!prs_uint8("pwd_expired", ps
, depth
, &info
->pwd_expired
))
2388 if (!smb_io_unihdr("hdr_comment", &info
->hdr_comment
, ps
, depth
))
2390 if (!smb_io_unihdr("hdr_parameters", &info
->hdr_parameters
, ps
,
2393 if (!prs_uint16("country", ps
, depth
, &info
->country
))
2395 if (!prs_uint16("codepage", ps
, depth
, &info
->codepage
))
2398 if (!smb_io_bufhdr2("hdr_priv_data", &hdr_priv_data
, ps
, depth
))
2400 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
2402 if (!smb_io_unihdr("hdr_profile", &info
->hdr_profile
, ps
, depth
))
2405 for (i
= 0; i
< 3; i
++)
2407 if (!smb_io_unihdr("hdr_reserved", &info
->hdr_reserved
[i
],
2412 for (i
= 0; i
< 4; i
++)
2414 if (!prs_uint32("dw_reserved", ps
, depth
,
2415 &info
->dw_reserved
[i
]))
2419 if (!smb_io_unistr2("uni_acct_name", &info
->uni_acct_name
,
2420 info
->hdr_acct_name
.buffer
, ps
, depth
))
2423 if (!smb_io_unistr2("uni_full_name", &info
->uni_full_name
,
2424 info
->hdr_full_name
.buffer
, ps
, depth
))
2427 if (!smb_io_unistr2("uni_home_dir ", &info
->uni_home_dir
,
2428 info
->hdr_home_dir
.buffer
, ps
, depth
))
2431 if (!smb_io_unistr2("uni_dir_drive", &info
->uni_dir_drive
,
2432 info
->hdr_dir_drive
.buffer
, ps
, depth
))
2435 if (!smb_io_unistr2("uni_logon_script", &info
->uni_logon_script
,
2436 info
->hdr_logon_script
.buffer
, ps
, depth
))
2439 if (!smb_io_unistr2("uni_acct_desc", &info
->uni_acct_desc
,
2440 info
->hdr_acct_desc
.buffer
, ps
, depth
))
2443 if (!smb_io_unistr2("uni_workstations", &info
->uni_workstations
,
2444 info
->hdr_workstations
.buffer
, ps
, depth
))
2448 if (!prs_uint32("unknown1", ps
, depth
, &info
->unknown1
))
2450 if (!prs_uint32("unknown2", ps
, depth
, &info
->unknown2
))
2453 if (!smb_io_rpc_blob("buf_logon_hrs", &info
->buf_logon_hrs
, ps
, depth
))
2456 if (!smb_io_unistr2("uni_comment", &info
->uni_comment
,
2457 info
->hdr_comment
.buffer
, ps
, depth
))
2460 if (!smb_io_unistr2("uni_parameters", &info
->uni_parameters
,
2461 info
->hdr_parameters
.buffer
, ps
, depth
))
2464 if (hdr_priv_data
.buffer
!= 0)
2468 if (!prs_uint32("pwd_len", ps
, depth
, &len
))
2470 old_offset
= ps
->data_offset
;
2476 if (!prs_hash1(ps
, ps
->data_offset
, len
))
2479 if (!net_io_sam_passwd_info("pass", &info
->pass
,
2486 if (!prs_hash1(ps
, old_offset
, len
))
2490 if (old_offset
+ len
> ps
->buffer_size
)
2492 ps
->data_offset
= old_offset
+ len
;
2494 if (!smb_io_rpc_blob("buf_sec_desc", &info
->buf_sec_desc
, ps
, depth
))
2497 if (!smb_io_unistr2("uni_profile", &info
->uni_profile
,
2498 info
->hdr_profile
.buffer
, ps
, depth
))
2506 /*******************************************************************
2507 reads or writes a structure.
2508 ********************************************************************/
2509 static BOOL
net_io_sam_group_mem_info(const char *desc
, SAM_GROUP_MEM_INFO
* info
,
2510 prs_struct
*ps
, int depth
)
2515 prs_debug(ps
, depth
, desc
, "net_io_sam_group_mem_info");
2519 if (!prs_uint32("ptr_rids ", ps
, depth
, &info
->ptr_rids
))
2521 if (!prs_uint32("ptr_attribs", ps
, depth
, &info
->ptr_attribs
))
2523 if (!prs_uint32("num_members", ps
, depth
, &info
->num_members
))
2526 if (ps
->data_offset
+ 16 > ps
->buffer_size
)
2528 ps
->data_offset
+= 16;
2530 if (info
->ptr_rids
!= 0)
2532 if (!prs_uint32("num_members2", ps
, depth
,
2533 &info
->num_members2
))
2536 if (info
->num_members2
!= info
->num_members
)
2542 info
->rids
= TALLOC_ARRAY(ps
->mem_ctx
, uint32
, info
->num_members2
);
2544 if (info
->rids
== NULL
) {
2545 DEBUG(0, ("out of memory allocating %d rids\n",
2546 info
->num_members2
));
2550 for (i
= 0; i
< info
->num_members2
; i
++)
2552 slprintf(tmp
, sizeof(tmp
) - 1, "rids[%02d]", i
);
2553 if (!prs_uint32(tmp
, ps
, depth
, &info
->rids
[i
]))
2558 if (info
->ptr_attribs
!= 0)
2560 if (!prs_uint32("num_members3", ps
, depth
,
2561 &info
->num_members3
))
2563 if (info
->num_members3
!= info
->num_members
)
2569 info
->attribs
= TALLOC_ARRAY(ps
->mem_ctx
, uint32
, info
->num_members3
);
2571 if (info
->attribs
== NULL
) {
2572 DEBUG(0, ("out of memory allocating %d attribs\n",
2573 info
->num_members3
));
2577 for (i
= 0; i
< info
->num_members3
; i
++)
2579 slprintf(tmp
, sizeof(tmp
) - 1, "attribs[%02d]", i
);
2580 if (!prs_uint32(tmp
, ps
, depth
, &info
->attribs
[i
]))
2588 /*******************************************************************
2589 reads or writes a structure.
2590 ********************************************************************/
2591 static BOOL
net_io_sam_alias_info(const char *desc
, SAM_ALIAS_INFO
* info
,
2592 prs_struct
*ps
, int depth
)
2594 prs_debug(ps
, depth
, desc
, "net_io_sam_alias_info");
2597 if (!smb_io_unihdr("hdr_als_name", &info
->hdr_als_name
, ps
, depth
))
2599 if (!prs_uint32("als_rid", ps
, depth
, &info
->als_rid
))
2601 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
2603 if (!smb_io_unihdr("hdr_als_desc", &info
->hdr_als_desc
, ps
, depth
))
2606 if (ps
->data_offset
+ 40 > ps
->buffer_size
)
2608 ps
->data_offset
+= 40;
2610 if (!smb_io_unistr2("uni_als_name", &info
->uni_als_name
,
2611 info
->hdr_als_name
.buffer
, ps
, depth
))
2613 if (!smb_io_rpc_blob("buf_sec_desc", &info
->buf_sec_desc
, ps
, depth
))
2616 if (!smb_io_unistr2("uni_als_desc", &info
->uni_als_desc
,
2617 info
->hdr_als_desc
.buffer
, ps
, depth
))
2623 /*******************************************************************
2624 reads or writes a structure.
2625 ********************************************************************/
2626 static BOOL
net_io_sam_alias_mem_info(const char *desc
, SAM_ALIAS_MEM_INFO
* info
,
2627 prs_struct
*ps
, int depth
)
2632 prs_debug(ps
, depth
, desc
, "net_io_sam_alias_mem_info");
2636 if (!prs_uint32("num_members", ps
, depth
, &info
->num_members
))
2638 if (!prs_uint32("ptr_members", ps
, depth
, &info
->ptr_members
))
2641 if (ps
->data_offset
+ 16 > ps
->buffer_size
)
2643 ps
->data_offset
+= 16;
2645 if (info
->ptr_members
!= 0)
2647 if (!prs_uint32("num_sids", ps
, depth
, &info
->num_sids
))
2649 if (info
->num_sids
!= info
->num_members
)
2655 info
->ptr_sids
= TALLOC_ARRAY(ps
->mem_ctx
, uint32
, info
->num_sids
);
2657 if (info
->ptr_sids
== NULL
) {
2658 DEBUG(0, ("out of memory allocating %d ptr_sids\n",
2663 for (i
= 0; i
< info
->num_sids
; i
++)
2665 slprintf(tmp
, sizeof(tmp
) - 1, "ptr_sids[%02d]", i
);
2666 if (!prs_uint32(tmp
, ps
, depth
, &info
->ptr_sids
[i
]))
2670 info
->sids
= TALLOC_ARRAY(ps
->mem_ctx
, DOM_SID2
, info
->num_sids
);
2672 if (info
->sids
== NULL
) {
2673 DEBUG(0, ("error allocating %d sids\n",
2678 for (i
= 0; i
< info
->num_sids
; i
++)
2680 if (info
->ptr_sids
[i
] != 0)
2682 slprintf(tmp
, sizeof(tmp
) - 1, "sids[%02d]",
2684 if (!smb_io_dom_sid2(tmp
, &info
->sids
[i
],
2694 /*******************************************************************
2695 reads or writes a structure.
2696 ********************************************************************/
2697 static BOOL
net_io_sam_policy_info(const char *desc
, SAM_DELTA_POLICY
*info
,
2698 prs_struct
*ps
, int depth
)
2701 prs_debug(ps
, depth
, desc
, "net_io_sam_policy_info");
2707 if (!prs_uint32("max_log_size", ps
, depth
, &info
->max_log_size
))
2709 if (!prs_uint64("audit_retention_period", ps
, depth
,
2710 &info
->audit_retention_period
))
2712 if (!prs_uint32("auditing_mode", ps
, depth
, &info
->auditing_mode
))
2714 if (!prs_uint32("num_events", ps
, depth
, &info
->num_events
))
2716 if (!prs_uint32("ptr_events", ps
, depth
, &info
->ptr_events
))
2719 if (!smb_io_unihdr("hdr_dom_name", &info
->hdr_dom_name
, ps
, depth
))
2722 if (!prs_uint32("sid_ptr", ps
, depth
, &info
->sid_ptr
))
2725 if (!prs_uint32("paged_pool_limit", ps
, depth
, &info
->paged_pool_limit
))
2727 if (!prs_uint32("non_paged_pool_limit", ps
, depth
,
2728 &info
->non_paged_pool_limit
))
2730 if (!prs_uint32("min_workset_size", ps
, depth
, &info
->min_workset_size
))
2732 if (!prs_uint32("max_workset_size", ps
, depth
, &info
->max_workset_size
))
2734 if (!prs_uint32("page_file_limit", ps
, depth
, &info
->page_file_limit
))
2736 if (!prs_uint64("time_limit", ps
, depth
, &info
->time_limit
))
2738 if (!smb_io_time("modify_time", &info
->modify_time
, ps
, depth
))
2740 if (!smb_io_time("create_time", &info
->create_time
, ps
, depth
))
2742 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
2745 for (i
=0; i
<4; i
++) {
2747 if (!smb_io_unihdr("dummy", &dummy
, ps
, depth
))
2751 for (i
=0; i
<4; i
++) {
2753 if (!prs_uint32("reserved", ps
, depth
, &reserved
))
2757 if (!prs_uint32("num_event_audit_options", ps
, depth
,
2758 &info
->num_event_audit_options
))
2761 for (i
=0; i
<info
->num_event_audit_options
; i
++)
2762 if (!prs_uint32("event_audit_option", ps
, depth
,
2763 &info
->event_audit_option
))
2766 if (!smb_io_unistr2("domain_name", &info
->domain_name
, True
, ps
, depth
))
2769 if(!smb_io_dom_sid2("domain_sid", &info
->domain_sid
, ps
, depth
))
2772 if (!smb_io_rpc_blob("buf_sec_desc", &info
->buf_sec_desc
, ps
, depth
))
2781 /* This function is pretty broken - see bug #334 */
2783 /*******************************************************************
2784 reads or writes a structure.
2785 ********************************************************************/
2786 static BOOL
net_io_sam_trustdoms_info(const char *desc
, SAM_DELTA_TRUSTDOMS
*info
,
2787 prs_struct
*ps
, int depth
)
2791 prs_debug(ps
, depth
, desc
, "net_io_sam_trustdoms_info");
2797 if(!prs_uint32("buf_size", ps
, depth
, &info
->buf_size
))
2800 if(!sec_io_desc("sec_desc", &info
->sec_desc
, ps
, depth
))
2803 if(!smb_io_dom_sid2("sid", &info
->sid
, ps
, depth
))
2806 if(!smb_io_unihdr("hdr_domain", &info
->hdr_domain
, ps
, depth
))
2809 if(!prs_uint32("unknown0", ps
, depth
, &info
->unknown0
))
2811 if(!prs_uint32("unknown1", ps
, depth
, &info
->unknown1
))
2813 if(!prs_uint32("unknown2", ps
, depth
, &info
->unknown2
))
2816 if(!prs_uint32("buf_size2", ps
, depth
, &info
->buf_size2
))
2818 if(!prs_uint32("ptr", ps
, depth
, &info
->ptr
))
2821 for (i
=0; i
<12; i
++)
2822 if(!prs_uint32("unknown3", ps
, depth
, &info
->unknown3
))
2825 if (!smb_io_unistr2("domain", &info
->domain
, True
, ps
, depth
))
2835 /* This function doesn't work - see bug #334 */
2837 /*******************************************************************
2838 reads or writes a structure.
2839 ********************************************************************/
2840 static BOOL
net_io_sam_secret_info(const char *desc
, SAM_DELTA_SECRET
*info
,
2841 prs_struct
*ps
, int depth
)
2845 prs_debug(ps
, depth
, desc
, "net_io_sam_secret_info");
2851 if(!prs_uint32("buf_size", ps
, depth
, &info
->buf_size
))
2854 if(!sec_io_desc("sec_desc", &info
->sec_desc
, ps
, depth
))
2857 if (!smb_io_unistr2("secret", &info
->secret
, True
, ps
, depth
))
2863 if(!prs_uint32("count1", ps
, depth
, &info
->count1
))
2865 if(!prs_uint32("count2", ps
, depth
, &info
->count2
))
2867 if(!prs_uint32("ptr", ps
, depth
, &info
->ptr
))
2871 if(!smb_io_time("time1", &info
->time1
, ps
, depth
)) /* logon time */
2873 if(!prs_uint32("count3", ps
, depth
, &info
->count3
))
2875 if(!prs_uint32("count4", ps
, depth
, &info
->count4
))
2877 if(!prs_uint32("ptr2", ps
, depth
, &info
->ptr2
))
2879 if(!smb_io_time("time2", &info
->time2
, ps
, depth
)) /* logon time */
2881 if(!prs_uint32("unknow1", ps
, depth
, &info
->unknow1
))
2885 if(!prs_uint32("buf_size2", ps
, depth
, &info
->buf_size2
))
2887 if(!prs_uint32("ptr3", ps
, depth
, &info
->ptr3
))
2890 if(!prs_uint32("unknow2", ps
, depth
, &info
->unknow2
))
2893 if(!prs_uint32("chal_len", ps
, depth
, &info
->chal_len
))
2895 if(!prs_uint32("reserved1", ps
, depth
, &info
->reserved1
))
2897 if(!prs_uint32("chal_len2", ps
, depth
, &info
->chal_len2
))
2900 if(!prs_uint8s (False
, "chal", ps
, depth
, info
->chal
, info
->chal_len2
))
2903 if(!prs_uint32("key_len", ps
, depth
, &info
->key_len
))
2905 if(!prs_uint32("reserved2", ps
, depth
, &info
->reserved2
))
2907 if(!prs_uint32("key_len2", ps
, depth
, &info
->key_len2
))
2910 if(!prs_uint8s (False
, "key", ps
, depth
, info
->key
, info
->key_len2
))
2914 if(!prs_uint32("buf_size3", ps
, depth
, &info
->buf_size3
))
2917 if(!sec_io_desc("sec_desc2", &info
->sec_desc2
, ps
, depth
))
2926 /*******************************************************************
2927 reads or writes a structure.
2928 ********************************************************************/
2929 static BOOL
net_io_sam_privs_info(const char *desc
, SAM_DELTA_PRIVS
*info
,
2930 prs_struct
*ps
, int depth
)
2934 prs_debug(ps
, depth
, desc
, "net_io_sam_privs_info");
2940 if(!smb_io_dom_sid2("sid", &info
->sid
, ps
, depth
))
2943 if(!prs_uint32("priv_count", ps
, depth
, &info
->priv_count
))
2945 if(!prs_uint32("priv_control", ps
, depth
, &info
->priv_control
))
2948 if(!prs_uint32("priv_attr_ptr", ps
, depth
, &info
->priv_attr_ptr
))
2950 if(!prs_uint32("priv_name_ptr", ps
, depth
, &info
->priv_name_ptr
))
2953 if (!prs_uint32("paged_pool_limit", ps
, depth
, &info
->paged_pool_limit
))
2955 if (!prs_uint32("non_paged_pool_limit", ps
, depth
,
2956 &info
->non_paged_pool_limit
))
2958 if (!prs_uint32("min_workset_size", ps
, depth
, &info
->min_workset_size
))
2960 if (!prs_uint32("max_workset_size", ps
, depth
, &info
->max_workset_size
))
2962 if (!prs_uint32("page_file_limit", ps
, depth
, &info
->page_file_limit
))
2964 if (!prs_uint64("time_limit", ps
, depth
, &info
->time_limit
))
2966 if (!prs_uint32("system_flags", ps
, depth
, &info
->system_flags
))
2968 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
2971 for (i
=0; i
<4; i
++) {
2973 if (!smb_io_unihdr("dummy", &dummy
, ps
, depth
))
2977 for (i
=0; i
<4; i
++) {
2979 if (!prs_uint32("reserved", ps
, depth
, &reserved
))
2983 if(!prs_uint32("attribute_count", ps
, depth
, &info
->attribute_count
))
2986 info
->attributes
= TALLOC_ARRAY(ps
->mem_ctx
, uint32
, info
->attribute_count
);
2988 for (i
=0; i
<info
->attribute_count
; i
++)
2989 if(!prs_uint32("attributes", ps
, depth
, &info
->attributes
[i
]))
2992 if(!prs_uint32("privlist_count", ps
, depth
, &info
->privlist_count
))
2995 info
->hdr_privslist
= TALLOC_ARRAY(ps
->mem_ctx
, UNIHDR
, info
->privlist_count
);
2996 info
->uni_privslist
= TALLOC_ARRAY(ps
->mem_ctx
, UNISTR2
, info
->privlist_count
);
2998 for (i
=0; i
<info
->privlist_count
; i
++)
2999 if(!smb_io_unihdr("hdr_privslist", &info
->hdr_privslist
[i
], ps
, depth
))
3002 for (i
=0; i
<info
->privlist_count
; i
++)
3003 if (!smb_io_unistr2("uni_privslist", &info
->uni_privslist
[i
], True
, ps
, depth
))
3006 if (!smb_io_rpc_blob("buf_sec_desc", &info
->buf_sec_desc
, ps
, depth
))
3012 /*******************************************************************
3013 reads or writes a structure.
3014 ********************************************************************/
3015 static BOOL
net_io_sam_delta_ctr(const char *desc
,
3016 SAM_DELTA_CTR
* delta
, uint16 type
,
3017 prs_struct
*ps
, int depth
)
3019 prs_debug(ps
, depth
, desc
, "net_io_sam_delta_ctr");
3023 /* Seen in sam deltas */
3024 case SAM_DELTA_MODIFIED_COUNT
:
3025 if (!net_io_sam_delta_mod_count("", &delta
->mod_count
, ps
, depth
))
3029 case SAM_DELTA_DOMAIN_INFO
:
3030 if (!net_io_sam_domain_info("", &delta
->domain_info
, ps
, depth
))
3034 case SAM_DELTA_GROUP_INFO
:
3035 if (!net_io_sam_group_info("", &delta
->group_info
, ps
, depth
))
3039 case SAM_DELTA_ACCOUNT_INFO
:
3040 if (!net_io_sam_account_info("", &delta
->account_info
, ps
, depth
))
3044 case SAM_DELTA_GROUP_MEM
:
3045 if (!net_io_sam_group_mem_info("", &delta
->grp_mem_info
, ps
, depth
))
3049 case SAM_DELTA_ALIAS_INFO
:
3050 if (!net_io_sam_alias_info("", &delta
->alias_info
, ps
, depth
))
3054 case SAM_DELTA_POLICY_INFO
:
3055 if (!net_io_sam_policy_info("", &delta
->policy_info
, ps
, depth
))
3059 case SAM_DELTA_ALIAS_MEM
:
3060 if (!net_io_sam_alias_mem_info("", &delta
->als_mem_info
, ps
, depth
))
3064 case SAM_DELTA_PRIVS_INFO
:
3065 if (!net_io_sam_privs_info("", &delta
->privs_info
, ps
, depth
))
3069 /* These guys are implemented but broken */
3071 case SAM_DELTA_TRUST_DOMS
:
3072 case SAM_DELTA_SECRET_INFO
:
3075 /* These guys are not implemented yet */
3077 case SAM_DELTA_RENAME_GROUP
:
3078 case SAM_DELTA_RENAME_USER
:
3079 case SAM_DELTA_RENAME_ALIAS
:
3080 case SAM_DELTA_DELETE_GROUP
:
3081 case SAM_DELTA_DELETE_USER
:
3083 DEBUG(0, ("Replication error: Unknown delta type 0x%x\n", type
));
3090 /*******************************************************************
3091 reads or writes a structure.
3092 ********************************************************************/
3093 BOOL
net_io_r_sam_sync(const char *desc
,
3094 NET_R_SAM_SYNC
* r_s
, prs_struct
*ps
, int depth
)
3098 prs_debug(ps
, depth
, desc
, "net_io_r_sam_sync");
3101 if (!smb_io_cred("srv_creds", &r_s
->srv_creds
, ps
, depth
))
3103 if (!prs_uint32("sync_context", ps
, depth
, &r_s
->sync_context
))
3106 if (!prs_uint32("ptr_deltas", ps
, depth
, &r_s
->ptr_deltas
))
3108 if (r_s
->ptr_deltas
!= 0)
3110 if (!prs_uint32("num_deltas ", ps
, depth
, &r_s
->num_deltas
))
3112 if (!prs_uint32("ptr_deltas2", ps
, depth
, &r_s
->ptr_deltas2
))
3114 if (r_s
->ptr_deltas2
!= 0)
3116 if (!prs_uint32("num_deltas2", ps
, depth
,
3120 if (r_s
->num_deltas2
!= r_s
->num_deltas
)
3126 if (r_s
->num_deltas2
> 0) {
3127 r_s
->hdr_deltas
= TALLOC_ARRAY(ps
->mem_ctx
, SAM_DELTA_HDR
, r_s
->num_deltas2
);
3128 if (r_s
->hdr_deltas
== NULL
) {
3129 DEBUG(0, ("error tallocating memory "
3130 "for %d delta headers\n",
3136 for (i
= 0; i
< r_s
->num_deltas2
; i
++)
3138 if (!net_io_sam_delta_hdr("",
3139 &r_s
->hdr_deltas
[i
],
3144 if (r_s
->num_deltas2
> 0) {
3145 r_s
->deltas
= TALLOC_ARRAY(ps
->mem_ctx
, SAM_DELTA_CTR
, r_s
->num_deltas2
);
3146 if (r_s
->deltas
== NULL
) {
3147 DEBUG(0, ("error tallocating memory "
3154 for (i
= 0; i
< r_s
->num_deltas2
; i
++)
3156 if (!net_io_sam_delta_ctr(
3157 "", &r_s
->deltas
[i
],
3158 r_s
->hdr_deltas
[i
].type3
,
3160 DEBUG(0, ("hmm, failed on i=%d\n", i
));
3168 if (!prs_ntstatus("status", ps
, depth
, &(r_s
->status
)))
3174 /*******************************************************************
3175 makes a NET_Q_SAM_DELTAS structure.
3176 ********************************************************************/
3177 BOOL
init_net_q_sam_deltas(NET_Q_SAM_DELTAS
*q_s
, const char *srv_name
,
3178 const char *cli_name
, DOM_CRED
*cli_creds
,
3179 uint32 database_id
, UINT64_S dom_mod_count
)
3181 DEBUG(5, ("init_net_q_sam_deltas\n"));
3183 init_unistr2(&q_s
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
3184 init_unistr2(&q_s
->uni_cli_name
, cli_name
, UNI_STR_TERMINATE
);
3186 memcpy(&q_s
->cli_creds
, cli_creds
, sizeof(q_s
->cli_creds
));
3187 memset(&q_s
->ret_creds
, 0, sizeof(q_s
->ret_creds
));
3189 q_s
->database_id
= database_id
;
3190 q_s
->dom_mod_count
.low
= dom_mod_count
.low
;
3191 q_s
->dom_mod_count
.high
= dom_mod_count
.high
;
3192 q_s
->max_size
= 0xffff;
3197 /*******************************************************************
3198 reads or writes a structure.
3199 ********************************************************************/
3200 BOOL
net_io_q_sam_deltas(const char *desc
, NET_Q_SAM_DELTAS
*q_s
, prs_struct
*ps
,
3203 prs_debug(ps
, depth
, desc
, "net_io_q_sam_deltas");
3206 if (!smb_io_unistr2("", &q_s
->uni_srv_name
, True
, ps
, depth
))
3208 if (!smb_io_unistr2("", &q_s
->uni_cli_name
, True
, ps
, depth
))
3211 if (!smb_io_cred("", &q_s
->cli_creds
, ps
, depth
))
3213 if (!smb_io_cred("", &q_s
->ret_creds
, ps
, depth
))
3216 if (!prs_uint32("database_id ", ps
, depth
, &q_s
->database_id
))
3218 if (!prs_uint64("dom_mod_count", ps
, depth
, &q_s
->dom_mod_count
))
3220 if (!prs_uint32("max_size", ps
, depth
, &q_s
->max_size
))
3226 /*******************************************************************
3227 reads or writes a structure.
3228 ********************************************************************/
3229 BOOL
net_io_r_sam_deltas(const char *desc
,
3230 NET_R_SAM_DELTAS
*r_s
, prs_struct
*ps
, int depth
)
3234 prs_debug(ps
, depth
, desc
, "net_io_r_sam_deltas");
3237 if (!smb_io_cred("srv_creds", &r_s
->srv_creds
, ps
, depth
))
3239 if (!prs_uint64("dom_mod_count", ps
, depth
, &r_s
->dom_mod_count
))
3242 if (!prs_uint32("ptr_deltas", ps
, depth
, &r_s
->ptr_deltas
))
3244 if (!prs_uint32("num_deltas", ps
, depth
, &r_s
->num_deltas
))
3246 if (!prs_uint32("ptr_deltas2", ps
, depth
, &r_s
->num_deltas2
))
3249 if (r_s
->num_deltas2
!= 0)
3251 if (!prs_uint32("num_deltas2 ", ps
, depth
, &r_s
->num_deltas2
))
3254 if (r_s
->ptr_deltas
!= 0)
3256 if (r_s
->num_deltas
> 0) {
3257 r_s
->hdr_deltas
= TALLOC_ARRAY(ps
->mem_ctx
, SAM_DELTA_HDR
, r_s
->num_deltas
);
3258 if (r_s
->hdr_deltas
== NULL
) {
3259 DEBUG(0, ("error tallocating memory "
3260 "for %d delta headers\n",
3266 for (i
= 0; i
< r_s
->num_deltas
; i
++)
3268 net_io_sam_delta_hdr("", &r_s
->hdr_deltas
[i
],
3272 if (r_s
->num_deltas
> 0) {
3273 r_s
->deltas
= TALLOC_ARRAY(ps
->mem_ctx
, SAM_DELTA_CTR
, r_s
->num_deltas
);
3274 if (r_s
->deltas
== NULL
) {
3275 DEBUG(0, ("error tallocating memory "
3282 for (i
= 0; i
< r_s
->num_deltas
; i
++)
3284 if (!net_io_sam_delta_ctr(
3287 r_s
->hdr_deltas
[i
].type2
,
3296 if (!prs_ntstatus("status", ps
, depth
, &r_s
->status
))
3302 /*******************************************************************
3303 Inits a NET_Q_DSR_GETDCNAME structure.
3304 ********************************************************************/
3306 void init_net_q_dsr_getdcname(NET_Q_DSR_GETDCNAME
*r_t
, const char *server_unc
,
3307 const char *domain_name
,
3308 struct uuid
*domain_guid
,
3309 struct uuid
*site_guid
,
3312 DEBUG(5, ("init_net_q_dsr_getdcname\n"));
3314 r_t
->ptr_server_unc
= (server_unc
!= NULL
);
3315 init_unistr2(&r_t
->uni_server_unc
, server_unc
, UNI_STR_TERMINATE
);
3317 r_t
->ptr_domain_name
= (domain_name
!= NULL
);
3318 init_unistr2(&r_t
->uni_domain_name
, domain_name
, UNI_STR_TERMINATE
);
3320 r_t
->ptr_domain_guid
= (domain_guid
!= NULL
);
3321 r_t
->domain_guid
= domain_guid
;
3323 r_t
->ptr_site_guid
= (site_guid
!= NULL
);
3324 r_t
->site_guid
= site_guid
;
3329 /*******************************************************************
3330 Reads or writes an NET_Q_DSR_GETDCNAME structure.
3331 ********************************************************************/
3333 BOOL
net_io_q_dsr_getdcname(const char *desc
, NET_Q_DSR_GETDCNAME
*r_t
,
3334 prs_struct
*ps
, int depth
)
3339 prs_debug(ps
, depth
, desc
, "net_io_q_dsr_getdcname");
3342 if (!prs_uint32("ptr_server_unc", ps
, depth
, &r_t
->ptr_server_unc
))
3345 if (!smb_io_unistr2("server_unc", &r_t
->uni_server_unc
,
3346 r_t
->ptr_server_unc
, ps
, depth
))
3352 if (!prs_uint32("ptr_domain_name", ps
, depth
, &r_t
->ptr_domain_name
))
3355 if (!smb_io_unistr2("domain_name", &r_t
->uni_domain_name
,
3356 r_t
->ptr_domain_name
, ps
, depth
))
3362 if (!prs_uint32("ptr_domain_guid", ps
, depth
, &r_t
->ptr_domain_guid
))
3365 if (UNMARSHALLING(ps
) && (r_t
->ptr_domain_guid
)) {
3366 r_t
->domain_guid
= PRS_ALLOC_MEM(ps
, struct uuid
, 1);
3367 if (r_t
->domain_guid
== NULL
)
3371 if ((r_t
->ptr_domain_guid
) &&
3372 (!smb_io_uuid("domain_guid", r_t
->domain_guid
, ps
, depth
)))
3378 if (!prs_uint32("ptr_site_guid", ps
, depth
, &r_t
->ptr_site_guid
))
3381 if (UNMARSHALLING(ps
) && (r_t
->ptr_site_guid
)) {
3382 r_t
->site_guid
= PRS_ALLOC_MEM(ps
, struct uuid
, 1);
3383 if (r_t
->site_guid
== NULL
)
3387 if ((r_t
->ptr_site_guid
) &&
3388 (!smb_io_uuid("site_guid", r_t
->site_guid
, ps
, depth
)))
3394 if (!prs_uint32("flags", ps
, depth
, &r_t
->flags
))
3400 /*******************************************************************
3401 Inits a NET_R_DSR_GETDCNAME structure.
3402 ********************************************************************/
3403 void init_net_r_dsr_getdcname(NET_R_DSR_GETDCNAME
*r_t
, const char *dc_unc
,
3404 const char *dc_address
, int32 dc_address_type
,
3405 struct uuid domain_guid
, const char *domain_name
,
3406 const char *forest_name
, uint32 dc_flags
,
3407 const char *dc_site_name
,
3408 const char *client_site_name
)
3410 DEBUG(5, ("init_net_q_dsr_getdcname\n"));
3412 r_t
->ptr_dc_unc
= (dc_unc
!= NULL
);
3413 init_unistr2(&r_t
->uni_dc_unc
, dc_unc
, UNI_STR_TERMINATE
);
3415 r_t
->ptr_dc_address
= (dc_address
!= NULL
);
3416 init_unistr2(&r_t
->uni_dc_address
, dc_address
, UNI_STR_TERMINATE
);
3418 r_t
->dc_address_type
= dc_address_type
;
3419 r_t
->domain_guid
= domain_guid
;
3421 r_t
->ptr_domain_name
= (domain_name
!= NULL
);
3422 init_unistr2(&r_t
->uni_domain_name
, domain_name
, UNI_STR_TERMINATE
);
3424 r_t
->ptr_forest_name
= (forest_name
!= NULL
);
3425 init_unistr2(&r_t
->uni_forest_name
, forest_name
, UNI_STR_TERMINATE
);
3427 r_t
->dc_flags
= dc_flags
;
3429 r_t
->ptr_dc_site_name
= (dc_site_name
!= NULL
);
3430 init_unistr2(&r_t
->uni_dc_site_name
, dc_site_name
, UNI_STR_TERMINATE
);
3432 r_t
->ptr_client_site_name
= (client_site_name
!= NULL
);
3433 init_unistr2(&r_t
->uni_client_site_name
, client_site_name
,
3437 /*******************************************************************
3438 Reads or writes an NET_R_DSR_GETDCNAME structure.
3439 ********************************************************************/
3441 BOOL
net_io_r_dsr_getdcname(const char *desc
, NET_R_DSR_GETDCNAME
*r_t
,
3442 prs_struct
*ps
, int depth
)
3444 uint32 info_ptr
= 1;
3449 prs_debug(ps
, depth
, desc
, "net_io_r_dsr_getdcname");
3452 /* The reply contains *just* an info struct, this is the ptr to it */
3453 if (!prs_uint32("info_ptr", ps
, depth
, &info_ptr
))
3459 if (!prs_uint32("ptr_dc_unc", ps
, depth
, &r_t
->ptr_dc_unc
))
3462 if (!prs_uint32("ptr_dc_address", ps
, depth
, &r_t
->ptr_dc_address
))
3465 if (!prs_int32("dc_address_type", ps
, depth
, &r_t
->dc_address_type
))
3468 if (!smb_io_uuid("domain_guid", &r_t
->domain_guid
, ps
, depth
))
3471 if (!prs_uint32("ptr_domain_name", ps
, depth
, &r_t
->ptr_domain_name
))
3474 if (!prs_uint32("ptr_forest_name", ps
, depth
, &r_t
->ptr_forest_name
))
3477 if (!prs_uint32("dc_flags", ps
, depth
, &r_t
->dc_flags
))
3480 if (!prs_uint32("ptr_dc_site_name", ps
, depth
, &r_t
->ptr_dc_site_name
))
3483 if (!prs_uint32("ptr_client_site_name", ps
, depth
,
3484 &r_t
->ptr_client_site_name
))
3490 if (!smb_io_unistr2("dc_unc", &r_t
->uni_dc_unc
,
3491 r_t
->ptr_dc_unc
, ps
, depth
))
3497 if (!smb_io_unistr2("dc_address", &r_t
->uni_dc_address
,
3498 r_t
->ptr_dc_address
, ps
, depth
))
3504 if (!smb_io_unistr2("domain_name", &r_t
->uni_domain_name
,
3505 r_t
->ptr_domain_name
, ps
, depth
))
3511 if (!smb_io_unistr2("forest_name", &r_t
->uni_forest_name
,
3512 r_t
->ptr_forest_name
, ps
, depth
))
3518 if (!smb_io_unistr2("dc_site_name", &r_t
->uni_dc_site_name
,
3519 r_t
->ptr_dc_site_name
, ps
, depth
))
3525 if (!smb_io_unistr2("client_site_name", &r_t
->uni_client_site_name
,
3526 r_t
->ptr_client_site_name
, ps
, depth
))
3532 if (!prs_werror("result", ps
, depth
, &r_t
->result
))
3538 /*******************************************************************
3539 Inits a NET_Q_DSR_GETSITENAME structure.
3540 ********************************************************************/
3542 void init_net_q_dsr_getsitename(NET_Q_DSR_GETSITENAME
*r_t
, const char *computer_name
)
3544 DEBUG(5, ("init_net_q_dsr_getsitename\n"));
3546 r_t
->ptr_computer_name
= (computer_name
!= NULL
);
3547 init_unistr2(&r_t
->uni_computer_name
, computer_name
, UNI_STR_TERMINATE
);
3550 /*******************************************************************
3551 Reads or writes an NET_Q_DSR_GETSITENAME structure.
3552 ********************************************************************/
3554 BOOL
net_io_q_dsr_getsitename(const char *desc
, NET_Q_DSR_GETSITENAME
*r_t
,
3555 prs_struct
*ps
, int depth
)
3560 prs_debug(ps
, depth
, desc
, "net_io_q_dsr_getsitename");
3563 if (!prs_uint32("ptr_computer_name", ps
, depth
, &r_t
->ptr_computer_name
))
3566 if (!smb_io_unistr2("computer_name", &r_t
->uni_computer_name
,
3567 r_t
->ptr_computer_name
, ps
, depth
))
3576 /*******************************************************************
3577 Reads or writes an NET_R_DSR_GETSITENAME structure.
3578 ********************************************************************/
3580 BOOL
net_io_r_dsr_getsitename(const char *desc
, NET_R_DSR_GETSITENAME
*r_t
,
3581 prs_struct
*ps
, int depth
)
3586 prs_debug(ps
, depth
, desc
, "net_io_r_dsr_getsitename");
3589 if (!prs_uint32("ptr_site_name", ps
, depth
, &r_t
->ptr_site_name
))
3595 if (!smb_io_unistr2("site_name", &r_t
->uni_site_name
,
3596 r_t
->ptr_site_name
, ps
, depth
))
3602 if (!prs_werror("result", ps
, depth
, &r_t
->result
))