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 Francois 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_q_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_werror("status", ps, depth, &r_t->status))
570 /*******************************************************************
571 Inits an NET_R_GETANYDCNAME structure.
572 ********************************************************************/
573 void init_net_q_getanydcname(NET_Q_GETANYDCNAME *r_t, const char *logon_server,
574 const char *domainname)
576 DEBUG(5,("init_q_getanydcname\n"));
578 init_unistr2(&r_t->uni_logon_server, logon_server, UNI_STR_TERMINATE);
579 r_t->ptr_domainname = (domainname != NULL);
580 init_unistr2(&r_t->uni_domainname, domainname, UNI_STR_TERMINATE);
583 /*******************************************************************
584 Reads or writes an NET_Q_GETANYDCNAME structure.
585 ********************************************************************/
587 BOOL net_io_q_getanydcname(const char *desc, NET_Q_GETANYDCNAME *r_t, prs_struct *ps,
593 prs_debug(ps, depth, desc, "net_io_q_getanydcname");
596 if (!smb_io_unistr2("logon_server", &r_t->uni_logon_server,
603 if (!prs_uint32("ptr_domainname", ps, depth, &r_t->ptr_domainname))
606 if (!smb_io_unistr2("domainname", &r_t->uni_domainname,
607 r_t->ptr_domainname, ps, depth))
614 /*******************************************************************
615 Inits an NET_R_GETANYDCNAME structure.
616 ********************************************************************/
617 void init_net_r_getanydcname(NET_R_GETANYDCNAME *r_t, const char *dcname)
619 DEBUG(5,("init_r_getanydcname\n"));
621 init_unistr2(&r_t->uni_dcname, dcname, UNI_STR_TERMINATE);
624 /*******************************************************************
625 Reads or writes an NET_R_GETANYDCNAME structure.
626 ********************************************************************/
628 BOOL net_io_r_getanydcname(const char *desc, NET_R_GETANYDCNAME *r_t, prs_struct *ps,
634 prs_debug(ps, depth, desc, "net_io_r_getanydcname");
637 if (!prs_uint32("ptr_dcname", ps, depth, &r_t->ptr_dcname))
640 if (!smb_io_unistr2("dcname", &r_t->uni_dcname,
641 r_t->ptr_dcname, ps, depth))
647 if (!prs_werror("status", ps, depth, &r_t->status))
653 /*******************************************************************
654 Inits an NET_R_TRUST_DOM_LIST structure.
655 ********************************************************************/
657 void init_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t,
658 uint32 num_doms, const char *dom_name)
662 DEBUG(5,("init_r_trust_dom\n"));
664 for (i = 0; i < MAX_TRUST_DOMS; i++) {
665 r_t->uni_trust_dom_name[i].uni_str_len = 0;
666 r_t->uni_trust_dom_name[i].uni_max_len = 0;
668 if (num_doms > MAX_TRUST_DOMS)
669 num_doms = MAX_TRUST_DOMS;
671 for (i = 0; i < num_doms; i++) {
673 fstrcpy(domain_name, dom_name);
674 strupper_m(domain_name);
675 init_unistr2(&r_t->uni_trust_dom_name[i], domain_name, UNI_STR_TERMINATE);
676 /* the use of UNISTR2 here is non-standard. */
677 r_t->uni_trust_dom_name[i].offset = 0x1;
680 r_t->status = NT_STATUS_OK;
683 /*******************************************************************
684 Reads or writes an NET_R_TRUST_DOM_LIST structure.
685 ********************************************************************/
687 BOOL net_io_r_trust_dom(const char *desc, NET_R_TRUST_DOM_LIST *r_t, prs_struct *ps, int depth)
694 prs_debug(ps, depth, desc, "net_io_r_trust_dom");
697 /* temporary code to give a valid response */
699 if(!prs_uint32("status", ps, depth, &value))
703 if(!prs_uint32("status", ps, depth, &value))
706 if(!prs_uint32("status", ps, depth, &value))
710 if(!prs_uint32("status", ps, depth, &value))
714 if(!prs_uint32("status", ps, depth, &value))
717 /* old non working code */
721 for (i = 0; i < MAX_TRUST_DOMS; i++) {
722 if (r_t->uni_trust_dom_name[i].uni_str_len == 0)
724 if(!smb_io_unistr2("", &r_t->uni_trust_dom_name[i], True, ps, depth))
728 if(!prs_ntstatus("status", ps, depth, &r_t->status))
735 /*******************************************************************
736 Reads or writes an NET_Q_TRUST_DOM_LIST structure.
737 ********************************************************************/
739 BOOL net_io_q_trust_dom(const char *desc, NET_Q_TRUST_DOM_LIST *q_l, prs_struct *ps, int depth)
744 prs_debug(ps, depth, desc, "net_io_q_trust_dom");
747 if(!prs_uint32("ptr ", ps, depth, &q_l->ptr))
749 if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth))
755 /*******************************************************************
756 Inits an NET_Q_REQ_CHAL structure.
757 ********************************************************************/
759 void init_q_req_chal(NET_Q_REQ_CHAL *q_c,
760 const char *logon_srv, const char *logon_clnt,
761 const DOM_CHAL *clnt_chal)
763 DEBUG(5,("init_q_req_chal: %d\n", __LINE__));
765 q_c->undoc_buffer = 1; /* don't know what this buffer is */
767 init_unistr2(&q_c->uni_logon_srv, logon_srv , UNI_STR_TERMINATE);
768 init_unistr2(&q_c->uni_logon_clnt, logon_clnt, UNI_STR_TERMINATE);
770 memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
772 DEBUG(5,("init_q_req_chal: %d\n", __LINE__));
775 /*******************************************************************
776 Reads or writes an NET_Q_REQ_CHAL structure.
777 ********************************************************************/
779 BOOL net_io_q_req_chal(const char *desc, NET_Q_REQ_CHAL *q_c, prs_struct *ps, int depth)
784 prs_debug(ps, depth, desc, "net_io_q_req_chal");
790 if(!prs_uint32("undoc_buffer", ps, depth, &q_c->undoc_buffer))
793 if(!smb_io_unistr2("", &q_c->uni_logon_srv, True, ps, depth)) /* logon server unicode string */
795 if(!smb_io_unistr2("", &q_c->uni_logon_clnt, True, ps, depth)) /* logon client unicode string */
798 if(!smb_io_chal("", &q_c->clnt_chal, ps, depth))
804 /*******************************************************************
805 Reads or writes a structure.
806 ********************************************************************/
808 BOOL net_io_r_req_chal(const char *desc, NET_R_REQ_CHAL *r_c, prs_struct *ps, int depth)
813 prs_debug(ps, depth, desc, "net_io_r_req_chal");
819 if(!smb_io_chal("", &r_c->srv_chal, ps, depth)) /* server challenge */
822 if(!prs_ntstatus("status", ps, depth, &r_c->status))
829 /*******************************************************************
830 Reads or writes a structure.
831 ********************************************************************/
833 BOOL net_io_q_auth(const char *desc, NET_Q_AUTH *q_a, prs_struct *ps, int depth)
838 prs_debug(ps, depth, desc, "net_io_q_auth");
844 if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */
846 if(!smb_io_chal("", &q_a->clnt_chal, ps, depth))
852 /*******************************************************************
853 Reads or writes a structure.
854 ********************************************************************/
856 BOOL net_io_r_auth(const char *desc, NET_R_AUTH *r_a, prs_struct *ps, int depth)
861 prs_debug(ps, depth, desc, "net_io_r_auth");
867 if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */
870 if(!prs_ntstatus("status", ps, depth, &r_a->status))
876 /*******************************************************************
877 Inits a NET_Q_AUTH_2 struct.
878 ********************************************************************/
880 void init_q_auth_2(NET_Q_AUTH_2 *q_a,
881 const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name,
882 const DOM_CHAL *clnt_chal, uint32 clnt_flgs)
884 DEBUG(5,("init_q_auth_2: %d\n", __LINE__));
886 init_log_info(&q_a->clnt_id, logon_srv, acct_name, sec_chan, comp_name);
887 memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
888 q_a->clnt_flgs.neg_flags = clnt_flgs;
890 DEBUG(5,("init_q_auth_2: %d\n", __LINE__));
893 /*******************************************************************
894 Reads or writes a structure.
895 ********************************************************************/
897 BOOL net_io_q_auth_2(const char *desc, NET_Q_AUTH_2 *q_a, prs_struct *ps, int depth)
902 prs_debug(ps, depth, desc, "net_io_q_auth_2");
908 if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */
910 if(!smb_io_chal("", &q_a->clnt_chal, ps, depth))
912 if(!net_io_neg_flags("", &q_a->clnt_flgs, ps, depth))
918 /*******************************************************************
919 Reads or writes a structure.
920 ********************************************************************/
922 BOOL net_io_r_auth_2(const char *desc, NET_R_AUTH_2 *r_a, prs_struct *ps, int depth)
927 prs_debug(ps, depth, desc, "net_io_r_auth_2");
933 if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */
935 if(!net_io_neg_flags("", &r_a->srv_flgs, ps, depth))
938 if(!prs_ntstatus("status", ps, depth, &r_a->status))
944 /*******************************************************************
945 Inits a NET_Q_AUTH_3 struct.
946 ********************************************************************/
948 void init_q_auth_3(NET_Q_AUTH_3 *q_a,
949 const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name,
950 const DOM_CHAL *clnt_chal, uint32 clnt_flgs)
952 DEBUG(5,("init_q_auth_3: %d\n", __LINE__));
954 init_log_info(&q_a->clnt_id, logon_srv, acct_name, sec_chan, comp_name);
955 memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
956 q_a->clnt_flgs.neg_flags = clnt_flgs;
958 DEBUG(5,("init_q_auth_3: %d\n", __LINE__));
961 /*******************************************************************
962 Reads or writes a structure.
963 ********************************************************************/
965 BOOL net_io_q_auth_3(const char *desc, NET_Q_AUTH_3 *q_a, prs_struct *ps, int depth)
970 prs_debug(ps, depth, desc, "net_io_q_auth_3");
976 if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */
978 if(!smb_io_chal("", &q_a->clnt_chal, ps, depth))
980 if(!net_io_neg_flags("", &q_a->clnt_flgs, ps, depth))
986 /*******************************************************************
987 Reads or writes a structure.
988 ********************************************************************/
990 BOOL net_io_r_auth_3(const char *desc, NET_R_AUTH_3 *r_a, prs_struct *ps, int depth)
995 prs_debug(ps, depth, desc, "net_io_r_auth_3");
1001 if(!smb_io_chal("srv_chal", &r_a->srv_chal, ps, depth)) /* server challenge */
1003 if(!net_io_neg_flags("srv_flgs", &r_a->srv_flgs, ps, depth))
1005 if (!prs_uint32("unknown", ps, depth, &r_a->unknown))
1008 if(!prs_ntstatus("status", ps, depth, &r_a->status))
1015 /*******************************************************************
1016 Inits a NET_Q_SRV_PWSET.
1017 ********************************************************************/
1019 void init_q_srv_pwset(NET_Q_SRV_PWSET *q_s,
1020 const char *logon_srv, const char *sess_key, const char *acct_name,
1021 uint16 sec_chan, const char *comp_name,
1022 DOM_CRED *cred, const uchar hashed_mach_pwd[16])
1024 unsigned char nt_cypher[16];
1026 DEBUG(5,("init_q_srv_pwset\n"));
1028 /* Process the new password. */
1029 cred_hash3( nt_cypher, hashed_mach_pwd, (const unsigned char *)sess_key, 1);
1031 init_clnt_info(&q_s->clnt_id, logon_srv, acct_name, sec_chan, comp_name, cred);
1033 memcpy(q_s->pwd, nt_cypher, sizeof(q_s->pwd));
1036 /*******************************************************************
1037 Reads or writes a structure.
1038 ********************************************************************/
1040 BOOL net_io_q_srv_pwset(const char *desc, NET_Q_SRV_PWSET *q_s, prs_struct *ps, int depth)
1045 prs_debug(ps, depth, desc, "net_io_q_srv_pwset");
1051 if(!smb_io_clnt_info("", &q_s->clnt_id, ps, depth)) /* client identification/authentication info */
1053 if(!prs_uint8s (False, "pwd", ps, depth, q_s->pwd, 16)) /* new password - undocumented */
1059 /*******************************************************************
1060 Reads or writes a structure.
1061 ********************************************************************/
1063 BOOL net_io_r_srv_pwset(const char *desc, NET_R_SRV_PWSET *r_s, prs_struct *ps, int depth)
1068 prs_debug(ps, depth, desc, "net_io_r_srv_pwset");
1074 if(!smb_io_cred("", &r_s->srv_cred, ps, depth)) /* server challenge */
1077 if(!prs_ntstatus("status", ps, depth, &r_s->status))
1083 /*************************************************************************
1084 Init DOM_SID2 array from a string containing multiple sids
1085 *************************************************************************/
1087 static int init_dom_sid2s(TALLOC_CTX *ctx, const char *sids_str, DOM_SID2 **ppsids)
1093 DEBUG(4,("init_dom_sid2s: %s\n", sids_str ? sids_str:""));
1101 /* Count the number of valid SIDs. */
1102 for (count = 0, ptr = sids_str; next_token(&ptr, s2, NULL, sizeof(s2)); ) {
1104 if (string_to_sid(&tmpsid, s2))
1108 /* Now allocate space for them. */
1109 *ppsids = TALLOC_ZERO_ARRAY(ctx, DOM_SID2, count);
1110 if (*ppsids == NULL)
1115 for (number = 0, ptr = sids_str; next_token(&ptr, s2, NULL, sizeof(s2)); ) {
1117 if (string_to_sid(&tmpsid, s2)) {
1118 /* count only valid sids */
1119 init_dom_sid2(&sids[number], &tmpsid);
1128 /*******************************************************************
1129 Inits a NET_ID_INFO_1 structure.
1130 ********************************************************************/
1132 void init_id_info1(NET_ID_INFO_1 *id, const char *domain_name,
1133 uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
1134 const char *user_name, const char *wksta_name,
1135 const char *sess_key,
1136 unsigned char lm_cypher[16], unsigned char nt_cypher[16])
1138 unsigned char lm_owf[16];
1139 unsigned char nt_owf[16];
1141 DEBUG(5,("init_id_info1: %d\n", __LINE__));
1143 id->ptr_id_info1 = 1;
1145 id->param_ctrl = param_ctrl;
1146 init_logon_id(&id->logon_id, log_id_low, log_id_high);
1149 if (lm_cypher && nt_cypher) {
1150 unsigned char key[16];
1151 #ifdef DEBUG_PASSWORD
1152 DEBUG(100,("lm cypher:"));
1153 dump_data(100, lm_cypher, 16);
1155 DEBUG(100,("nt cypher:"));
1156 dump_data(100, nt_cypher, 16);
1160 memcpy(key, sess_key, 8);
1162 memcpy(lm_owf, lm_cypher, 16);
1163 SamOEMhash(lm_owf, key, 16);
1164 memcpy(nt_owf, nt_cypher, 16);
1165 SamOEMhash(nt_owf, key, 16);
1167 #ifdef DEBUG_PASSWORD
1168 DEBUG(100,("encrypt of lm owf password:"));
1169 dump_data(100, lm_owf, 16);
1171 DEBUG(100,("encrypt of nt owf password:"));
1172 dump_data(100, nt_owf, 16);
1174 /* set up pointers to cypher blocks */
1179 init_owf_info(&id->lm_owf, lm_cypher);
1180 init_owf_info(&id->nt_owf, nt_cypher);
1182 init_unistr2(&id->uni_domain_name, domain_name, UNI_FLAGS_NONE);
1183 init_uni_hdr(&id->hdr_domain_name, &id->uni_domain_name);
1184 init_unistr2(&id->uni_user_name, user_name, UNI_FLAGS_NONE);
1185 init_uni_hdr(&id->hdr_user_name, &id->uni_user_name);
1186 init_unistr2(&id->uni_wksta_name, wksta_name, UNI_FLAGS_NONE);
1187 init_uni_hdr(&id->hdr_wksta_name, &id->uni_wksta_name);
1190 /*******************************************************************
1191 Reads or writes an NET_ID_INFO_1 structure.
1192 ********************************************************************/
1194 static BOOL net_io_id_info1(const char *desc, NET_ID_INFO_1 *id, prs_struct *ps, int depth)
1199 prs_debug(ps, depth, desc, "net_io_id_info1");
1205 if(!prs_uint32("ptr_id_info1", ps, depth, &id->ptr_id_info1))
1208 if (id->ptr_id_info1 != 0) {
1209 if(!smb_io_unihdr("unihdr", &id->hdr_domain_name, ps, depth))
1212 if(!prs_uint32("param_ctrl", ps, depth, &id->param_ctrl))
1214 if(!smb_io_logon_id("", &id->logon_id, ps, depth))
1217 if(!smb_io_unihdr("unihdr", &id->hdr_user_name, ps, depth))
1219 if(!smb_io_unihdr("unihdr", &id->hdr_wksta_name, ps, depth))
1222 if(!smb_io_owf_info("", &id->lm_owf, ps, depth))
1224 if(!smb_io_owf_info("", &id->nt_owf, ps, depth))
1227 if(!smb_io_unistr2("unistr2", &id->uni_domain_name,
1228 id->hdr_domain_name.buffer, ps, depth))
1230 if(!smb_io_unistr2("unistr2", &id->uni_user_name,
1231 id->hdr_user_name.buffer, ps, depth))
1233 if(!smb_io_unistr2("unistr2", &id->uni_wksta_name,
1234 id->hdr_wksta_name.buffer, ps, depth))
1241 /*******************************************************************
1242 Inits a NET_ID_INFO_2 structure.
1244 This is a network logon packet. The log_id parameters
1245 are what an NT server would generate for LUID once the
1246 user is logged on. I don't think we care about them.
1248 Note that this has no access to the NT and LM hashed passwords,
1249 so it forwards the challenge, and the NT and LM responses (24
1250 bytes each) over the secure channel to the Domain controller
1251 for it to say yea or nay. This is the preferred method of
1252 checking for a logon as it doesn't export the password
1253 hashes to anyone who has compromised the secure channel. JRA.
1254 ********************************************************************/
1256 void init_id_info2(NET_ID_INFO_2 * id, const char *domain_name,
1258 uint32 log_id_low, uint32 log_id_high,
1259 const char *user_name, const char *wksta_name,
1260 const uchar lm_challenge[8],
1261 const uchar * lm_chal_resp, size_t lm_chal_resp_len,
1262 const uchar * nt_chal_resp, size_t nt_chal_resp_len)
1265 DEBUG(5,("init_id_info2: %d\n", __LINE__));
1267 id->ptr_id_info2 = 1;
1269 id->param_ctrl = param_ctrl;
1270 init_logon_id(&id->logon_id, log_id_low, log_id_high);
1272 memcpy(id->lm_chal, lm_challenge, sizeof(id->lm_chal));
1273 init_str_hdr(&id->hdr_nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len, (nt_chal_resp != NULL) ? 1 : 0);
1274 init_str_hdr(&id->hdr_lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len, (lm_chal_resp != NULL) ? 1 : 0);
1276 init_unistr2(&id->uni_domain_name, domain_name, UNI_FLAGS_NONE);
1277 init_uni_hdr(&id->hdr_domain_name, &id->uni_domain_name);
1278 init_unistr2(&id->uni_user_name, user_name, UNI_FLAGS_NONE);
1279 init_uni_hdr(&id->hdr_user_name, &id->uni_user_name);
1280 init_unistr2(&id->uni_wksta_name, wksta_name, UNI_FLAGS_NONE);
1281 init_uni_hdr(&id->hdr_wksta_name, &id->uni_wksta_name);
1283 init_string2(&id->nt_chal_resp, (const char *)nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len);
1284 init_string2(&id->lm_chal_resp, (const char *)lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len);
1288 /*******************************************************************
1289 Reads or writes an NET_ID_INFO_2 structure.
1290 ********************************************************************/
1292 static BOOL net_io_id_info2(const char *desc, NET_ID_INFO_2 *id, prs_struct *ps, int depth)
1297 prs_debug(ps, depth, desc, "net_io_id_info2");
1303 if(!prs_uint32("ptr_id_info2", ps, depth, &id->ptr_id_info2))
1306 if (id->ptr_id_info2 != 0) {
1307 if(!smb_io_unihdr("unihdr", &id->hdr_domain_name, ps, depth))
1310 if(!prs_uint32("param_ctrl", ps, depth, &id->param_ctrl))
1312 if(!smb_io_logon_id("", &id->logon_id, ps, depth))
1315 if(!smb_io_unihdr("unihdr", &id->hdr_user_name, ps, depth))
1317 if(!smb_io_unihdr("unihdr", &id->hdr_wksta_name, ps, depth))
1320 if(!prs_uint8s (False, "lm_chal", ps, depth, id->lm_chal, 8)) /* lm 8 byte challenge */
1323 if(!smb_io_strhdr("hdr_nt_chal_resp", &id->hdr_nt_chal_resp, ps, depth))
1325 if(!smb_io_strhdr("hdr_lm_chal_resp", &id->hdr_lm_chal_resp, ps, depth))
1328 if(!smb_io_unistr2("uni_domain_name", &id->uni_domain_name,
1329 id->hdr_domain_name.buffer, ps, depth))
1331 if(!smb_io_unistr2("uni_user_name ", &id->uni_user_name,
1332 id->hdr_user_name.buffer, ps, depth))
1334 if(!smb_io_unistr2("uni_wksta_name ", &id->uni_wksta_name,
1335 id->hdr_wksta_name.buffer, ps, depth))
1337 if(!smb_io_string2("nt_chal_resp", &id->nt_chal_resp,
1338 id->hdr_nt_chal_resp.buffer, ps, depth))
1340 if(!smb_io_string2("lm_chal_resp", &id->lm_chal_resp,
1341 id->hdr_lm_chal_resp.buffer, ps, depth))
1349 /*******************************************************************
1350 Inits a DOM_SAM_INFO structure.
1351 ********************************************************************/
1353 void init_sam_info(DOM_SAM_INFO *sam,
1354 const char *logon_srv, const char *comp_name,
1355 DOM_CRED *clnt_cred,
1356 DOM_CRED *rtn_cred, uint16 logon_level,
1357 NET_ID_INFO_CTR *ctr)
1359 DEBUG(5,("init_sam_info: %d\n", __LINE__));
1361 init_clnt_info2(&sam->client, logon_srv, comp_name, clnt_cred);
1363 if (rtn_cred != NULL) {
1364 sam->ptr_rtn_cred = 1;
1365 memcpy(&sam->rtn_cred, rtn_cred, sizeof(sam->rtn_cred));
1367 sam->ptr_rtn_cred = 0;
1370 sam->logon_level = logon_level;
1374 /*******************************************************************
1375 Reads or writes a DOM_SAM_INFO structure.
1376 ********************************************************************/
1378 static BOOL net_io_id_info_ctr(const char *desc, NET_ID_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1380 NET_ID_INFO_CTR *ctr = *pp_ctr;
1382 prs_debug(ps, depth, desc, "smb_io_sam_info_ctr");
1385 if (UNMARSHALLING(ps)) {
1386 ctr = *pp_ctr = PRS_ALLOC_MEM(ps, NET_ID_INFO_CTR, 1);
1394 /* don't 4-byte align here! */
1396 if(!prs_uint16("switch_value ", ps, depth, &ctr->switch_value))
1399 switch (ctr->switch_value) {
1401 if(!net_io_id_info1("", &ctr->auth.id1, ps, depth))
1405 if(!net_io_id_info2("", &ctr->auth.id2, ps, depth))
1410 DEBUG(4,("smb_io_sam_info_ctr: unknown switch_value!\n"));
1417 /*******************************************************************
1418 Reads or writes a DOM_SAM_INFO structure.
1419 ********************************************************************/
1421 static BOOL smb_io_sam_info(const char *desc, DOM_SAM_INFO *sam, prs_struct *ps, int depth)
1426 prs_debug(ps, depth, desc, "smb_io_sam_info");
1432 if(!smb_io_clnt_info2("", &sam->client, ps, depth))
1435 if(!prs_uint32("ptr_rtn_cred ", ps, depth, &sam->ptr_rtn_cred))
1437 if (sam->ptr_rtn_cred) {
1438 if(!smb_io_cred("", &sam->rtn_cred, ps, depth))
1442 if(!prs_uint16("logon_level ", ps, depth, &sam->logon_level))
1445 if (sam->logon_level != 0) {
1446 if(!net_io_id_info_ctr("logon_info", &sam->ctr, ps, depth))
1453 /*******************************************************************
1454 Reads or writes a DOM_SAM_INFO_EX structure.
1455 ********************************************************************/
1457 static BOOL smb_io_sam_info_ex(const char *desc, DOM_SAM_INFO_EX *sam, prs_struct *ps, int depth)
1462 prs_debug(ps, depth, desc, "smb_io_sam_info_ex");
1468 if(!smb_io_clnt_srv("", &sam->client, ps, depth))
1471 if(!prs_uint16("logon_level ", ps, depth, &sam->logon_level))
1474 if (sam->logon_level != 0) {
1475 if(!net_io_id_info_ctr("logon_info", &sam->ctr, ps, depth))
1482 /*************************************************************************
1483 Inits a NET_USER_INFO_3 structure.
1485 This is a network logon reply packet, and contains much information about
1486 the user. This information is passed as a (very long) paramater list
1487 to avoid having to link in the PASSDB code to every program that deals
1489 *************************************************************************/
1491 void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr,
1495 const char* user_name,
1496 const char* full_name,
1497 const char* home_dir,
1498 const char* dir_drive,
1499 const char* logon_script,
1500 const char* profile_path,
1502 time_t unix_logon_time,
1503 time_t unix_logoff_time,
1504 time_t unix_kickoff_time,
1505 time_t unix_pass_last_set_time,
1506 time_t unix_pass_can_change_time,
1507 time_t unix_pass_must_change_time,
1509 uint16 logon_count, uint16 bad_pw_count,
1510 uint32 num_groups, const DOM_GID *gids,
1511 uint32 user_flgs, uint32 acct_flags,
1512 uchar user_session_key[16],
1513 uchar lm_session_key[16],
1514 const char *logon_srv, const char *logon_dom,
1515 const DOM_SID *dom_sid)
1517 /* only cope with one "other" sid, right now. */
1518 /* need to count the number of space-delimited sids */
1520 int num_other_sids = 0;
1522 NTTIME logon_time, logoff_time, kickoff_time,
1523 pass_last_set_time, pass_can_change_time,
1524 pass_must_change_time;
1528 usr->ptr_user_info = 1; /* yes, we're bothering to put USER_INFO data here */
1530 /* Create NTTIME structs */
1531 unix_to_nt_time (&logon_time, unix_logon_time);
1532 unix_to_nt_time (&logoff_time, unix_logoff_time);
1533 unix_to_nt_time (&kickoff_time, unix_kickoff_time);
1534 unix_to_nt_time (&pass_last_set_time, unix_pass_last_set_time);
1535 unix_to_nt_time (&pass_can_change_time, unix_pass_can_change_time);
1536 unix_to_nt_time (&pass_must_change_time, unix_pass_must_change_time);
1538 usr->logon_time = logon_time;
1539 usr->logoff_time = logoff_time;
1540 usr->kickoff_time = kickoff_time;
1541 usr->pass_last_set_time = pass_last_set_time;
1542 usr->pass_can_change_time = pass_can_change_time;
1543 usr->pass_must_change_time = pass_must_change_time;
1545 usr->logon_count = logon_count;
1546 usr->bad_pw_count = bad_pw_count;
1548 usr->user_rid = user_rid;
1549 usr->group_rid = group_rid;
1550 usr->num_groups = num_groups;
1552 usr->buffer_groups = 1; /* indicates fill in groups, below, even if there are none */
1553 usr->user_flgs = user_flgs;
1554 usr->acct_flags = acct_flags;
1556 if (user_session_key != NULL)
1557 memcpy(usr->user_sess_key, user_session_key, sizeof(usr->user_sess_key));
1559 memset((char *)usr->user_sess_key, '\0', sizeof(usr->user_sess_key));
1561 usr->buffer_dom_id = dom_sid ? 1 : 0; /* yes, we're bothering to put a domain SID in */
1563 memset((char *)usr->lm_sess_key, '\0', sizeof(usr->lm_sess_key));
1565 for (i=0; i<7; i++) {
1566 memset(&usr->unknown[i], '\0', sizeof(usr->unknown));
1569 if (lm_session_key != NULL) {
1570 memcpy(usr->lm_sess_key, lm_session_key, sizeof(usr->lm_sess_key));
1573 num_other_sids = init_dom_sid2s(ctx, NULL, &usr->other_sids);
1575 usr->num_other_sids = num_other_sids;
1576 usr->buffer_other_sids = (num_other_sids != 0) ? 1 : 0;
1578 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
1579 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
1580 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
1581 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
1582 init_unistr2(&usr->uni_logon_script, logon_script, UNI_FLAGS_NONE);
1583 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
1584 init_unistr2(&usr->uni_profile_path, profile_path, UNI_FLAGS_NONE);
1585 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
1586 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
1587 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
1588 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
1589 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
1591 usr->num_groups2 = num_groups;
1593 usr->gids = TALLOC_ZERO_ARRAY(ctx,DOM_GID,num_groups);
1594 if (usr->gids == NULL && num_groups>0)
1597 for (i = 0; i < num_groups; i++)
1598 usr->gids[i] = gids[i];
1600 init_unistr2(&usr->uni_logon_srv, logon_srv, UNI_FLAGS_NONE);
1601 init_uni_hdr(&usr->hdr_logon_srv, &usr->uni_logon_srv);
1602 init_unistr2(&usr->uni_logon_dom, logon_dom, UNI_FLAGS_NONE);
1603 init_uni_hdr(&usr->hdr_logon_dom, &usr->uni_logon_dom);
1605 init_dom_sid2(&usr->dom_sid, dom_sid);
1606 /* "other" sids are set up above */
1609 static void dump_acct_flags(uint32 acct_flags) {
1612 DEBUG(lvl,("dump_acct_flags\n"));
1613 if (acct_flags & ACB_NORMAL) {
1614 DEBUGADD(lvl,("\taccount has ACB_NORMAL\n"));
1616 if (acct_flags & ACB_PWNOEXP) {
1617 DEBUGADD(lvl,("\taccount has ACB_PWNOEXP\n"));
1619 if (acct_flags & ACB_ENC_TXT_PWD_ALLOWED) {
1620 DEBUGADD(lvl,("\taccount has ACB_ENC_TXT_PWD_ALLOWED\n"));
1622 if (acct_flags & ACB_NOT_DELEGATED) {
1623 DEBUGADD(lvl,("\taccount has ACB_NOT_DELEGATED\n"));
1625 if (acct_flags & ACB_USE_DES_KEY_ONLY) {
1626 DEBUGADD(lvl,("\taccount has ACB_USE_DES_KEY_ONLY set, sig verify wont work\n"));
1628 if (acct_flags & ACB_NO_AUTH_DATA_REQD) {
1629 DEBUGADD(lvl,("\taccount has ACB_NO_AUTH_DATA_REQD set\n"));
1631 if (acct_flags & ACB_PWEXPIRED) {
1632 DEBUGADD(lvl,("\taccount has ACB_PWEXPIRED set\n"));
1636 static void dump_user_flgs(uint32 user_flags) {
1639 DEBUG(lvl,("dump_user_flgs\n"));
1640 if (user_flags & LOGON_EXTRA_SIDS) {
1641 DEBUGADD(lvl,("\taccount has LOGON_EXTRA_SIDS\n"));
1643 if (user_flags & LOGON_RESOURCE_GROUPS) {
1644 DEBUGADD(lvl,("\taccount has LOGON_RESOURCE_GROUPS\n"));
1646 if (user_flags & LOGON_NTLMV2_ENABLED) {
1647 DEBUGADD(lvl,("\taccount has LOGON_NTLMV2_ENABLED\n"));
1649 if (user_flags & LOGON_CACHED_ACCOUNT) {
1650 DEBUGADD(lvl,("\taccount has LOGON_CACHED_ACCOUNT\n"));
1652 if (user_flags & LOGON_PROFILE_PATH_RETURNED) {
1653 DEBUGADD(lvl,("\taccount has LOGON_PROFILE_PATH_RETURNED\n"));
1655 if (user_flags & LOGON_SERVER_TRUST_ACCOUNT) {
1656 DEBUGADD(lvl,("\taccount has LOGON_SERVER_TRUST_ACCOUNT\n"));
1662 /*******************************************************************
1663 This code has been modified to cope with a NET_USER_INFO_2 - which is
1664 exactly the same as a NET_USER_INFO_3, minus the other sids parameters.
1665 We use validation level to determine if we're marshalling a info 2 or
1666 INFO_3 - be we always return an INFO_3. Based on code donated by Marc
1667 Jacobsen at HP. JRA.
1668 ********************************************************************/
1670 BOOL net_io_user_info3(const char *desc, NET_USER_INFO_3 *usr, prs_struct *ps,
1671 int depth, uint16 validation_level, BOOL kerb_validation_level)
1678 prs_debug(ps, depth, desc, "net_io_user_info3");
1681 if (UNMARSHALLING(ps))
1687 if(!prs_uint32("ptr_user_info ", ps, depth, &usr->ptr_user_info))
1690 if (usr->ptr_user_info == 0)
1693 if(!smb_io_time("logon time", &usr->logon_time, ps, depth)) /* logon time */
1695 if(!smb_io_time("logoff time", &usr->logoff_time, ps, depth)) /* logoff time */
1697 if(!smb_io_time("kickoff time", &usr->kickoff_time, ps, depth)) /* kickoff time */
1699 if(!smb_io_time("last set time", &usr->pass_last_set_time, ps, depth)) /* password last set time */
1701 if(!smb_io_time("can change time", &usr->pass_can_change_time , ps, depth)) /* password can change time */
1703 if(!smb_io_time("must change time", &usr->pass_must_change_time, ps, depth)) /* password must change time */
1706 if(!smb_io_unihdr("hdr_user_name", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
1708 if(!smb_io_unihdr("hdr_full_name", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
1710 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
1712 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
1714 if(!smb_io_unihdr("hdr_home_dir", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
1716 if(!smb_io_unihdr("hdr_dir_drive", &usr->hdr_dir_drive, ps, depth)) /* home directory drive unicode string header */
1719 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count)) /* logon count */
1721 if(!prs_uint16("bad_pw_count ", ps, depth, &usr->bad_pw_count)) /* bad password count */
1724 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User RID */
1726 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group RID */
1728 if(!prs_uint32("num_groups ", ps, depth, &usr->num_groups)) /* num groups */
1730 if(!prs_uint32("buffer_groups ", ps, depth, &usr->buffer_groups)) /* undocumented buffer pointer to groups. */
1732 if(!prs_uint32("user_flgs ", ps, depth, &usr->user_flgs)) /* user flags */
1734 dump_user_flgs(usr->user_flgs);
1735 if(!prs_uint8s(False, "user_sess_key", ps, depth, usr->user_sess_key, 16)) /* user session key */
1738 if(!smb_io_unihdr("hdr_logon_srv", &usr->hdr_logon_srv, ps, depth)) /* logon server unicode string header */
1740 if(!smb_io_unihdr("hdr_logon_dom", &usr->hdr_logon_dom, ps, depth)) /* logon domain unicode string header */
1743 if(!prs_uint32("buffer_dom_id ", ps, depth, &usr->buffer_dom_id)) /* undocumented logon domain id pointer */
1746 if(!prs_uint8s(False, "lm_sess_key", ps, depth, usr->lm_sess_key, 8)) /* lm session key */
1749 if(!prs_uint32("acct_flags ", ps, depth, &usr->acct_flags)) /* Account flags */
1751 dump_acct_flags(usr->acct_flags);
1752 for (i = 0; i < 7; i++)
1754 if (!prs_uint32("unkown", ps, depth, &usr->unknown[i])) /* unknown */
1758 if (validation_level == 3) {
1759 if(!prs_uint32("num_other_sids", ps, depth, &usr->num_other_sids)) /* 0 - num_sids */
1761 if(!prs_uint32("buffer_other_sids", ps, depth, &usr->buffer_other_sids)) /* NULL - undocumented pointer to SIDs. */
1764 if (UNMARSHALLING(ps)) {
1765 usr->num_other_sids = 0;
1766 usr->buffer_other_sids = 0;
1770 /* get kerb validation info (not really part of user_info_3) - Guenther */
1772 if (kerb_validation_level) {
1774 if(!prs_uint32("ptr_res_group_dom_sid", ps, depth, &usr->ptr_res_group_dom_sid))
1776 if(!prs_uint32("res_group_count", ps, depth, &usr->res_group_count))
1778 if(!prs_uint32("ptr_res_groups", ps, depth, &usr->ptr_res_groups))
1782 if(!smb_io_unistr2("uni_user_name", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
1784 if(!smb_io_unistr2("uni_full_name", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
1786 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
1788 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
1790 if(!smb_io_unistr2("uni_home_dir", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
1792 if(!smb_io_unistr2("uni_dir_drive", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
1798 if(!prs_uint32("num_groups2 ", ps, depth, &usr->num_groups2)) /* num groups2 */
1801 if (usr->num_groups != usr->num_groups2) {
1802 DEBUG(3,("net_io_user_info3: num_groups mismatch! (%d != %d)\n",
1803 usr->num_groups, usr->num_groups2));
1807 if (UNMARSHALLING(ps)) {
1808 usr->gids = PRS_ALLOC_MEM(ps, DOM_GID, usr->num_groups);
1809 if (usr->gids == NULL)
1813 for (i = 0; i < usr->num_groups; i++) {
1814 if(!smb_io_gid("", &usr->gids[i], ps, depth)) /* group info */
1818 if(!smb_io_unistr2("uni_logon_srv", &usr->uni_logon_srv, usr->hdr_logon_srv.buffer, ps, depth)) /* logon server unicode string */
1820 if(!smb_io_unistr2("uni_logon_dom", &usr->uni_logon_dom, usr->hdr_logon_dom.buffer, ps, depth)) /* logon domain unicode string */
1823 if(!smb_io_dom_sid2("", &usr->dom_sid, ps, depth)) /* domain SID */
1826 if (validation_level == 3 && usr->buffer_other_sids) {
1828 uint32 num_other_sids = usr->num_other_sids;
1830 if (!(usr->user_flgs & LOGON_EXTRA_SIDS)) {
1831 DEBUG(10,("net_io_user_info3: user_flgs attribute does not have LOGON_EXTRA_SIDS\n"));
1835 if (!prs_uint32("num_other_sids", ps, depth,
1839 if (num_other_sids != usr->num_other_sids)
1842 if (UNMARSHALLING(ps)) {
1843 usr->other_sids = PRS_ALLOC_MEM(ps, DOM_SID2, usr->num_other_sids);
1844 usr->other_sids_attrib =
1845 PRS_ALLOC_MEM(ps, uint32, usr->num_other_sids);
1847 if ((num_other_sids != 0) &&
1848 ((usr->other_sids == NULL) ||
1849 (usr->other_sids_attrib == NULL)))
1853 /* First the pointers to the SIDS and attributes */
1857 for (i=0; i<usr->num_other_sids; i++) {
1860 if (!prs_uint32("sid_ptr", ps, depth, &ptr))
1863 if (UNMARSHALLING(ps) && (ptr == 0))
1866 if (!prs_uint32("attribute", ps, depth,
1867 &usr->other_sids_attrib[i]))
1871 for (i = 0; i < usr->num_other_sids; i++) {
1872 if(!smb_io_dom_sid2("", &usr->other_sids[i], ps, depth)) /* other domain SIDs */
1882 /*******************************************************************
1883 Reads or writes a structure.
1884 ********************************************************************/
1886 BOOL net_io_q_sam_logon(const char *desc, NET_Q_SAM_LOGON *q_l, prs_struct *ps, int depth)
1891 prs_debug(ps, depth, desc, "net_io_q_sam_logon");
1897 if(!smb_io_sam_info("", &q_l->sam_id, ps, depth))
1900 if(!prs_align_uint16(ps))
1903 if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level))
1909 /*******************************************************************
1910 Reads or writes a structure.
1911 ********************************************************************/
1913 BOOL net_io_r_sam_logon(const char *desc, NET_R_SAM_LOGON *r_l, prs_struct *ps, int depth)
1918 prs_debug(ps, depth, desc, "net_io_r_sam_logon");
1921 if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */
1923 if (&r_l->buffer_creds) {
1924 if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials. server time stamp appears to be ignored. */
1928 if(!prs_uint16("switch_value", ps, depth, &r_l->switch_value))
1933 #if 1 /* W2k always needs this - even for bad passwd. JRA */
1934 if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
1937 if (r_l->switch_value != 0) {
1938 if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
1943 if(!prs_uint32("auth_resp ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */
1946 if(!prs_ntstatus("status ", ps, depth, &r_l->status))
1955 /*******************************************************************
1956 Reads or writes a structure.
1957 ********************************************************************/
1959 BOOL net_io_q_sam_logon_ex(const char *desc, NET_Q_SAM_LOGON_EX *q_l, prs_struct *ps, int depth)
1964 prs_debug(ps, depth, desc, "net_io_q_sam_logon_ex");
1970 if(!smb_io_sam_info_ex("", &q_l->sam_id, ps, depth))
1973 if(!prs_align_uint16(ps))
1976 if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level))
1979 if(!prs_uint32("flags ", ps, depth, &q_l->flags))
1985 /*******************************************************************
1986 Reads or writes a structure.
1987 ********************************************************************/
1989 BOOL net_io_r_sam_logon_ex(const char *desc, NET_R_SAM_LOGON_EX *r_l, prs_struct *ps, int depth)
1994 prs_debug(ps, depth, desc, "net_io_r_sam_logon_ex");
1997 if(!prs_uint16("switch_value", ps, depth, &r_l->switch_value))
2002 #if 1 /* W2k always needs this - even for bad passwd. JRA */
2003 if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
2006 if (r_l->switch_value != 0) {
2007 if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
2012 if(!prs_uint32("auth_resp ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */
2015 if(!prs_uint32("flags ", ps, depth, &r_l->flags))
2018 if(!prs_ntstatus("status ", ps, depth, &r_l->status))
2028 /*******************************************************************
2029 Reads or writes a structure.
2030 ********************************************************************/
2032 BOOL net_io_q_sam_logoff(const char *desc, NET_Q_SAM_LOGOFF *q_l, prs_struct *ps, int depth)
2037 prs_debug(ps, depth, desc, "net_io_q_sam_logoff");
2043 if(!smb_io_sam_info("", &q_l->sam_id, ps, depth)) /* domain SID */
2049 /*******************************************************************
2050 Reads or writes a structure.
2051 ********************************************************************/
2053 BOOL net_io_r_sam_logoff(const char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int depth)
2058 prs_debug(ps, depth, desc, "net_io_r_sam_logoff");
2064 if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */
2066 if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials. server time stamp appears to be ignored. */
2069 if(!prs_ntstatus("status ", ps, depth, &r_l->status))
2075 /*******************************************************************
2076 makes a NET_Q_SAM_SYNC structure.
2077 ********************************************************************/
2078 BOOL init_net_q_sam_sync(NET_Q_SAM_SYNC * q_s, const char *srv_name,
2079 const char *cli_name, DOM_CRED *cli_creds,
2080 DOM_CRED *ret_creds, uint32 database_id,
2083 DEBUG(5, ("init_q_sam_sync\n"));
2085 init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE);
2086 init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE);
2089 memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));
2092 memcpy(&q_s->ret_creds, ret_creds, sizeof(q_s->ret_creds));
2094 memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds));
2096 q_s->database_id = database_id;
2097 q_s->restart_state = 0;
2098 q_s->sync_context = next_rid;
2099 q_s->max_size = 0xffff;
2104 /*******************************************************************
2105 reads or writes a structure.
2106 ********************************************************************/
2107 BOOL net_io_q_sam_sync(const char *desc, NET_Q_SAM_SYNC * q_s, prs_struct *ps,
2110 prs_debug(ps, depth, desc, "net_io_q_sam_sync");
2113 if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth))
2115 if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth))
2118 if (!smb_io_cred("", &q_s->cli_creds, ps, depth))
2120 if (!smb_io_cred("", &q_s->ret_creds, ps, depth))
2123 if (!prs_uint32("database_id ", ps, depth, &q_s->database_id))
2125 if (!prs_uint32("restart_state", ps, depth, &q_s->restart_state))
2127 if (!prs_uint32("sync_context ", ps, depth, &q_s->sync_context))
2130 if (!prs_uint32("max_size", ps, depth, &q_s->max_size))
2136 /*******************************************************************
2137 reads or writes a structure.
2138 ********************************************************************/
2139 static BOOL net_io_sam_delta_hdr(const char *desc, SAM_DELTA_HDR * delta,
2140 prs_struct *ps, int depth)
2142 prs_debug(ps, depth, desc, "net_io_sam_delta_hdr");
2145 if (!prs_uint16("type", ps, depth, &delta->type))
2147 if (!prs_uint16("type2", ps, depth, &delta->type2))
2149 if (!prs_uint32("target_rid", ps, depth, &delta->target_rid))
2152 if (!prs_uint32("type3", ps, depth, &delta->type3))
2155 /* Not sure why we need this but it seems to be necessary to get
2156 sam deltas working. */
2158 if (delta->type != 0x16) {
2159 if (!prs_uint32("ptr_delta", ps, depth, &delta->ptr_delta))
2166 /*******************************************************************
2167 reads or writes a structure.
2168 ********************************************************************/
2169 static BOOL net_io_sam_delta_mod_count(const char *desc, SAM_DELTA_MOD_COUNT *info,
2170 prs_struct *ps, int depth)
2172 prs_debug(ps, depth, desc, "net_io_sam_delta_stamp");
2175 if (!prs_uint32("seqnum", ps, depth, &info->seqnum))
2177 if (!prs_uint32("dom_mod_count_ptr", ps, depth,
2178 &info->dom_mod_count_ptr))
2181 if (info->dom_mod_count_ptr) {
2182 if (!prs_uint64("dom_mod_count", ps, depth,
2183 &info->dom_mod_count))
2190 /*******************************************************************
2191 reads or writes a structure.
2192 ********************************************************************/
2193 static BOOL net_io_sam_domain_info(const char *desc, SAM_DOMAIN_INFO * info,
2194 prs_struct *ps, int depth)
2196 prs_debug(ps, depth, desc, "net_io_sam_domain_info");
2199 if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth))
2201 if (!smb_io_unihdr("hdr_oem_info", &info->hdr_oem_info, ps, depth))
2204 if (!prs_uint64("force_logoff", ps, depth, &info->force_logoff))
2206 if (!prs_uint16("min_pwd_len", ps, depth, &info->min_pwd_len))
2208 if (!prs_uint16("pwd_history_len", ps, depth, &info->pwd_history_len))
2210 if (!prs_uint64("max_pwd_age", ps, depth, &info->max_pwd_age))
2212 if (!prs_uint64("min_pwd_age", ps, depth, &info->min_pwd_age))
2214 if (!prs_uint64("dom_mod_count", ps, depth, &info->dom_mod_count))
2216 if (!smb_io_time("creation_time", &info->creation_time, ps, depth))
2218 if (!prs_uint32("security_information", ps, depth, &info->security_information))
2220 if (!smb_io_bufhdr4("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2222 if (!smb_io_lockout_string_hdr("hdr_account_lockout_string", &info->hdr_account_lockout, ps, depth))
2224 if (!smb_io_unihdr("hdr_unknown2", &info->hdr_unknown2, ps, depth))
2226 if (!smb_io_unihdr("hdr_unknown3", &info->hdr_unknown3, ps, depth))
2228 if (!smb_io_unihdr("hdr_unknown4", &info->hdr_unknown4, ps, depth))
2230 if (!prs_uint32("logon_chgpass", ps, depth, &info->logon_chgpass))
2232 if (!prs_uint32("unknown6", ps, depth, &info->unknown6))
2234 if (!prs_uint32("unknown7", ps, depth, &info->unknown7))
2236 if (!prs_uint32("unknown8", ps, depth, &info->unknown8))
2239 if (!smb_io_unistr2("uni_dom_name", &info->uni_dom_name,
2240 info->hdr_dom_name.buffer, ps, depth))
2242 if (!smb_io_unistr2("buf_oem_info", &info->buf_oem_info,
2243 info->hdr_oem_info.buffer, ps, depth))
2246 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
2249 if (!smb_io_account_lockout_str("account_lockout", &info->account_lockout,
2250 info->hdr_account_lockout.buffer, ps, depth))
2253 if (!smb_io_unistr2("buf_unknown2", &info->buf_unknown2,
2254 info->hdr_unknown2.buffer, ps, depth))
2256 if (!smb_io_unistr2("buf_unknown3", &info->buf_unknown3,
2257 info->hdr_unknown3.buffer, ps, depth))
2259 if (!smb_io_unistr2("buf_unknown4", &info->buf_unknown4,
2260 info->hdr_unknown4.buffer, ps, depth))
2266 /*******************************************************************
2267 reads or writes a structure.
2268 ********************************************************************/
2269 static BOOL net_io_sam_group_info(const char *desc, SAM_GROUP_INFO * info,
2270 prs_struct *ps, int depth)
2272 prs_debug(ps, depth, desc, "net_io_sam_group_info");
2275 if (!smb_io_unihdr("hdr_grp_name", &info->hdr_grp_name, ps, depth))
2277 if (!smb_io_gid("gid", &info->gid, ps, depth))
2279 if (!smb_io_unihdr("hdr_grp_desc", &info->hdr_grp_desc, ps, depth))
2281 if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2284 if (ps->data_offset + 48 > ps->buffer_size)
2286 ps->data_offset += 48;
2288 if (!smb_io_unistr2("uni_grp_name", &info->uni_grp_name,
2289 info->hdr_grp_name.buffer, ps, depth))
2291 if (!smb_io_unistr2("uni_grp_desc", &info->uni_grp_desc,
2292 info->hdr_grp_desc.buffer, ps, depth))
2294 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
2300 /*******************************************************************
2301 reads or writes a structure.
2302 ********************************************************************/
2303 static BOOL net_io_sam_passwd_info(const char *desc, SAM_PWD * pwd,
2304 prs_struct *ps, int depth)
2306 prs_debug(ps, depth, desc, "net_io_sam_passwd_info");
2309 if (!prs_uint32("unk_0 ", ps, depth, &pwd->unk_0))
2312 if (!smb_io_unihdr("hdr_lm_pwd", &pwd->hdr_lm_pwd, ps, depth))
2314 if (!prs_uint8s(False, "buf_lm_pwd", ps, depth, pwd->buf_lm_pwd, 16))
2317 if (!smb_io_unihdr("hdr_nt_pwd", &pwd->hdr_nt_pwd, ps, depth))
2319 if (!prs_uint8s(False, "buf_nt_pwd", ps, depth, pwd->buf_nt_pwd, 16))
2322 if (!smb_io_unihdr("", &pwd->hdr_empty_lm, ps, depth))
2324 if (!smb_io_unihdr("", &pwd->hdr_empty_nt, ps, depth))
2330 /*******************************************************************
2331 reads or writes a structure.
2332 ********************************************************************/
2333 static BOOL net_io_sam_account_info(const char *desc, SAM_ACCOUNT_INFO *info,
2334 prs_struct *ps, int depth)
2336 BUFHDR2 hdr_priv_data;
2339 prs_debug(ps, depth, desc, "net_io_sam_account_info");
2342 if (!smb_io_unihdr("hdr_acct_name", &info->hdr_acct_name, ps, depth))
2344 if (!smb_io_unihdr("hdr_full_name", &info->hdr_full_name, ps, depth))
2347 if (!prs_uint32("user_rid ", ps, depth, &info->user_rid))
2349 if (!prs_uint32("group_rid", ps, depth, &info->group_rid))
2352 if (!smb_io_unihdr("hdr_home_dir ", &info->hdr_home_dir, ps, depth))
2354 if (!smb_io_unihdr("hdr_dir_drive", &info->hdr_dir_drive, ps, depth))
2356 if (!smb_io_unihdr("hdr_logon_script", &info->hdr_logon_script, ps,
2360 if (!smb_io_unihdr("hdr_acct_desc", &info->hdr_acct_desc, ps, depth))
2362 if (!smb_io_unihdr("hdr_workstations", &info->hdr_workstations, ps,
2366 if (!smb_io_time("logon_time", &info->logon_time, ps, depth))
2368 if (!smb_io_time("logoff_time", &info->logoff_time, ps, depth))
2371 if (!prs_uint32("logon_divs ", ps, depth, &info->logon_divs))
2373 if (!prs_uint32("ptr_logon_hrs", ps, depth, &info->ptr_logon_hrs))
2376 if (!prs_uint16("bad_pwd_count", ps, depth, &info->bad_pwd_count))
2378 if (!prs_uint16("logon_count", ps, depth, &info->logon_count))
2380 if (!smb_io_time("pwd_last_set_time", &info->pwd_last_set_time, ps,
2383 if (!smb_io_time("acct_expiry_time", &info->acct_expiry_time, ps,
2387 if (!prs_uint32("acb_info", ps, depth, &info->acb_info))
2389 if (!prs_uint8s(False, "nt_pwd", ps, depth, info->nt_pwd, 16))
2391 if (!prs_uint8s(False, "lm_pwd", ps, depth, info->lm_pwd, 16))
2393 if (!prs_uint8("lm_pwd_present", ps, depth, &info->lm_pwd_present))
2395 if (!prs_uint8("nt_pwd_present", ps, depth, &info->nt_pwd_present))
2397 if (!prs_uint8("pwd_expired", ps, depth, &info->pwd_expired))
2400 if (!smb_io_unihdr("hdr_comment", &info->hdr_comment, ps, depth))
2402 if (!smb_io_unihdr("hdr_parameters", &info->hdr_parameters, ps,
2405 if (!prs_uint16("country", ps, depth, &info->country))
2407 if (!prs_uint16("codepage", ps, depth, &info->codepage))
2410 if (!smb_io_bufhdr2("hdr_priv_data", &hdr_priv_data, ps, depth))
2412 if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2414 if (!smb_io_unihdr("hdr_profile", &info->hdr_profile, ps, depth))
2417 for (i = 0; i < 3; i++)
2419 if (!smb_io_unihdr("hdr_reserved", &info->hdr_reserved[i],
2424 for (i = 0; i < 4; i++)
2426 if (!prs_uint32("dw_reserved", ps, depth,
2427 &info->dw_reserved[i]))
2431 if (!smb_io_unistr2("uni_acct_name", &info->uni_acct_name,
2432 info->hdr_acct_name.buffer, ps, depth))
2435 if (!smb_io_unistr2("uni_full_name", &info->uni_full_name,
2436 info->hdr_full_name.buffer, ps, depth))
2439 if (!smb_io_unistr2("uni_home_dir ", &info->uni_home_dir,
2440 info->hdr_home_dir.buffer, ps, depth))
2443 if (!smb_io_unistr2("uni_dir_drive", &info->uni_dir_drive,
2444 info->hdr_dir_drive.buffer, ps, depth))
2447 if (!smb_io_unistr2("uni_logon_script", &info->uni_logon_script,
2448 info->hdr_logon_script.buffer, ps, depth))
2451 if (!smb_io_unistr2("uni_acct_desc", &info->uni_acct_desc,
2452 info->hdr_acct_desc.buffer, ps, depth))
2455 if (!smb_io_unistr2("uni_workstations", &info->uni_workstations,
2456 info->hdr_workstations.buffer, ps, depth))
2460 if (!prs_uint32("unknown1", ps, depth, &info->unknown1))
2462 if (!prs_uint32("unknown2", ps, depth, &info->unknown2))
2465 if (!smb_io_rpc_blob("buf_logon_hrs", &info->buf_logon_hrs, ps, depth))
2468 if (!smb_io_unistr2("uni_comment", &info->uni_comment,
2469 info->hdr_comment.buffer, ps, depth))
2472 if (!smb_io_unistr2("uni_parameters", &info->uni_parameters,
2473 info->hdr_parameters.buffer, ps, depth))
2476 if (hdr_priv_data.buffer != 0)
2480 if (!prs_uint32("pwd_len", ps, depth, &len))
2482 old_offset = ps->data_offset;
2488 if (!prs_hash1(ps, ps->data_offset, len))
2491 if (!net_io_sam_passwd_info("pass", &info->pass,
2498 if (!prs_hash1(ps, old_offset, len))
2502 if (old_offset + len > ps->buffer_size)
2504 ps->data_offset = old_offset + len;
2506 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
2509 if (!smb_io_unistr2("uni_profile", &info->uni_profile,
2510 info->hdr_profile.buffer, ps, depth))
2518 /*******************************************************************
2519 reads or writes a structure.
2520 ********************************************************************/
2521 static BOOL net_io_sam_group_mem_info(const char *desc, SAM_GROUP_MEM_INFO * info,
2522 prs_struct *ps, int depth)
2527 prs_debug(ps, depth, desc, "net_io_sam_group_mem_info");
2531 if (!prs_uint32("ptr_rids ", ps, depth, &info->ptr_rids))
2533 if (!prs_uint32("ptr_attribs", ps, depth, &info->ptr_attribs))
2535 if (!prs_uint32("num_members", ps, depth, &info->num_members))
2538 if (ps->data_offset + 16 > ps->buffer_size)
2540 ps->data_offset += 16;
2542 if (info->ptr_rids != 0)
2544 if (!prs_uint32("num_members2", ps, depth,
2545 &info->num_members2))
2548 if (info->num_members2 != info->num_members)
2554 info->rids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members2);
2556 if (info->rids == NULL) {
2557 DEBUG(0, ("out of memory allocating %d rids\n",
2558 info->num_members2));
2562 for (i = 0; i < info->num_members2; i++)
2564 slprintf(tmp, sizeof(tmp) - 1, "rids[%02d]", i);
2565 if (!prs_uint32(tmp, ps, depth, &info->rids[i]))
2570 if (info->ptr_attribs != 0)
2572 if (!prs_uint32("num_members3", ps, depth,
2573 &info->num_members3))
2575 if (info->num_members3 != info->num_members)
2581 info->attribs = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members3);
2583 if (info->attribs == NULL) {
2584 DEBUG(0, ("out of memory allocating %d attribs\n",
2585 info->num_members3));
2589 for (i = 0; i < info->num_members3; i++)
2591 slprintf(tmp, sizeof(tmp) - 1, "attribs[%02d]", i);
2592 if (!prs_uint32(tmp, ps, depth, &info->attribs[i]))
2600 /*******************************************************************
2601 reads or writes a structure.
2602 ********************************************************************/
2603 static BOOL net_io_sam_alias_info(const char *desc, SAM_ALIAS_INFO * info,
2604 prs_struct *ps, int depth)
2606 prs_debug(ps, depth, desc, "net_io_sam_alias_info");
2609 if (!smb_io_unihdr("hdr_als_name", &info->hdr_als_name, ps, depth))
2611 if (!prs_uint32("als_rid", ps, depth, &info->als_rid))
2613 if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2615 if (!smb_io_unihdr("hdr_als_desc", &info->hdr_als_desc, ps, depth))
2618 if (ps->data_offset + 40 > ps->buffer_size)
2620 ps->data_offset += 40;
2622 if (!smb_io_unistr2("uni_als_name", &info->uni_als_name,
2623 info->hdr_als_name.buffer, ps, depth))
2625 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
2628 if (!smb_io_unistr2("uni_als_desc", &info->uni_als_desc,
2629 info->hdr_als_desc.buffer, ps, depth))
2635 /*******************************************************************
2636 reads or writes a structure.
2637 ********************************************************************/
2638 static BOOL net_io_sam_alias_mem_info(const char *desc, SAM_ALIAS_MEM_INFO * info,
2639 prs_struct *ps, int depth)
2644 prs_debug(ps, depth, desc, "net_io_sam_alias_mem_info");
2648 if (!prs_uint32("num_members", ps, depth, &info->num_members))
2650 if (!prs_uint32("ptr_members", ps, depth, &info->ptr_members))
2653 if (ps->data_offset + 16 > ps->buffer_size)
2655 ps->data_offset += 16;
2657 if (info->ptr_members != 0)
2659 if (!prs_uint32("num_sids", ps, depth, &info->num_sids))
2661 if (info->num_sids != info->num_members)
2667 info->ptr_sids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_sids);
2669 if (info->ptr_sids == NULL) {
2670 DEBUG(0, ("out of memory allocating %d ptr_sids\n",
2675 for (i = 0; i < info->num_sids; i++)
2677 slprintf(tmp, sizeof(tmp) - 1, "ptr_sids[%02d]", i);
2678 if (!prs_uint32(tmp, ps, depth, &info->ptr_sids[i]))
2682 info->sids = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, info->num_sids);
2684 if (info->sids == NULL) {
2685 DEBUG(0, ("error allocating %d sids\n",
2690 for (i = 0; i < info->num_sids; i++)
2692 if (info->ptr_sids[i] != 0)
2694 slprintf(tmp, sizeof(tmp) - 1, "sids[%02d]",
2696 if (!smb_io_dom_sid2(tmp, &info->sids[i],
2706 /*******************************************************************
2707 reads or writes a structure.
2708 ********************************************************************/
2709 static BOOL net_io_sam_policy_info(const char *desc, SAM_DELTA_POLICY *info,
2710 prs_struct *ps, int depth)
2713 prs_debug(ps, depth, desc, "net_io_sam_policy_info");
2719 if (!prs_uint32("max_log_size", ps, depth, &info->max_log_size))
2721 if (!prs_uint64("audit_retention_period", ps, depth,
2722 &info->audit_retention_period))
2724 if (!prs_uint32("auditing_mode", ps, depth, &info->auditing_mode))
2726 if (!prs_uint32("num_events", ps, depth, &info->num_events))
2728 if (!prs_uint32("ptr_events", ps, depth, &info->ptr_events))
2731 if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth))
2734 if (!prs_uint32("sid_ptr", ps, depth, &info->sid_ptr))
2737 if (!prs_uint32("paged_pool_limit", ps, depth, &info->paged_pool_limit))
2739 if (!prs_uint32("non_paged_pool_limit", ps, depth,
2740 &info->non_paged_pool_limit))
2742 if (!prs_uint32("min_workset_size", ps, depth, &info->min_workset_size))
2744 if (!prs_uint32("max_workset_size", ps, depth, &info->max_workset_size))
2746 if (!prs_uint32("page_file_limit", ps, depth, &info->page_file_limit))
2748 if (!prs_uint64("time_limit", ps, depth, &info->time_limit))
2750 if (!smb_io_time("modify_time", &info->modify_time, ps, depth))
2752 if (!smb_io_time("create_time", &info->create_time, ps, depth))
2754 if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2757 for (i=0; i<4; i++) {
2759 if (!smb_io_unihdr("dummy", &dummy, ps, depth))
2763 for (i=0; i<4; i++) {
2765 if (!prs_uint32("reserved", ps, depth, &reserved))
2769 if (!prs_uint32("num_event_audit_options", ps, depth,
2770 &info->num_event_audit_options))
2773 for (i=0; i<info->num_event_audit_options; i++)
2774 if (!prs_uint32("event_audit_option", ps, depth,
2775 &info->event_audit_option))
2778 if (!smb_io_unistr2("domain_name", &info->domain_name, True, ps, depth))
2781 if(!smb_io_dom_sid2("domain_sid", &info->domain_sid, ps, depth))
2784 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
2793 /* This function is pretty broken - see bug #334 */
2795 /*******************************************************************
2796 reads or writes a structure.
2797 ********************************************************************/
2798 static BOOL net_io_sam_trustdoms_info(const char *desc, SAM_DELTA_TRUSTDOMS *info,
2799 prs_struct *ps, int depth)
2803 prs_debug(ps, depth, desc, "net_io_sam_trustdoms_info");
2809 if(!prs_uint32("buf_size", ps, depth, &info->buf_size))
2812 if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth))
2815 if(!smb_io_dom_sid2("sid", &info->sid, ps, depth))
2818 if(!smb_io_unihdr("hdr_domain", &info->hdr_domain, ps, depth))
2821 if(!prs_uint32("unknown0", ps, depth, &info->unknown0))
2823 if(!prs_uint32("unknown1", ps, depth, &info->unknown1))
2825 if(!prs_uint32("unknown2", ps, depth, &info->unknown2))
2828 if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2))
2830 if(!prs_uint32("ptr", ps, depth, &info->ptr))
2833 for (i=0; i<12; i++)
2834 if(!prs_uint32("unknown3", ps, depth, &info->unknown3))
2837 if (!smb_io_unistr2("domain", &info->domain, True, ps, depth))
2847 /* This function doesn't work - see bug #334 */
2849 /*******************************************************************
2850 reads or writes a structure.
2851 ********************************************************************/
2852 static BOOL net_io_sam_secret_info(const char *desc, SAM_DELTA_SECRET *info,
2853 prs_struct *ps, int depth)
2857 prs_debug(ps, depth, desc, "net_io_sam_secret_info");
2863 if(!prs_uint32("buf_size", ps, depth, &info->buf_size))
2866 if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth))
2869 if (!smb_io_unistr2("secret", &info->secret, True, ps, depth))
2875 if(!prs_uint32("count1", ps, depth, &info->count1))
2877 if(!prs_uint32("count2", ps, depth, &info->count2))
2879 if(!prs_uint32("ptr", ps, depth, &info->ptr))
2883 if(!smb_io_time("time1", &info->time1, ps, depth)) /* logon time */
2885 if(!prs_uint32("count3", ps, depth, &info->count3))
2887 if(!prs_uint32("count4", ps, depth, &info->count4))
2889 if(!prs_uint32("ptr2", ps, depth, &info->ptr2))
2891 if(!smb_io_time("time2", &info->time2, ps, depth)) /* logon time */
2893 if(!prs_uint32("unknow1", ps, depth, &info->unknow1))
2897 if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2))
2899 if(!prs_uint32("ptr3", ps, depth, &info->ptr3))
2902 if(!prs_uint32("unknow2", ps, depth, &info->unknow2))
2905 if(!prs_uint32("chal_len", ps, depth, &info->chal_len))
2907 if(!prs_uint32("reserved1", ps, depth, &info->reserved1))
2909 if(!prs_uint32("chal_len2", ps, depth, &info->chal_len2))
2912 if(!prs_uint8s (False, "chal", ps, depth, info->chal, info->chal_len2))
2915 if(!prs_uint32("key_len", ps, depth, &info->key_len))
2917 if(!prs_uint32("reserved2", ps, depth, &info->reserved2))
2919 if(!prs_uint32("key_len2", ps, depth, &info->key_len2))
2922 if(!prs_uint8s (False, "key", ps, depth, info->key, info->key_len2))
2926 if(!prs_uint32("buf_size3", ps, depth, &info->buf_size3))
2929 if(!sec_io_desc("sec_desc2", &info->sec_desc2, ps, depth))
2938 /*******************************************************************
2939 reads or writes a structure.
2940 ********************************************************************/
2941 static BOOL net_io_sam_privs_info(const char *desc, SAM_DELTA_PRIVS *info,
2942 prs_struct *ps, int depth)
2946 prs_debug(ps, depth, desc, "net_io_sam_privs_info");
2952 if(!smb_io_dom_sid2("sid", &info->sid, ps, depth))
2955 if(!prs_uint32("priv_count", ps, depth, &info->priv_count))
2957 if(!prs_uint32("priv_control", ps, depth, &info->priv_control))
2960 if(!prs_uint32("priv_attr_ptr", ps, depth, &info->priv_attr_ptr))
2962 if(!prs_uint32("priv_name_ptr", ps, depth, &info->priv_name_ptr))
2965 if (!prs_uint32("paged_pool_limit", ps, depth, &info->paged_pool_limit))
2967 if (!prs_uint32("non_paged_pool_limit", ps, depth,
2968 &info->non_paged_pool_limit))
2970 if (!prs_uint32("min_workset_size", ps, depth, &info->min_workset_size))
2972 if (!prs_uint32("max_workset_size", ps, depth, &info->max_workset_size))
2974 if (!prs_uint32("page_file_limit", ps, depth, &info->page_file_limit))
2976 if (!prs_uint64("time_limit", ps, depth, &info->time_limit))
2978 if (!prs_uint32("system_flags", ps, depth, &info->system_flags))
2980 if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2983 for (i=0; i<4; i++) {
2985 if (!smb_io_unihdr("dummy", &dummy, ps, depth))
2989 for (i=0; i<4; i++) {
2991 if (!prs_uint32("reserved", ps, depth, &reserved))
2995 if(!prs_uint32("attribute_count", ps, depth, &info->attribute_count))
2998 if (UNMARSHALLING(ps)) {
2999 if (info->attribute_count) {
3000 info->attributes = TALLOC_ARRAY(ps->mem_ctx, uint32, info->attribute_count);
3001 if (!info->attributes) {
3005 info->attributes = NULL;
3009 for (i=0; i<info->attribute_count; i++)
3010 if(!prs_uint32("attributes", ps, depth, &info->attributes[i]))
3013 if(!prs_uint32("privlist_count", ps, depth, &info->privlist_count))
3016 if (UNMARSHALLING(ps)) {
3017 if (info->privlist_count) {
3018 info->hdr_privslist = TALLOC_ARRAY(ps->mem_ctx, UNIHDR, info->privlist_count);
3019 info->uni_privslist = TALLOC_ARRAY(ps->mem_ctx, UNISTR2, info->privlist_count);
3020 if (!info->hdr_privslist) {
3023 if (!info->uni_privslist) {
3027 info->hdr_privslist = NULL;
3028 info->uni_privslist = NULL;
3032 for (i=0; i<info->privlist_count; i++)
3033 if(!smb_io_unihdr("hdr_privslist", &info->hdr_privslist[i], ps, depth))
3036 for (i=0; i<info->privlist_count; i++)
3037 if (!smb_io_unistr2("uni_privslist", &info->uni_privslist[i], True, ps, depth))
3040 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
3046 /*******************************************************************
3047 reads or writes a structure.
3048 ********************************************************************/
3049 static BOOL net_io_sam_delta_ctr(const char *desc,
3050 SAM_DELTA_CTR * delta, uint16 type,
3051 prs_struct *ps, int depth)
3053 prs_debug(ps, depth, desc, "net_io_sam_delta_ctr");
3057 /* Seen in sam deltas */
3058 case SAM_DELTA_MODIFIED_COUNT:
3059 if (!net_io_sam_delta_mod_count("", &delta->mod_count, ps, depth))
3063 case SAM_DELTA_DOMAIN_INFO:
3064 if (!net_io_sam_domain_info("", &delta->domain_info, ps, depth))
3068 case SAM_DELTA_GROUP_INFO:
3069 if (!net_io_sam_group_info("", &delta->group_info, ps, depth))
3073 case SAM_DELTA_ACCOUNT_INFO:
3074 if (!net_io_sam_account_info("", &delta->account_info, ps, depth))
3078 case SAM_DELTA_GROUP_MEM:
3079 if (!net_io_sam_group_mem_info("", &delta->grp_mem_info, ps, depth))
3083 case SAM_DELTA_ALIAS_INFO:
3084 if (!net_io_sam_alias_info("", &delta->alias_info, ps, depth))
3088 case SAM_DELTA_POLICY_INFO:
3089 if (!net_io_sam_policy_info("", &delta->policy_info, ps, depth))
3093 case SAM_DELTA_ALIAS_MEM:
3094 if (!net_io_sam_alias_mem_info("", &delta->als_mem_info, ps, depth))
3098 case SAM_DELTA_PRIVS_INFO:
3099 if (!net_io_sam_privs_info("", &delta->privs_info, ps, depth))
3103 /* These guys are implemented but broken */
3105 case SAM_DELTA_TRUST_DOMS:
3106 case SAM_DELTA_SECRET_INFO:
3109 /* These guys are not implemented yet */
3111 case SAM_DELTA_RENAME_GROUP:
3112 case SAM_DELTA_RENAME_USER:
3113 case SAM_DELTA_RENAME_ALIAS:
3114 case SAM_DELTA_DELETE_GROUP:
3115 case SAM_DELTA_DELETE_USER:
3117 DEBUG(0, ("Replication error: Unknown delta type 0x%x\n", type));
3124 /*******************************************************************
3125 reads or writes a structure.
3126 ********************************************************************/
3127 BOOL net_io_r_sam_sync(const char *desc,
3128 NET_R_SAM_SYNC * r_s, prs_struct *ps, int depth)
3132 prs_debug(ps, depth, desc, "net_io_r_sam_sync");
3135 if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth))
3137 if (!prs_uint32("sync_context", ps, depth, &r_s->sync_context))
3140 if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas))
3142 if (r_s->ptr_deltas != 0)
3144 if (!prs_uint32("num_deltas ", ps, depth, &r_s->num_deltas))
3146 if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->ptr_deltas2))
3148 if (r_s->ptr_deltas2 != 0)
3150 if (!prs_uint32("num_deltas2", ps, depth,
3154 if (r_s->num_deltas2 != r_s->num_deltas)
3160 if (r_s->num_deltas2 > 0) {
3161 r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas2);
3162 if (r_s->hdr_deltas == NULL) {
3163 DEBUG(0, ("error tallocating memory "
3164 "for %d delta headers\n",
3170 for (i = 0; i < r_s->num_deltas2; i++)
3172 if (!net_io_sam_delta_hdr("",
3173 &r_s->hdr_deltas[i],
3178 if (r_s->num_deltas2 > 0) {
3179 r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas2);
3180 if (r_s->deltas == NULL) {
3181 DEBUG(0, ("error tallocating memory "
3188 for (i = 0; i < r_s->num_deltas2; i++)
3190 if (!net_io_sam_delta_ctr(
3191 "", &r_s->deltas[i],
3192 r_s->hdr_deltas[i].type3,
3194 DEBUG(0, ("hmm, failed on i=%d\n", i));
3202 if (!prs_ntstatus("status", ps, depth, &(r_s->status)))
3208 /*******************************************************************
3209 makes a NET_Q_SAM_DELTAS structure.
3210 ********************************************************************/
3211 BOOL init_net_q_sam_deltas(NET_Q_SAM_DELTAS *q_s, const char *srv_name,
3212 const char *cli_name, DOM_CRED *cli_creds,
3213 uint32 database_id, uint64 dom_mod_count)
3215 DEBUG(5, ("init_net_q_sam_deltas\n"));
3217 init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE);
3218 init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE);
3220 memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));
3221 memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds));
3223 q_s->database_id = database_id;
3224 q_s->dom_mod_count = dom_mod_count;
3225 q_s->max_size = 0xffff;
3230 /*******************************************************************
3231 reads or writes a structure.
3232 ********************************************************************/
3233 BOOL net_io_q_sam_deltas(const char *desc, NET_Q_SAM_DELTAS *q_s, prs_struct *ps,
3236 prs_debug(ps, depth, desc, "net_io_q_sam_deltas");
3239 if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth))
3241 if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth))
3244 if (!smb_io_cred("", &q_s->cli_creds, ps, depth))
3246 if (!smb_io_cred("", &q_s->ret_creds, ps, depth))
3249 if (!prs_uint32("database_id ", ps, depth, &q_s->database_id))
3251 if (!prs_uint64("dom_mod_count", ps, depth, &q_s->dom_mod_count))
3253 if (!prs_uint32("max_size", ps, depth, &q_s->max_size))
3259 /*******************************************************************
3260 reads or writes a structure.
3261 ********************************************************************/
3262 BOOL net_io_r_sam_deltas(const char *desc,
3263 NET_R_SAM_DELTAS *r_s, prs_struct *ps, int depth)
3267 prs_debug(ps, depth, desc, "net_io_r_sam_deltas");
3270 if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth))
3272 if (!prs_uint64("dom_mod_count", ps, depth, &r_s->dom_mod_count))
3275 if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas))
3277 if (!prs_uint32("num_deltas", ps, depth, &r_s->num_deltas))
3279 if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->num_deltas2))
3282 if (r_s->num_deltas2 != 0)
3284 if (!prs_uint32("num_deltas2 ", ps, depth, &r_s->num_deltas2))
3287 if (r_s->ptr_deltas != 0)
3289 if (r_s->num_deltas > 0) {
3290 r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas);
3291 if (r_s->hdr_deltas == NULL) {
3292 DEBUG(0, ("error tallocating memory "
3293 "for %d delta headers\n",
3299 for (i = 0; i < r_s->num_deltas; i++)
3301 net_io_sam_delta_hdr("", &r_s->hdr_deltas[i],
3305 if (r_s->num_deltas > 0) {
3306 r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas);
3307 if (r_s->deltas == NULL) {
3308 DEBUG(0, ("error tallocating memory "
3315 for (i = 0; i < r_s->num_deltas; i++)
3317 if (!net_io_sam_delta_ctr(
3320 r_s->hdr_deltas[i].type2,
3329 if (!prs_ntstatus("status", ps, depth, &r_s->status))
3335 /*******************************************************************
3336 Inits a NET_Q_DSR_GETDCNAME structure.
3337 ********************************************************************/
3339 void init_net_q_dsr_getdcname(NET_Q_DSR_GETDCNAME *r_t, const char *server_unc,
3340 const char *domain_name,
3341 struct GUID *domain_guid,
3342 struct GUID *site_guid,
3345 DEBUG(5, ("init_net_q_dsr_getdcname\n"));
3347 r_t->ptr_server_unc = (server_unc != NULL);
3348 init_unistr2(&r_t->uni_server_unc, server_unc, UNI_STR_TERMINATE);
3350 r_t->ptr_domain_name = (domain_name != NULL);
3351 init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE);
3353 r_t->ptr_domain_guid = (domain_guid != NULL);
3354 r_t->domain_guid = domain_guid;
3356 r_t->ptr_site_guid = (site_guid != NULL);
3357 r_t->site_guid = site_guid;
3362 /*******************************************************************
3363 Reads or writes an NET_Q_DSR_GETDCNAME structure.
3364 ********************************************************************/
3366 BOOL net_io_q_dsr_getdcname(const char *desc, NET_Q_DSR_GETDCNAME *r_t,
3367 prs_struct *ps, int depth)
3372 prs_debug(ps, depth, desc, "net_io_q_dsr_getdcname");
3375 if (!prs_uint32("ptr_server_unc", ps, depth, &r_t->ptr_server_unc))
3378 if (!smb_io_unistr2("server_unc", &r_t->uni_server_unc,
3379 r_t->ptr_server_unc, ps, depth))
3385 if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name))
3388 if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name,
3389 r_t->ptr_domain_name, ps, depth))
3395 if (!prs_uint32("ptr_domain_guid", ps, depth, &r_t->ptr_domain_guid))
3398 if (UNMARSHALLING(ps) && (r_t->ptr_domain_guid)) {
3399 r_t->domain_guid = PRS_ALLOC_MEM(ps, struct GUID, 1);
3400 if (r_t->domain_guid == NULL)
3404 if ((r_t->ptr_domain_guid) &&
3405 (!smb_io_uuid("domain_guid", r_t->domain_guid, ps, depth)))
3411 if (!prs_uint32("ptr_site_guid", ps, depth, &r_t->ptr_site_guid))
3414 if (UNMARSHALLING(ps) && (r_t->ptr_site_guid)) {
3415 r_t->site_guid = PRS_ALLOC_MEM(ps, struct GUID, 1);
3416 if (r_t->site_guid == NULL)
3420 if ((r_t->ptr_site_guid) &&
3421 (!smb_io_uuid("site_guid", r_t->site_guid, ps, depth)))
3427 if (!prs_uint32("flags", ps, depth, &r_t->flags))
3433 /*******************************************************************
3434 Inits a NET_R_DSR_GETDCNAME structure.
3435 ********************************************************************/
3436 void init_net_r_dsr_getdcname(NET_R_DSR_GETDCNAME *r_t, const char *dc_unc,
3437 const char *dc_address, int32 dc_address_type,
3438 struct GUID domain_guid, const char *domain_name,
3439 const char *forest_name, uint32 dc_flags,
3440 const char *dc_site_name,
3441 const char *client_site_name)
3443 DEBUG(5, ("init_net_q_dsr_getdcname\n"));
3445 r_t->ptr_dc_unc = (dc_unc != NULL);
3446 init_unistr2(&r_t->uni_dc_unc, dc_unc, UNI_STR_TERMINATE);
3448 r_t->ptr_dc_address = (dc_address != NULL);
3449 init_unistr2(&r_t->uni_dc_address, dc_address, UNI_STR_TERMINATE);
3451 r_t->dc_address_type = dc_address_type;
3452 r_t->domain_guid = domain_guid;
3454 r_t->ptr_domain_name = (domain_name != NULL);
3455 init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE);
3457 r_t->ptr_forest_name = (forest_name != NULL);
3458 init_unistr2(&r_t->uni_forest_name, forest_name, UNI_STR_TERMINATE);
3460 r_t->dc_flags = dc_flags;
3462 r_t->ptr_dc_site_name = (dc_site_name != NULL);
3463 init_unistr2(&r_t->uni_dc_site_name, dc_site_name, UNI_STR_TERMINATE);
3465 r_t->ptr_client_site_name = (client_site_name != NULL);
3466 init_unistr2(&r_t->uni_client_site_name, client_site_name,
3470 /*******************************************************************
3471 Reads or writes an NET_R_DSR_GETDCNAME structure.
3472 ********************************************************************/
3474 BOOL net_io_r_dsr_getdcname(const char *desc, NET_R_DSR_GETDCNAME *r_t,
3475 prs_struct *ps, int depth)
3477 uint32 info_ptr = 1;
3482 prs_debug(ps, depth, desc, "net_io_r_dsr_getdcname");
3485 /* The reply contains *just* an info struct, this is the ptr to it */
3486 if (!prs_uint32("info_ptr", ps, depth, &info_ptr))
3492 if (!prs_uint32("ptr_dc_unc", ps, depth, &r_t->ptr_dc_unc))
3495 if (!prs_uint32("ptr_dc_address", ps, depth, &r_t->ptr_dc_address))
3498 if (!prs_int32("dc_address_type", ps, depth, &r_t->dc_address_type))
3501 if (!smb_io_uuid("domain_guid", &r_t->domain_guid, ps, depth))
3504 if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name))
3507 if (!prs_uint32("ptr_forest_name", ps, depth, &r_t->ptr_forest_name))
3510 if (!prs_uint32("dc_flags", ps, depth, &r_t->dc_flags))
3513 if (!prs_uint32("ptr_dc_site_name", ps, depth, &r_t->ptr_dc_site_name))
3516 if (!prs_uint32("ptr_client_site_name", ps, depth,
3517 &r_t->ptr_client_site_name))
3523 if (!smb_io_unistr2("dc_unc", &r_t->uni_dc_unc,
3524 r_t->ptr_dc_unc, ps, depth))
3530 if (!smb_io_unistr2("dc_address", &r_t->uni_dc_address,
3531 r_t->ptr_dc_address, ps, depth))
3537 if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name,
3538 r_t->ptr_domain_name, ps, depth))
3544 if (!smb_io_unistr2("forest_name", &r_t->uni_forest_name,
3545 r_t->ptr_forest_name, ps, depth))
3551 if (!smb_io_unistr2("dc_site_name", &r_t->uni_dc_site_name,
3552 r_t->ptr_dc_site_name, ps, depth))
3558 if (!smb_io_unistr2("client_site_name", &r_t->uni_client_site_name,
3559 r_t->ptr_client_site_name, ps, depth))
3565 if (!prs_werror("result", ps, depth, &r_t->result))
3571 /*******************************************************************
3572 Inits a NET_Q_DSR_GETSITENAME structure.
3573 ********************************************************************/
3575 void init_net_q_dsr_getsitename(NET_Q_DSR_GETSITENAME *r_t, const char *computer_name)
3577 DEBUG(5, ("init_net_q_dsr_getsitename\n"));
3579 r_t->ptr_computer_name = (computer_name != NULL);
3580 init_unistr2(&r_t->uni_computer_name, computer_name, UNI_STR_TERMINATE);
3583 /*******************************************************************
3584 Reads or writes an NET_Q_DSR_GETSITENAME structure.
3585 ********************************************************************/
3587 BOOL net_io_q_dsr_getsitename(const char *desc, NET_Q_DSR_GETSITENAME *r_t,
3588 prs_struct *ps, int depth)
3593 prs_debug(ps, depth, desc, "net_io_q_dsr_getsitename");
3596 if (!prs_uint32("ptr_computer_name", ps, depth, &r_t->ptr_computer_name))
3599 if (!smb_io_unistr2("computer_name", &r_t->uni_computer_name,
3600 r_t->ptr_computer_name, ps, depth))
3609 /*******************************************************************
3610 Reads or writes an NET_R_DSR_GETSITENAME structure.
3611 ********************************************************************/
3613 BOOL net_io_r_dsr_getsitename(const char *desc, NET_R_DSR_GETSITENAME *r_t,
3614 prs_struct *ps, int depth)
3619 prs_debug(ps, depth, desc, "net_io_r_dsr_getsitename");
3622 if (!prs_uint32("ptr_site_name", ps, depth, &r_t->ptr_site_name))
3628 if (!smb_io_unistr2("site_name", &r_t->uni_site_name,
3629 r_t->ptr_site_name, ps, depth))
3635 if (!prs_werror("result", ps, depth, &r_t->result))