Enable building of VFS modules: vfs_tsmsm, vfs_shadowcopy2 and IDMAP module idmap_tdb2
[Samba/id10ts.git] / source3 / rpc_parse / parse_net.c
blob65607a4ac896a31c9b9d5f77a306b2817aea89c5
1 /*
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 3 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, see <http://www.gnu.org/licenses/>.
23 #include "includes.h"
25 #undef DBGC_CLASS
26 #define DBGC_CLASS DBGC_RPC_PARSE
28 /*******************************************************************
29 Reads or writes a structure.
30 ********************************************************************/
32 static bool net_io_neg_flags(const char *desc, NEG_FLAGS *neg, prs_struct *ps, int depth)
34 if (neg == NULL)
35 return False;
37 prs_debug(ps, depth, desc, "net_io_neg_flags");
38 depth++;
40 if(!prs_align(ps))
41 return False;
43 if(!prs_uint32("neg_flags", ps, depth, &neg->neg_flags))
44 return False;
46 return True;
49 /*******************************************************************
50 Inits a NETLOGON_INFO_3 structure.
51 ********************************************************************/
53 static void init_netinfo_3(NETLOGON_INFO_3 *info, uint32 flags, uint32 logon_attempts)
55 info->flags = flags;
56 info->logon_attempts = logon_attempts;
57 info->reserved_1 = 0x0;
58 info->reserved_2 = 0x0;
59 info->reserved_3 = 0x0;
60 info->reserved_4 = 0x0;
61 info->reserved_5 = 0x0;
64 /*******************************************************************
65 Reads or writes a NETLOGON_INFO_3 structure.
66 ********************************************************************/
68 static bool net_io_netinfo_3(const char *desc, NETLOGON_INFO_3 *info, prs_struct *ps, int depth)
70 if (info == NULL)
71 return False;
73 prs_debug(ps, depth, desc, "net_io_netinfo_3");
74 depth++;
76 if(!prs_align(ps))
77 return False;
79 if(!prs_uint32("flags ", ps, depth, &info->flags))
80 return False;
81 if(!prs_uint32("logon_attempts", ps, depth, &info->logon_attempts))
82 return False;
83 if(!prs_uint32("reserved_1 ", ps, depth, &info->reserved_1))
84 return False;
85 if(!prs_uint32("reserved_2 ", ps, depth, &info->reserved_2))
86 return False;
87 if(!prs_uint32("reserved_3 ", ps, depth, &info->reserved_3))
88 return False;
89 if(!prs_uint32("reserved_4 ", ps, depth, &info->reserved_4))
90 return False;
91 if(!prs_uint32("reserved_5 ", ps, depth, &info->reserved_5))
92 return False;
94 return True;
98 /*******************************************************************
99 Inits a NETLOGON_INFO_1 structure.
100 ********************************************************************/
102 static void init_netinfo_1(NETLOGON_INFO_1 *info, uint32 flags, uint32 pdc_status)
104 info->flags = flags;
105 info->pdc_status = pdc_status;
108 /*******************************************************************
109 Reads or writes a NETLOGON_INFO_1 structure.
110 ********************************************************************/
112 static bool net_io_netinfo_1(const char *desc, NETLOGON_INFO_1 *info, prs_struct *ps, int depth)
114 if (info == NULL)
115 return False;
117 prs_debug(ps, depth, desc, "net_io_netinfo_1");
118 depth++;
120 if(!prs_align(ps))
121 return False;
123 if(!prs_uint32("flags ", ps, depth, &info->flags))
124 return False;
125 if(!prs_uint32("pdc_status", ps, depth, &info->pdc_status))
126 return False;
128 return True;
131 /*******************************************************************
132 Inits a NETLOGON_INFO_2 structure.
133 ********************************************************************/
135 static void init_netinfo_2(NETLOGON_INFO_2 *info, uint32 flags, uint32 pdc_status,
136 uint32 tc_status, const char *trusted_dc_name)
138 info->flags = flags;
139 info->pdc_status = pdc_status;
140 info->ptr_trusted_dc_name = 1;
141 info->tc_status = tc_status;
143 if (trusted_dc_name != NULL)
144 init_unistr2(&info->uni_trusted_dc_name, trusted_dc_name, UNI_STR_TERMINATE);
145 else
146 init_unistr2(&info->uni_trusted_dc_name, "", UNI_STR_TERMINATE);
149 /*******************************************************************
150 Reads or writes a NETLOGON_INFO_2 structure.
151 ********************************************************************/
153 static bool net_io_netinfo_2(const char *desc, NETLOGON_INFO_2 *info, prs_struct *ps, int depth)
155 if (info == NULL)
156 return False;
158 prs_debug(ps, depth, desc, "net_io_netinfo_2");
159 depth++;
161 if(!prs_align(ps))
162 return False;
164 if(!prs_uint32("flags ", ps, depth, &info->flags))
165 return False;
166 if(!prs_uint32("pdc_status ", ps, depth, &info->pdc_status))
167 return False;
168 if(!prs_uint32("ptr_trusted_dc_name", ps, depth, &info->ptr_trusted_dc_name))
169 return False;
170 if(!prs_uint32("tc_status ", ps, depth, &info->tc_status))
171 return False;
173 if (info->ptr_trusted_dc_name != 0) {
174 if(!smb_io_unistr2("unistr2", &info->uni_trusted_dc_name, info->ptr_trusted_dc_name, ps, depth))
175 return False;
178 if(!prs_align(ps))
179 return False;
181 return True;
184 static bool net_io_ctrl_data_info_5(const char *desc, CTRL_DATA_INFO_5 *info, prs_struct *ps, int depth)
186 if (info == NULL)
187 return False;
189 prs_debug(ps, depth, desc, "net_io_ctrl_data_info_5");
190 depth++;
192 if ( !prs_uint32( "function_code", ps, depth, &info->function_code ) )
193 return False;
195 if(!prs_uint32("ptr_domain", ps, depth, &info->ptr_domain))
196 return False;
198 if ( info->ptr_domain ) {
199 if(!smb_io_unistr2("domain", &info->domain, info->ptr_domain, ps, depth))
200 return False;
203 return True;
206 static bool net_io_ctrl_data_info_6(const char *desc, CTRL_DATA_INFO_6 *info, prs_struct *ps, int depth)
208 if (info == NULL)
209 return False;
211 prs_debug(ps, depth, desc, "net_io_ctrl_data_info_6");
212 depth++;
214 if ( !prs_uint32( "function_code", ps, depth, &info->function_code ) )
215 return False;
217 if(!prs_uint32("ptr_domain", ps, depth, &info->ptr_domain))
218 return False;
220 if ( info->ptr_domain ) {
221 if(!smb_io_unistr2("domain", &info->domain, info->ptr_domain, ps, depth))
222 return False;
225 return True;
228 /*******************************************************************
229 Reads or writes an NET_Q_LOGON_CTRL2 structure.
230 ********************************************************************/
232 bool net_io_q_logon_ctrl2(const char *desc, NET_Q_LOGON_CTRL2 *q_l, prs_struct *ps, int depth)
234 if (q_l == NULL)
235 return False;
237 prs_debug(ps, depth, desc, "net_io_q_logon_ctrl2");
238 depth++;
240 if(!prs_align(ps))
241 return False;
243 if(!prs_uint32("ptr ", ps, depth, &q_l->ptr))
244 return False;
246 if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth))
247 return False;
249 if(!prs_align(ps))
250 return False;
252 if(!prs_uint32("function_code", ps, depth, &q_l->function_code))
253 return False;
254 if(!prs_uint32("query_level ", ps, depth, &q_l->query_level))
255 return False;
256 switch ( q_l->function_code ) {
257 case NETLOGON_CONTROL_REDISCOVER:
258 if ( !net_io_ctrl_data_info_5( "ctrl_data_info5", &q_l->info.info5, ps, depth) )
259 return False;
260 break;
262 case NETLOGON_CONTROL_TC_QUERY:
263 if ( !net_io_ctrl_data_info_6( "ctrl_data_info6", &q_l->info.info6, ps, depth) )
264 return False;
265 break;
267 default:
268 DEBUG(0,("net_io_q_logon_ctrl2: unknown function_code [%d]\n",
269 q_l->function_code));
270 return False;
273 return True;
276 /*******************************************************************
277 Inits an NET_Q_LOGON_CTRL2 structure.
278 ********************************************************************/
280 void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, const char *srv_name,
281 uint32 query_level)
283 DEBUG(5,("init_q_logon_ctrl2\n"));
285 q_l->function_code = 0x01;
286 q_l->query_level = query_level;
288 init_unistr2(&q_l->uni_server_name, srv_name, UNI_STR_TERMINATE);
291 /*******************************************************************
292 Inits an NET_R_LOGON_CTRL2 structure.
293 ********************************************************************/
295 void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level,
296 uint32 flags, uint32 pdc_status,
297 uint32 logon_attempts, uint32 tc_status,
298 const char *trusted_domain_name)
300 r_l->switch_value = query_level;
302 switch (query_level) {
303 case 1:
304 r_l->ptr = 1; /* undocumented pointer */
305 init_netinfo_1(&r_l->logon.info1, flags, pdc_status);
306 r_l->status = NT_STATUS_OK;
307 break;
308 case 2:
309 r_l->ptr = 1; /* undocumented pointer */
310 init_netinfo_2(&r_l->logon.info2, flags, pdc_status,
311 tc_status, trusted_domain_name);
312 r_l->status = NT_STATUS_OK;
313 break;
314 case 3:
315 r_l->ptr = 1; /* undocumented pointer */
316 init_netinfo_3(&r_l->logon.info3, flags, logon_attempts);
317 r_l->status = NT_STATUS_OK;
318 break;
319 default:
320 DEBUG(2,("init_r_logon_ctrl2: unsupported switch value %d\n",
321 r_l->switch_value));
322 r_l->ptr = 0; /* undocumented pointer */
324 /* take a guess at an error code... */
325 r_l->status = NT_STATUS_INVALID_INFO_CLASS;
326 break;
330 /*******************************************************************
331 Reads or writes an NET_R_LOGON_CTRL2 structure.
332 ********************************************************************/
334 bool net_io_r_logon_ctrl2(const char *desc, NET_R_LOGON_CTRL2 *r_l, prs_struct *ps, int depth)
336 if (r_l == NULL)
337 return False;
339 prs_debug(ps, depth, desc, "net_io_r_logon_ctrl2");
340 depth++;
342 if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value))
343 return False;
344 if(!prs_uint32("ptr ", ps, depth, &r_l->ptr))
345 return False;
347 if (r_l->ptr != 0) {
348 switch (r_l->switch_value) {
349 case 1:
350 if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth))
351 return False;
352 break;
353 case 2:
354 if(!net_io_netinfo_2("", &r_l->logon.info2, ps, depth))
355 return False;
356 break;
357 case 3:
358 if(!net_io_netinfo_3("", &r_l->logon.info3, ps, depth))
359 return False;
360 break;
361 default:
362 DEBUG(2,("net_io_r_logon_ctrl2: unsupported switch value %d\n",
363 r_l->switch_value));
364 break;
368 if(!prs_ntstatus("status ", ps, depth, &r_l->status))
369 return False;
371 return True;
374 /*******************************************************************
375 Reads or writes an NET_Q_LOGON_CTRL structure.
376 ********************************************************************/
378 bool net_io_q_logon_ctrl(const char *desc, NET_Q_LOGON_CTRL *q_l, prs_struct *ps,
379 int depth)
381 prs_debug(ps, depth, desc, "net_io_q_logon_ctrl");
382 depth++;
384 if(!prs_align(ps))
385 return False;
387 if(!prs_uint32("ptr ", ps, depth, &q_l->ptr))
388 return False;
390 if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth))
391 return False;
393 if(!prs_align(ps))
394 return False;
396 if(!prs_uint32("function_code", ps, depth, &q_l->function_code))
397 return False;
398 if(!prs_uint32("query_level ", ps, depth, &q_l->query_level))
399 return False;
401 return True;
404 /*******************************************************************
405 Inits an NET_Q_LOGON_CTRL structure.
406 ********************************************************************/
408 void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, const char *srv_name,
409 uint32 query_level)
411 DEBUG(5,("init_q_logon_ctrl\n"));
413 q_l->function_code = 0x01; /* ??? */
414 q_l->query_level = query_level;
416 init_unistr2(&q_l->uni_server_name, srv_name, UNI_STR_TERMINATE);
419 /*******************************************************************
420 Inits an NET_R_LOGON_CTRL structure.
421 ********************************************************************/
423 void init_net_r_logon_ctrl(NET_R_LOGON_CTRL *r_l, uint32 query_level,
424 uint32 flags, uint32 pdc_status)
426 DEBUG(5,("init_r_logon_ctrl\n"));
428 r_l->switch_value = query_level; /* should only be 0x1 */
430 switch (query_level) {
431 case 1:
432 r_l->ptr = 1; /* undocumented pointer */
433 init_netinfo_1(&r_l->logon.info1, flags, pdc_status);
434 r_l->status = NT_STATUS_OK;
435 break;
436 default:
437 DEBUG(2,("init_r_logon_ctrl: unsupported switch value %d\n",
438 r_l->switch_value));
439 r_l->ptr = 0; /* undocumented pointer */
441 /* take a guess at an error code... */
442 r_l->status = NT_STATUS_INVALID_INFO_CLASS;
443 break;
447 /*******************************************************************
448 Reads or writes an NET_R_LOGON_CTRL structure.
449 ********************************************************************/
451 bool net_io_r_logon_ctrl(const char *desc, NET_R_LOGON_CTRL *r_l, prs_struct *ps,
452 int depth)
454 prs_debug(ps, depth, desc, "net_io_r_logon_ctrl");
455 depth++;
457 if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value))
458 return False;
459 if(!prs_uint32("ptr ", ps, depth, &r_l->ptr))
460 return False;
462 if (r_l->ptr != 0) {
463 switch (r_l->switch_value) {
464 case 1:
465 if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth))
466 return False;
467 break;
468 default:
469 DEBUG(2,("net_io_r_logon_ctrl: unsupported switch value %d\n",
470 r_l->switch_value));
471 break;
475 if(!prs_ntstatus("status ", ps, depth, &r_l->status))
476 return False;
478 return True;
481 /*******************************************************************
482 Inits an NET_R_GETANYDCNAME structure.
483 ********************************************************************/
484 void init_net_q_getanydcname(NET_Q_GETANYDCNAME *r_t, const char *logon_server,
485 const char *domainname)
487 DEBUG(5,("init_q_getanydcname\n"));
489 r_t->ptr_logon_server = (logon_server != NULL);
490 init_unistr2(&r_t->uni_logon_server, logon_server, UNI_STR_TERMINATE);
491 r_t->ptr_domainname = (domainname != NULL);
492 init_unistr2(&r_t->uni_domainname, domainname, UNI_STR_TERMINATE);
495 /*******************************************************************
496 Reads or writes an NET_Q_GETANYDCNAME structure.
497 ********************************************************************/
499 bool net_io_q_getanydcname(const char *desc, NET_Q_GETANYDCNAME *r_t, prs_struct *ps,
500 int depth)
502 if (r_t == NULL)
503 return False;
505 prs_debug(ps, depth, desc, "net_io_q_getanydcname");
506 depth++;
508 if (!prs_uint32("ptr_logon_server", ps, depth, &r_t->ptr_logon_server))
509 return False;
511 if (!smb_io_unistr2("logon_server", &r_t->uni_logon_server,
512 r_t->ptr_logon_server, ps, depth))
513 return False;
515 if (!prs_align(ps))
516 return False;
518 if (!prs_uint32("ptr_domainname", ps, depth, &r_t->ptr_domainname))
519 return False;
521 if (!smb_io_unistr2("domainname", &r_t->uni_domainname,
522 r_t->ptr_domainname, ps, depth))
523 return False;
525 return True;
529 /*******************************************************************
530 Inits an NET_R_GETANYDCNAME structure.
531 ********************************************************************/
532 void init_net_r_getanydcname(NET_R_GETANYDCNAME *r_t, const char *dcname)
534 DEBUG(5,("init_r_getanydcname\n"));
536 init_unistr2(&r_t->uni_dcname, dcname, UNI_STR_TERMINATE);
539 /*******************************************************************
540 Reads or writes an NET_R_GETANYDCNAME structure.
541 ********************************************************************/
543 bool net_io_r_getanydcname(const char *desc, NET_R_GETANYDCNAME *r_t, prs_struct *ps,
544 int depth)
546 if (r_t == NULL)
547 return False;
549 prs_debug(ps, depth, desc, "net_io_r_getanydcname");
550 depth++;
552 if (!prs_uint32("ptr_dcname", ps, depth, &r_t->ptr_dcname))
553 return False;
555 if (!smb_io_unistr2("dcname", &r_t->uni_dcname,
556 r_t->ptr_dcname, ps, depth))
557 return False;
559 if (!prs_align(ps))
560 return False;
562 if (!prs_werror("status", ps, depth, &r_t->status))
563 return False;
565 return True;
569 /*******************************************************************
570 Inits an NET_R_GETDCNAME structure.
571 ********************************************************************/
572 void init_net_q_getdcname(NET_Q_GETDCNAME *r_t, const char *logon_server,
573 const char *domainname)
575 DEBUG(5,("init_q_getdcname\n"));
577 init_unistr2(&r_t->uni_logon_server, logon_server, UNI_STR_TERMINATE);
578 r_t->ptr_domainname = (domainname != NULL);
579 init_unistr2(&r_t->uni_domainname, domainname, UNI_STR_TERMINATE);
582 /*******************************************************************
583 Reads or writes an NET_Q_GETDCNAME structure.
584 ********************************************************************/
586 bool net_io_q_getdcname(const char *desc, NET_Q_GETDCNAME *r_t, prs_struct *ps,
587 int depth)
589 if (r_t == NULL)
590 return False;
592 prs_debug(ps, depth, desc, "net_io_q_getdcname");
593 depth++;
595 if (!smb_io_unistr2("logon_server", &r_t->uni_logon_server,
596 1, ps, depth))
597 return False;
599 if (!prs_align(ps))
600 return False;
602 if (!prs_uint32("ptr_domainname", ps, depth, &r_t->ptr_domainname))
603 return False;
605 if (!smb_io_unistr2("domainname", &r_t->uni_domainname,
606 r_t->ptr_domainname, ps, depth))
607 return False;
609 return True;
613 /*******************************************************************
614 Inits an NET_R_GETDCNAME structure.
615 ********************************************************************/
616 void init_net_r_getdcname(NET_R_GETDCNAME *r_t, const char *dcname)
618 DEBUG(5,("init_r_getdcname\n"));
620 init_unistr2(&r_t->uni_dcname, dcname, UNI_STR_TERMINATE);
623 /*******************************************************************
624 Reads or writes an NET_R_GETDCNAME structure.
625 ********************************************************************/
627 bool net_io_r_getdcname(const char *desc, NET_R_GETDCNAME *r_t, prs_struct *ps,
628 int depth)
630 if (r_t == NULL)
631 return False;
633 prs_debug(ps, depth, desc, "net_io_r_getdcname");
634 depth++;
636 if (!prs_uint32("ptr_dcname", ps, depth, &r_t->ptr_dcname))
637 return False;
639 if (!smb_io_unistr2("dcname", &r_t->uni_dcname,
640 r_t->ptr_dcname, ps, depth))
641 return False;
643 if (!prs_align(ps))
644 return False;
646 if (!prs_werror("status", ps, depth, &r_t->status))
647 return False;
649 return True;
652 /*******************************************************************
653 Inits an NET_R_TRUST_DOM_LIST structure.
654 ********************************************************************/
656 void init_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t,
657 uint32 num_doms, const char *dom_name)
659 unsigned int i = 0;
661 DEBUG(5,("init_r_trust_dom\n"));
663 for (i = 0; i < MAX_TRUST_DOMS; i++) {
664 r_t->uni_trust_dom_name[i].uni_str_len = 0;
665 r_t->uni_trust_dom_name[i].uni_max_len = 0;
667 if (num_doms > MAX_TRUST_DOMS)
668 num_doms = MAX_TRUST_DOMS;
670 for (i = 0; i < num_doms; i++) {
671 fstring domain_name;
672 fstrcpy(domain_name, dom_name);
673 strupper_m(domain_name);
674 init_unistr2(&r_t->uni_trust_dom_name[i], domain_name, UNI_STR_TERMINATE);
675 /* the use of UNISTR2 here is non-standard. */
676 r_t->uni_trust_dom_name[i].offset = 0x1;
679 r_t->status = NT_STATUS_OK;
682 /*******************************************************************
683 Reads or writes an NET_R_TRUST_DOM_LIST structure.
684 ********************************************************************/
686 bool net_io_r_trust_dom(const char *desc, NET_R_TRUST_DOM_LIST *r_t, prs_struct *ps, int depth)
688 uint32 value;
690 if (r_t == NULL)
691 return False;
693 prs_debug(ps, depth, desc, "net_io_r_trust_dom");
694 depth++;
696 /* temporary code to give a valid response */
697 value=2;
698 if(!prs_uint32("status", ps, depth, &value))
699 return False;
701 value=1;
702 if(!prs_uint32("status", ps, depth, &value))
703 return False;
704 value=2;
705 if(!prs_uint32("status", ps, depth, &value))
706 return False;
708 value=0;
709 if(!prs_uint32("status", ps, depth, &value))
710 return False;
712 value=0;
713 if(!prs_uint32("status", ps, depth, &value))
714 return False;
716 /* old non working code */
717 #if 0
718 int i;
720 for (i = 0; i < MAX_TRUST_DOMS; i++) {
721 if (r_t->uni_trust_dom_name[i].uni_str_len == 0)
722 break;
723 if(!smb_io_unistr2("", &r_t->uni_trust_dom_name[i], True, ps, depth))
724 return False;
727 if(!prs_ntstatus("status", ps, depth, &r_t->status))
728 return False;
729 #endif
730 return True;
734 /*******************************************************************
735 Reads or writes an NET_Q_TRUST_DOM_LIST structure.
736 ********************************************************************/
738 bool net_io_q_trust_dom(const char *desc, NET_Q_TRUST_DOM_LIST *q_l, prs_struct *ps, int depth)
740 if (q_l == NULL)
741 return False;
743 prs_debug(ps, depth, desc, "net_io_q_trust_dom");
744 depth++;
746 if(!prs_uint32("ptr ", ps, depth, &q_l->ptr))
747 return False;
748 if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth))
749 return False;
751 return True;
754 /*******************************************************************
755 Inits an NET_Q_REQ_CHAL structure.
756 ********************************************************************/
758 void init_q_req_chal(NET_Q_REQ_CHAL *q_c,
759 const char *logon_srv, const char *logon_clnt,
760 const DOM_CHAL *clnt_chal)
762 DEBUG(5,("init_q_req_chal: %d\n", __LINE__));
764 q_c->undoc_buffer = 1; /* don't know what this buffer is */
766 init_unistr2(&q_c->uni_logon_srv, logon_srv , UNI_STR_TERMINATE);
767 init_unistr2(&q_c->uni_logon_clnt, logon_clnt, UNI_STR_TERMINATE);
769 memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
771 DEBUG(5,("init_q_req_chal: %d\n", __LINE__));
774 /*******************************************************************
775 Reads or writes an NET_Q_REQ_CHAL structure.
776 ********************************************************************/
778 bool net_io_q_req_chal(const char *desc, NET_Q_REQ_CHAL *q_c, prs_struct *ps, int depth)
780 if (q_c == NULL)
781 return False;
783 prs_debug(ps, depth, desc, "net_io_q_req_chal");
784 depth++;
786 if(!prs_align(ps))
787 return False;
789 if(!prs_uint32("undoc_buffer", ps, depth, &q_c->undoc_buffer))
790 return False;
792 if(!smb_io_unistr2("", &q_c->uni_logon_srv, True, ps, depth)) /* logon server unicode string */
793 return False;
794 if(!smb_io_unistr2("", &q_c->uni_logon_clnt, True, ps, depth)) /* logon client unicode string */
795 return False;
797 if(!smb_io_chal("", &q_c->clnt_chal, ps, depth))
798 return False;
800 return True;
803 /*******************************************************************
804 Reads or writes a structure.
805 ********************************************************************/
807 bool net_io_r_req_chal(const char *desc, NET_R_REQ_CHAL *r_c, prs_struct *ps, int depth)
809 if (r_c == NULL)
810 return False;
812 prs_debug(ps, depth, desc, "net_io_r_req_chal");
813 depth++;
815 if(!prs_align(ps))
816 return False;
818 if(!smb_io_chal("", &r_c->srv_chal, ps, depth)) /* server challenge */
819 return False;
821 if(!prs_ntstatus("status", ps, depth, &r_c->status))
822 return False;
824 return True;
828 /*******************************************************************
829 Reads or writes a structure.
830 ********************************************************************/
832 bool net_io_q_auth(const char *desc, NET_Q_AUTH *q_a, prs_struct *ps, int depth)
834 if (q_a == NULL)
835 return False;
837 prs_debug(ps, depth, desc, "net_io_q_auth");
838 depth++;
840 if(!prs_align(ps))
841 return False;
843 if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */
844 return False;
845 if(!smb_io_chal("", &q_a->clnt_chal, ps, depth))
846 return False;
848 return True;
851 /*******************************************************************
852 Reads or writes a structure.
853 ********************************************************************/
855 bool net_io_r_auth(const char *desc, NET_R_AUTH *r_a, prs_struct *ps, int depth)
857 if (r_a == NULL)
858 return False;
860 prs_debug(ps, depth, desc, "net_io_r_auth");
861 depth++;
863 if(!prs_align(ps))
864 return False;
866 if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */
867 return False;
869 if(!prs_ntstatus("status", ps, depth, &r_a->status))
870 return False;
872 return True;
875 /*******************************************************************
876 Inits a NET_Q_AUTH_2 struct.
877 ********************************************************************/
879 void init_q_auth_2(NET_Q_AUTH_2 *q_a,
880 const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name,
881 const DOM_CHAL *clnt_chal, uint32 clnt_flgs)
883 DEBUG(5,("init_q_auth_2: %d\n", __LINE__));
885 init_log_info(&q_a->clnt_id, logon_srv, acct_name, sec_chan, comp_name);
886 memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
887 q_a->clnt_flgs.neg_flags = clnt_flgs;
889 DEBUG(5,("init_q_auth_2: %d\n", __LINE__));
892 /*******************************************************************
893 Reads or writes a structure.
894 ********************************************************************/
896 bool net_io_q_auth_2(const char *desc, NET_Q_AUTH_2 *q_a, prs_struct *ps, int depth)
898 if (q_a == NULL)
899 return False;
901 prs_debug(ps, depth, desc, "net_io_q_auth_2");
902 depth++;
904 if(!prs_align(ps))
905 return False;
907 if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */
908 return False;
909 if(!smb_io_chal("", &q_a->clnt_chal, ps, depth))
910 return False;
911 if(!net_io_neg_flags("", &q_a->clnt_flgs, ps, depth))
912 return False;
914 return True;
917 /*******************************************************************
918 Reads or writes a structure.
919 ********************************************************************/
921 bool net_io_r_auth_2(const char *desc, NET_R_AUTH_2 *r_a, prs_struct *ps, int depth)
923 if (r_a == NULL)
924 return False;
926 prs_debug(ps, depth, desc, "net_io_r_auth_2");
927 depth++;
929 if(!prs_align(ps))
930 return False;
932 if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */
933 return False;
934 if(!net_io_neg_flags("", &r_a->srv_flgs, ps, depth))
935 return False;
937 if(!prs_ntstatus("status", ps, depth, &r_a->status))
938 return False;
940 return True;
943 /*******************************************************************
944 Inits a NET_Q_AUTH_3 struct.
945 ********************************************************************/
947 void init_q_auth_3(NET_Q_AUTH_3 *q_a,
948 const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name,
949 const DOM_CHAL *clnt_chal, uint32 clnt_flgs)
951 DEBUG(5,("init_q_auth_3: %d\n", __LINE__));
953 init_log_info(&q_a->clnt_id, logon_srv, acct_name, sec_chan, comp_name);
954 memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
955 q_a->clnt_flgs.neg_flags = clnt_flgs;
957 DEBUG(5,("init_q_auth_3: %d\n", __LINE__));
960 /*******************************************************************
961 Reads or writes a structure.
962 ********************************************************************/
964 bool net_io_q_auth_3(const char *desc, NET_Q_AUTH_3 *q_a, prs_struct *ps, int depth)
966 if (q_a == NULL)
967 return False;
969 prs_debug(ps, depth, desc, "net_io_q_auth_3");
970 depth++;
972 if(!prs_align(ps))
973 return False;
975 if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */
976 return False;
977 if(!smb_io_chal("", &q_a->clnt_chal, ps, depth))
978 return False;
979 if(!net_io_neg_flags("", &q_a->clnt_flgs, ps, depth))
980 return False;
982 return True;
985 /*******************************************************************
986 Reads or writes a structure.
987 ********************************************************************/
989 bool net_io_r_auth_3(const char *desc, NET_R_AUTH_3 *r_a, prs_struct *ps, int depth)
991 if (r_a == NULL)
992 return False;
994 prs_debug(ps, depth, desc, "net_io_r_auth_3");
995 depth++;
997 if(!prs_align(ps))
998 return False;
1000 if(!smb_io_chal("srv_chal", &r_a->srv_chal, ps, depth)) /* server challenge */
1001 return False;
1002 if(!net_io_neg_flags("srv_flgs", &r_a->srv_flgs, ps, depth))
1003 return False;
1004 if (!prs_uint32("unknown", ps, depth, &r_a->unknown))
1005 return False;
1007 if(!prs_ntstatus("status", ps, depth, &r_a->status))
1008 return False;
1010 return True;
1014 /*******************************************************************
1015 Inits a NET_Q_SRV_PWSET.
1016 ********************************************************************/
1018 void init_q_srv_pwset(NET_Q_SRV_PWSET *q_s,
1019 const char *logon_srv, const char *sess_key, const char *acct_name,
1020 uint16 sec_chan, const char *comp_name,
1021 DOM_CRED *cred, const uchar hashed_mach_pwd[16])
1023 unsigned char nt_cypher[16];
1025 DEBUG(5,("init_q_srv_pwset\n"));
1027 /* Process the new password. */
1028 cred_hash3( nt_cypher, hashed_mach_pwd, (const unsigned char *)sess_key, 1);
1030 init_clnt_info(&q_s->clnt_id, logon_srv, acct_name, sec_chan, comp_name, cred);
1032 memcpy(q_s->pwd, nt_cypher, sizeof(q_s->pwd));
1035 /*******************************************************************
1036 Reads or writes a structure.
1037 ********************************************************************/
1039 bool net_io_q_srv_pwset(const char *desc, NET_Q_SRV_PWSET *q_s, prs_struct *ps, int depth)
1041 if (q_s == NULL)
1042 return False;
1044 prs_debug(ps, depth, desc, "net_io_q_srv_pwset");
1045 depth++;
1047 if(!prs_align(ps))
1048 return False;
1050 if(!smb_io_clnt_info("", &q_s->clnt_id, ps, depth)) /* client identification/authentication info */
1051 return False;
1052 if(!prs_uint8s (False, "pwd", ps, depth, q_s->pwd, 16)) /* new password - undocumented */
1053 return False;
1055 return True;
1058 /*******************************************************************
1059 Reads or writes a structure.
1060 ********************************************************************/
1062 bool net_io_r_srv_pwset(const char *desc, NET_R_SRV_PWSET *r_s, prs_struct *ps, int depth)
1064 if (r_s == NULL)
1065 return False;
1067 prs_debug(ps, depth, desc, "net_io_r_srv_pwset");
1068 depth++;
1070 if(!prs_align(ps))
1071 return False;
1073 if(!smb_io_cred("", &r_s->srv_cred, ps, depth)) /* server challenge */
1074 return False;
1076 if(!prs_ntstatus("status", ps, depth, &r_s->status))
1077 return False;
1079 return True;
1082 /*************************************************************************
1083 Init DOM_SID2 array from a string containing multiple sids
1084 *************************************************************************/
1086 static int init_dom_sid2s(TALLOC_CTX *ctx, const char *sids_str, DOM_SID2 **ppsids)
1088 const char *ptr;
1089 char *s2;
1090 int count = 0;
1092 DEBUG(4,("init_dom_sid2s: %s\n", sids_str ? sids_str:""));
1094 *ppsids = NULL;
1096 if(sids_str) {
1097 int number;
1098 DOM_SID2 *sids;
1099 TALLOC_CTX *frame = talloc_stackframe();
1101 /* Count the number of valid SIDs. */
1102 for (count = 0, ptr = sids_str;
1103 next_token_talloc(frame,&ptr, &s2, NULL); ) {
1104 DOM_SID tmpsid;
1105 if (string_to_sid(&tmpsid, s2))
1106 count++;
1109 /* Now allocate space for them. */
1110 if (count) {
1111 *ppsids = TALLOC_ZERO_ARRAY(ctx, DOM_SID2, count);
1112 if (*ppsids == NULL) {
1113 TALLOC_FREE(frame);
1114 return 0;
1116 } else {
1117 *ppsids = NULL;
1120 sids = *ppsids;
1122 for (number = 0, ptr = sids_str;
1123 next_token_talloc(frame, &ptr, &s2, NULL); ) {
1124 DOM_SID tmpsid;
1125 if (string_to_sid(&tmpsid, s2)) {
1126 /* count only valid sids */
1127 init_dom_sid2(&sids[number], &tmpsid);
1128 number++;
1131 TALLOC_FREE(frame);
1134 return count;
1137 /*******************************************************************
1138 Inits a NET_ID_INFO_1 structure.
1139 ********************************************************************/
1141 void init_id_info1(NET_ID_INFO_1 *id, const char *domain_name,
1142 uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
1143 const char *user_name, const char *wksta_name,
1144 const char *sess_key,
1145 unsigned char lm_cypher[16], unsigned char nt_cypher[16])
1147 unsigned char lm_owf[16];
1148 unsigned char nt_owf[16];
1150 DEBUG(5,("init_id_info1: %d\n", __LINE__));
1152 id->ptr_id_info1 = 1;
1154 id->param_ctrl = param_ctrl;
1155 init_logon_id(&id->logon_id, log_id_low, log_id_high);
1158 if (lm_cypher && nt_cypher) {
1159 unsigned char key[16];
1160 #ifdef DEBUG_PASSWORD
1161 DEBUG(100,("lm cypher:"));
1162 dump_data(100, lm_cypher, 16);
1164 DEBUG(100,("nt cypher:"));
1165 dump_data(100, nt_cypher, 16);
1166 #endif
1168 memset(key, 0, 16);
1169 memcpy(key, sess_key, 8);
1171 memcpy(lm_owf, lm_cypher, 16);
1172 SamOEMhash(lm_owf, key, 16);
1173 memcpy(nt_owf, nt_cypher, 16);
1174 SamOEMhash(nt_owf, key, 16);
1176 #ifdef DEBUG_PASSWORD
1177 DEBUG(100,("encrypt of lm owf password:"));
1178 dump_data(100, lm_owf, 16);
1180 DEBUG(100,("encrypt of nt owf password:"));
1181 dump_data(100, nt_owf, 16);
1182 #endif
1183 /* set up pointers to cypher blocks */
1184 lm_cypher = lm_owf;
1185 nt_cypher = nt_owf;
1188 init_owf_info(&id->lm_owf, lm_cypher);
1189 init_owf_info(&id->nt_owf, nt_cypher);
1191 init_unistr2(&id->uni_domain_name, domain_name, UNI_FLAGS_NONE);
1192 init_uni_hdr(&id->hdr_domain_name, &id->uni_domain_name);
1193 init_unistr2(&id->uni_user_name, user_name, UNI_FLAGS_NONE);
1194 init_uni_hdr(&id->hdr_user_name, &id->uni_user_name);
1195 init_unistr2(&id->uni_wksta_name, wksta_name, UNI_FLAGS_NONE);
1196 init_uni_hdr(&id->hdr_wksta_name, &id->uni_wksta_name);
1199 /*******************************************************************
1200 Reads or writes an NET_ID_INFO_1 structure.
1201 ********************************************************************/
1203 static bool net_io_id_info1(const char *desc, NET_ID_INFO_1 *id, prs_struct *ps, int depth)
1205 if (id == NULL)
1206 return False;
1208 prs_debug(ps, depth, desc, "net_io_id_info1");
1209 depth++;
1211 if(!prs_align(ps))
1212 return False;
1214 if(!prs_uint32("ptr_id_info1", ps, depth, &id->ptr_id_info1))
1215 return False;
1217 if (id->ptr_id_info1 != 0) {
1218 if(!smb_io_unihdr("unihdr", &id->hdr_domain_name, ps, depth))
1219 return False;
1221 if(!prs_uint32("param_ctrl", ps, depth, &id->param_ctrl))
1222 return False;
1223 if(!smb_io_logon_id("", &id->logon_id, ps, depth))
1224 return False;
1226 if(!smb_io_unihdr("unihdr", &id->hdr_user_name, ps, depth))
1227 return False;
1228 if(!smb_io_unihdr("unihdr", &id->hdr_wksta_name, ps, depth))
1229 return False;
1231 if(!smb_io_owf_info("", &id->lm_owf, ps, depth))
1232 return False;
1233 if(!smb_io_owf_info("", &id->nt_owf, ps, depth))
1234 return False;
1236 if(!smb_io_unistr2("unistr2", &id->uni_domain_name,
1237 id->hdr_domain_name.buffer, ps, depth))
1238 return False;
1239 if(!smb_io_unistr2("unistr2", &id->uni_user_name,
1240 id->hdr_user_name.buffer, ps, depth))
1241 return False;
1242 if(!smb_io_unistr2("unistr2", &id->uni_wksta_name,
1243 id->hdr_wksta_name.buffer, ps, depth))
1244 return False;
1247 return True;
1250 /*******************************************************************
1251 Inits a NET_ID_INFO_2 structure.
1253 This is a network logon packet. The log_id parameters
1254 are what an NT server would generate for LUID once the
1255 user is logged on. I don't think we care about them.
1257 Note that this has no access to the NT and LM hashed passwords,
1258 so it forwards the challenge, and the NT and LM responses (24
1259 bytes each) over the secure channel to the Domain controller
1260 for it to say yea or nay. This is the preferred method of
1261 checking for a logon as it doesn't export the password
1262 hashes to anyone who has compromised the secure channel. JRA.
1263 ********************************************************************/
1265 void init_id_info2(NET_ID_INFO_2 * id, const char *domain_name,
1266 uint32 param_ctrl,
1267 uint32 log_id_low, uint32 log_id_high,
1268 const char *user_name, const char *wksta_name,
1269 const uchar lm_challenge[8],
1270 const uchar * lm_chal_resp, size_t lm_chal_resp_len,
1271 const uchar * nt_chal_resp, size_t nt_chal_resp_len)
1274 DEBUG(5,("init_id_info2: %d\n", __LINE__));
1276 id->ptr_id_info2 = 1;
1278 id->param_ctrl = param_ctrl;
1279 init_logon_id(&id->logon_id, log_id_low, log_id_high);
1281 memcpy(id->lm_chal, lm_challenge, sizeof(id->lm_chal));
1282 init_str_hdr(&id->hdr_nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len, (nt_chal_resp != NULL) ? 1 : 0);
1283 init_str_hdr(&id->hdr_lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len, (lm_chal_resp != NULL) ? 1 : 0);
1285 init_unistr2(&id->uni_domain_name, domain_name, UNI_FLAGS_NONE);
1286 init_uni_hdr(&id->hdr_domain_name, &id->uni_domain_name);
1287 init_unistr2(&id->uni_user_name, user_name, UNI_FLAGS_NONE);
1288 init_uni_hdr(&id->hdr_user_name, &id->uni_user_name);
1289 init_unistr2(&id->uni_wksta_name, wksta_name, UNI_FLAGS_NONE);
1290 init_uni_hdr(&id->hdr_wksta_name, &id->uni_wksta_name);
1292 init_string2(&id->nt_chal_resp, (const char *)nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len);
1293 init_string2(&id->lm_chal_resp, (const char *)lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len);
1297 /*******************************************************************
1298 Reads or writes an NET_ID_INFO_2 structure.
1299 ********************************************************************/
1301 static bool net_io_id_info2(const char *desc, NET_ID_INFO_2 *id, prs_struct *ps, int depth)
1303 if (id == NULL)
1304 return False;
1306 prs_debug(ps, depth, desc, "net_io_id_info2");
1307 depth++;
1309 if(!prs_align(ps))
1310 return False;
1312 if(!prs_uint32("ptr_id_info2", ps, depth, &id->ptr_id_info2))
1313 return False;
1315 if (id->ptr_id_info2 != 0) {
1316 if(!smb_io_unihdr("unihdr", &id->hdr_domain_name, ps, depth))
1317 return False;
1319 if(!prs_uint32("param_ctrl", ps, depth, &id->param_ctrl))
1320 return False;
1321 if(!smb_io_logon_id("", &id->logon_id, ps, depth))
1322 return False;
1324 if(!smb_io_unihdr("unihdr", &id->hdr_user_name, ps, depth))
1325 return False;
1326 if(!smb_io_unihdr("unihdr", &id->hdr_wksta_name, ps, depth))
1327 return False;
1329 if(!prs_uint8s (False, "lm_chal", ps, depth, id->lm_chal, 8)) /* lm 8 byte challenge */
1330 return False;
1332 if(!smb_io_strhdr("hdr_nt_chal_resp", &id->hdr_nt_chal_resp, ps, depth))
1333 return False;
1334 if(!smb_io_strhdr("hdr_lm_chal_resp", &id->hdr_lm_chal_resp, ps, depth))
1335 return False;
1337 if(!smb_io_unistr2("uni_domain_name", &id->uni_domain_name,
1338 id->hdr_domain_name.buffer, ps, depth))
1339 return False;
1340 if(!smb_io_unistr2("uni_user_name ", &id->uni_user_name,
1341 id->hdr_user_name.buffer, ps, depth))
1342 return False;
1343 if(!smb_io_unistr2("uni_wksta_name ", &id->uni_wksta_name,
1344 id->hdr_wksta_name.buffer, ps, depth))
1345 return False;
1346 if(!smb_io_string2("nt_chal_resp", &id->nt_chal_resp,
1347 id->hdr_nt_chal_resp.buffer, ps, depth))
1348 return False;
1349 if(!smb_io_string2("lm_chal_resp", &id->lm_chal_resp,
1350 id->hdr_lm_chal_resp.buffer, ps, depth))
1351 return False;
1354 return True;
1358 /*******************************************************************
1359 Inits a DOM_SAM_INFO structure.
1360 ********************************************************************/
1362 void init_sam_info(DOM_SAM_INFO *sam,
1363 const char *logon_srv, const char *comp_name,
1364 DOM_CRED *clnt_cred,
1365 DOM_CRED *rtn_cred, uint16 logon_level,
1366 NET_ID_INFO_CTR *ctr)
1368 DEBUG(5,("init_sam_info: %d\n", __LINE__));
1370 init_clnt_info2(&sam->client, logon_srv, comp_name, clnt_cred);
1372 if (rtn_cred != NULL) {
1373 sam->ptr_rtn_cred = 1;
1374 memcpy(&sam->rtn_cred, rtn_cred, sizeof(sam->rtn_cred));
1375 } else {
1376 sam->ptr_rtn_cred = 0;
1379 sam->logon_level = logon_level;
1380 sam->ctr = ctr;
1383 /*******************************************************************
1384 Inits a DOM_SAM_INFO structure.
1385 ********************************************************************/
1387 void init_sam_info_ex(DOM_SAM_INFO_EX *sam,
1388 const char *logon_srv, const char *comp_name,
1389 uint16 logon_level, NET_ID_INFO_CTR *ctr)
1391 DEBUG(5,("init_sam_info_ex: %d\n", __LINE__));
1393 init_clnt_srv(&sam->client, logon_srv, comp_name);
1394 sam->logon_level = logon_level;
1395 sam->ctr = ctr;
1398 /*******************************************************************
1399 Reads or writes a DOM_SAM_INFO structure.
1400 ********************************************************************/
1402 static bool net_io_id_info_ctr(const char *desc, NET_ID_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1404 NET_ID_INFO_CTR *ctr = *pp_ctr;
1406 prs_debug(ps, depth, desc, "smb_io_sam_info_ctr");
1407 depth++;
1409 if (UNMARSHALLING(ps)) {
1410 ctr = *pp_ctr = PRS_ALLOC_MEM(ps, NET_ID_INFO_CTR, 1);
1411 if (ctr == NULL)
1412 return False;
1415 if (ctr == NULL)
1416 return False;
1418 /* don't 4-byte align here! */
1420 if(!prs_uint16("switch_value ", ps, depth, &ctr->switch_value))
1421 return False;
1423 switch (ctr->switch_value) {
1424 case 1:
1425 if(!net_io_id_info1("", &ctr->auth.id1, ps, depth))
1426 return False;
1427 break;
1428 case 2:
1429 if(!net_io_id_info2("", &ctr->auth.id2, ps, depth))
1430 return False;
1431 break;
1432 default:
1433 /* PANIC! */
1434 DEBUG(4,("smb_io_sam_info_ctr: unknown switch_value!\n"));
1435 break;
1438 return True;
1441 /*******************************************************************
1442 Reads or writes a DOM_SAM_INFO structure.
1443 ********************************************************************/
1445 static bool smb_io_sam_info(const char *desc, DOM_SAM_INFO *sam, prs_struct *ps, int depth)
1447 if (sam == NULL)
1448 return False;
1450 prs_debug(ps, depth, desc, "smb_io_sam_info");
1451 depth++;
1453 if(!prs_align(ps))
1454 return False;
1456 if(!smb_io_clnt_info2("", &sam->client, ps, depth))
1457 return False;
1459 if(!prs_uint32("ptr_rtn_cred ", ps, depth, &sam->ptr_rtn_cred))
1460 return False;
1461 if (sam->ptr_rtn_cred) {
1462 if(!smb_io_cred("", &sam->rtn_cred, ps, depth))
1463 return False;
1466 if(!prs_uint16("logon_level ", ps, depth, &sam->logon_level))
1467 return False;
1469 if (sam->logon_level != 0) {
1470 if(!net_io_id_info_ctr("logon_info", &sam->ctr, ps, depth))
1471 return False;
1474 return True;
1477 /*******************************************************************
1478 Reads or writes a DOM_SAM_INFO_EX structure.
1479 ********************************************************************/
1481 static bool smb_io_sam_info_ex(const char *desc, DOM_SAM_INFO_EX *sam, prs_struct *ps, int depth)
1483 if (sam == NULL)
1484 return False;
1486 prs_debug(ps, depth, desc, "smb_io_sam_info_ex");
1487 depth++;
1489 if(!prs_align(ps))
1490 return False;
1492 if(!smb_io_clnt_srv("", &sam->client, ps, depth))
1493 return False;
1495 if(!prs_uint16("logon_level ", ps, depth, &sam->logon_level))
1496 return False;
1498 if (sam->logon_level != 0) {
1499 if(!net_io_id_info_ctr("logon_info", &sam->ctr, ps, depth))
1500 return False;
1503 return True;
1506 /*************************************************************************
1507 Inits a NET_USER_INFO_3 structure.
1509 This is a network logon reply packet, and contains much information about
1510 the user. This information is passed as a (very long) paramater list
1511 to avoid having to link in the PASSDB code to every program that deals
1512 with this file.
1513 *************************************************************************/
1515 void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr,
1516 uint32 user_rid,
1517 uint32 group_rid,
1519 const char* user_name,
1520 const char* full_name,
1521 const char* home_dir,
1522 const char* dir_drive,
1523 const char* logon_script,
1524 const char* profile_path,
1526 time_t unix_logon_time,
1527 time_t unix_logoff_time,
1528 time_t unix_kickoff_time,
1529 time_t unix_pass_last_set_time,
1530 time_t unix_pass_can_change_time,
1531 time_t unix_pass_must_change_time,
1533 uint16 logon_count, uint16 bad_pw_count,
1534 uint32 num_groups, const DOM_GID *gids,
1535 uint32 user_flgs, uint32 acct_flags,
1536 uchar user_session_key[16],
1537 uchar lm_session_key[16],
1538 const char *logon_srv, const char *logon_dom,
1539 const DOM_SID *dom_sid)
1541 /* only cope with one "other" sid, right now. */
1542 /* need to count the number of space-delimited sids */
1543 unsigned int i;
1544 int num_other_sids = 0;
1546 NTTIME logon_time, logoff_time, kickoff_time,
1547 pass_last_set_time, pass_can_change_time,
1548 pass_must_change_time;
1550 ZERO_STRUCTP(usr);
1552 usr->ptr_user_info = 1; /* yes, we're bothering to put USER_INFO data here */
1554 /* Create NTTIME structs */
1555 unix_to_nt_time (&logon_time, unix_logon_time);
1556 unix_to_nt_time (&logoff_time, unix_logoff_time);
1557 unix_to_nt_time (&kickoff_time, unix_kickoff_time);
1558 unix_to_nt_time (&pass_last_set_time, unix_pass_last_set_time);
1559 unix_to_nt_time (&pass_can_change_time, unix_pass_can_change_time);
1560 unix_to_nt_time (&pass_must_change_time, unix_pass_must_change_time);
1562 usr->logon_time = logon_time;
1563 usr->logoff_time = logoff_time;
1564 usr->kickoff_time = kickoff_time;
1565 usr->pass_last_set_time = pass_last_set_time;
1566 usr->pass_can_change_time = pass_can_change_time;
1567 usr->pass_must_change_time = pass_must_change_time;
1569 usr->logon_count = logon_count;
1570 usr->bad_pw_count = bad_pw_count;
1572 usr->user_rid = user_rid;
1573 usr->group_rid = group_rid;
1574 usr->num_groups = num_groups;
1576 usr->buffer_groups = 1; /* indicates fill in groups, below, even if there are none */
1577 usr->user_flgs = user_flgs;
1578 usr->acct_flags = acct_flags;
1580 if (user_session_key != NULL)
1581 memcpy(usr->user_sess_key, user_session_key, sizeof(usr->user_sess_key));
1582 else
1583 memset((char *)usr->user_sess_key, '\0', sizeof(usr->user_sess_key));
1585 usr->buffer_dom_id = dom_sid ? 1 : 0; /* yes, we're bothering to put a domain SID in */
1587 memset((char *)usr->lm_sess_key, '\0', sizeof(usr->lm_sess_key));
1589 for (i=0; i<7; i++) {
1590 memset(&usr->unknown[i], '\0', sizeof(usr->unknown));
1593 if (lm_session_key != NULL) {
1594 memcpy(usr->lm_sess_key, lm_session_key, sizeof(usr->lm_sess_key));
1597 num_other_sids = init_dom_sid2s(ctx, NULL, &usr->other_sids);
1599 usr->num_other_sids = num_other_sids;
1600 usr->buffer_other_sids = (num_other_sids != 0) ? 1 : 0;
1602 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
1603 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
1604 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
1605 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
1606 init_unistr2(&usr->uni_logon_script, logon_script, UNI_FLAGS_NONE);
1607 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
1608 init_unistr2(&usr->uni_profile_path, profile_path, UNI_FLAGS_NONE);
1609 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
1610 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
1611 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
1612 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
1613 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
1615 usr->num_groups2 = num_groups;
1617 if (num_groups) {
1618 usr->gids = TALLOC_ZERO_ARRAY(ctx,DOM_GID,num_groups);
1619 if (usr->gids == NULL)
1620 return;
1621 } else {
1622 usr->gids = NULL;
1625 for (i = 0; i < num_groups; i++)
1626 usr->gids[i] = gids[i];
1628 init_unistr2(&usr->uni_logon_srv, logon_srv, UNI_FLAGS_NONE);
1629 init_uni_hdr(&usr->hdr_logon_srv, &usr->uni_logon_srv);
1630 init_unistr2(&usr->uni_logon_dom, logon_dom, UNI_FLAGS_NONE);
1631 init_uni_hdr(&usr->hdr_logon_dom, &usr->uni_logon_dom);
1633 init_dom_sid2(&usr->dom_sid, dom_sid);
1634 /* "other" sids are set up above */
1637 static void dump_acct_flags(uint32 acct_flags) {
1639 int lvl = 10;
1640 DEBUG(lvl,("dump_acct_flags\n"));
1641 if (acct_flags & ACB_NORMAL) {
1642 DEBUGADD(lvl,("\taccount has ACB_NORMAL\n"));
1644 if (acct_flags & ACB_PWNOEXP) {
1645 DEBUGADD(lvl,("\taccount has ACB_PWNOEXP\n"));
1647 if (acct_flags & ACB_ENC_TXT_PWD_ALLOWED) {
1648 DEBUGADD(lvl,("\taccount has ACB_ENC_TXT_PWD_ALLOWED\n"));
1650 if (acct_flags & ACB_NOT_DELEGATED) {
1651 DEBUGADD(lvl,("\taccount has ACB_NOT_DELEGATED\n"));
1653 if (acct_flags & ACB_USE_DES_KEY_ONLY) {
1654 DEBUGADD(lvl,("\taccount has ACB_USE_DES_KEY_ONLY set, sig verify wont work\n"));
1656 if (acct_flags & ACB_NO_AUTH_DATA_REQD) {
1657 DEBUGADD(lvl,("\taccount has ACB_NO_AUTH_DATA_REQD set\n"));
1659 if (acct_flags & ACB_PWEXPIRED) {
1660 DEBUGADD(lvl,("\taccount has ACB_PWEXPIRED set\n"));
1664 static void dump_user_flgs(uint32 user_flags) {
1666 int lvl = 10;
1667 DEBUG(lvl,("dump_user_flgs\n"));
1668 if (user_flags & LOGON_EXTRA_SIDS) {
1669 DEBUGADD(lvl,("\taccount has LOGON_EXTRA_SIDS\n"));
1671 if (user_flags & LOGON_RESOURCE_GROUPS) {
1672 DEBUGADD(lvl,("\taccount has LOGON_RESOURCE_GROUPS\n"));
1674 if (user_flags & LOGON_NTLMV2_ENABLED) {
1675 DEBUGADD(lvl,("\taccount has LOGON_NTLMV2_ENABLED\n"));
1677 if (user_flags & LOGON_CACHED_ACCOUNT) {
1678 DEBUGADD(lvl,("\taccount has LOGON_CACHED_ACCOUNT\n"));
1680 if (user_flags & LOGON_PROFILE_PATH_RETURNED) {
1681 DEBUGADD(lvl,("\taccount has LOGON_PROFILE_PATH_RETURNED\n"));
1683 if (user_flags & LOGON_SERVER_TRUST_ACCOUNT) {
1684 DEBUGADD(lvl,("\taccount has LOGON_SERVER_TRUST_ACCOUNT\n"));
1690 /*******************************************************************
1691 This code has been modified to cope with a NET_USER_INFO_2 - which is
1692 exactly the same as a NET_USER_INFO_3, minus the other sids parameters.
1693 We use validation level to determine if we're marshalling a info 2 or
1694 INFO_3 - be we always return an INFO_3. Based on code donated by Marc
1695 Jacobsen at HP. JRA.
1696 ********************************************************************/
1698 bool net_io_user_info3(const char *desc, NET_USER_INFO_3 *usr, prs_struct *ps,
1699 int depth, uint16 validation_level, bool kerb_validation_level)
1701 unsigned int i;
1703 if (usr == NULL)
1704 return False;
1706 prs_debug(ps, depth, desc, "net_io_user_info3");
1707 depth++;
1709 if (UNMARSHALLING(ps))
1710 ZERO_STRUCTP(usr);
1712 if(!prs_align(ps))
1713 return False;
1715 if(!prs_uint32("ptr_user_info ", ps, depth, &usr->ptr_user_info))
1716 return False;
1718 if (usr->ptr_user_info == 0)
1719 return True;
1721 if(!smb_io_time("logon time", &usr->logon_time, ps, depth)) /* logon time */
1722 return False;
1723 if(!smb_io_time("logoff time", &usr->logoff_time, ps, depth)) /* logoff time */
1724 return False;
1725 if(!smb_io_time("kickoff time", &usr->kickoff_time, ps, depth)) /* kickoff time */
1726 return False;
1727 if(!smb_io_time("last set time", &usr->pass_last_set_time, ps, depth)) /* password last set time */
1728 return False;
1729 if(!smb_io_time("can change time", &usr->pass_can_change_time , ps, depth)) /* password can change time */
1730 return False;
1731 if(!smb_io_time("must change time", &usr->pass_must_change_time, ps, depth)) /* password must change time */
1732 return False;
1734 if(!smb_io_unihdr("hdr_user_name", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
1735 return False;
1736 if(!smb_io_unihdr("hdr_full_name", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
1737 return False;
1738 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
1739 return False;
1740 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
1741 return False;
1742 if(!smb_io_unihdr("hdr_home_dir", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
1743 return False;
1744 if(!smb_io_unihdr("hdr_dir_drive", &usr->hdr_dir_drive, ps, depth)) /* home directory drive unicode string header */
1745 return False;
1747 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count)) /* logon count */
1748 return False;
1749 if(!prs_uint16("bad_pw_count ", ps, depth, &usr->bad_pw_count)) /* bad password count */
1750 return False;
1752 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User RID */
1753 return False;
1754 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group RID */
1755 return False;
1756 if(!prs_uint32("num_groups ", ps, depth, &usr->num_groups)) /* num groups */
1757 return False;
1758 if(!prs_uint32("buffer_groups ", ps, depth, &usr->buffer_groups)) /* undocumented buffer pointer to groups. */
1759 return False;
1760 if(!prs_uint32("user_flgs ", ps, depth, &usr->user_flgs)) /* user flags */
1761 return False;
1762 dump_user_flgs(usr->user_flgs);
1763 if(!prs_uint8s(False, "user_sess_key", ps, depth, usr->user_sess_key, 16)) /* user session key */
1764 return False;
1766 if(!smb_io_unihdr("hdr_logon_srv", &usr->hdr_logon_srv, ps, depth)) /* logon server unicode string header */
1767 return False;
1768 if(!smb_io_unihdr("hdr_logon_dom", &usr->hdr_logon_dom, ps, depth)) /* logon domain unicode string header */
1769 return False;
1771 if(!prs_uint32("buffer_dom_id ", ps, depth, &usr->buffer_dom_id)) /* undocumented logon domain id pointer */
1772 return False;
1774 if(!prs_uint8s(False, "lm_sess_key", ps, depth, usr->lm_sess_key, 8)) /* lm session key */
1775 return False;
1777 if(!prs_uint32("acct_flags ", ps, depth, &usr->acct_flags)) /* Account flags */
1778 return False;
1779 dump_acct_flags(usr->acct_flags);
1780 for (i = 0; i < 7; i++)
1782 if (!prs_uint32("unkown", ps, depth, &usr->unknown[i])) /* unknown */
1783 return False;
1786 if (validation_level == 3) {
1787 if(!prs_uint32("num_other_sids", ps, depth, &usr->num_other_sids)) /* 0 - num_sids */
1788 return False;
1789 if(!prs_uint32("buffer_other_sids", ps, depth, &usr->buffer_other_sids)) /* NULL - undocumented pointer to SIDs. */
1790 return False;
1791 } else {
1792 if (UNMARSHALLING(ps)) {
1793 usr->num_other_sids = 0;
1794 usr->buffer_other_sids = 0;
1798 /* get kerb validation info (not really part of user_info_3) - Guenther */
1800 if (kerb_validation_level) {
1802 if(!prs_uint32("ptr_res_group_dom_sid", ps, depth, &usr->ptr_res_group_dom_sid))
1803 return False;
1804 if(!prs_uint32("res_group_count", ps, depth, &usr->res_group_count))
1805 return False;
1806 if(!prs_uint32("ptr_res_groups", ps, depth, &usr->ptr_res_groups))
1807 return False;
1810 if(!smb_io_unistr2("uni_user_name", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
1811 return False;
1812 if(!smb_io_unistr2("uni_full_name", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
1813 return False;
1814 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
1815 return False;
1816 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
1817 return False;
1818 if(!smb_io_unistr2("uni_home_dir", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
1819 return False;
1820 if(!smb_io_unistr2("uni_dir_drive", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
1821 return False;
1823 if(!prs_align(ps))
1824 return False;
1826 if(!prs_uint32("num_groups2 ", ps, depth, &usr->num_groups2)) /* num groups2 */
1827 return False;
1829 if (usr->num_groups != usr->num_groups2) {
1830 DEBUG(3,("net_io_user_info3: num_groups mismatch! (%d != %d)\n",
1831 usr->num_groups, usr->num_groups2));
1832 return False;
1835 if (UNMARSHALLING(ps)) {
1836 if (usr->num_groups) {
1837 usr->gids = PRS_ALLOC_MEM(ps, DOM_GID, usr->num_groups);
1838 if (usr->gids == NULL)
1839 return False;
1840 } else {
1841 usr->gids = NULL;
1845 for (i = 0; i < usr->num_groups; i++) {
1846 if(!smb_io_gid("", &usr->gids[i], ps, depth)) /* group info */
1847 return False;
1850 if(!smb_io_unistr2("uni_logon_srv", &usr->uni_logon_srv, usr->hdr_logon_srv.buffer, ps, depth)) /* logon server unicode string */
1851 return False;
1852 if(!smb_io_unistr2("uni_logon_dom", &usr->uni_logon_dom, usr->hdr_logon_dom.buffer, ps, depth)) /* logon domain unicode string */
1853 return False;
1855 if(!smb_io_dom_sid2("", &usr->dom_sid, ps, depth)) /* domain SID */
1856 return False;
1858 if (validation_level == 3 && usr->buffer_other_sids) {
1860 uint32 num_other_sids = usr->num_other_sids;
1862 if (!(usr->user_flgs & LOGON_EXTRA_SIDS)) {
1863 DEBUG(10,("net_io_user_info3: user_flgs attribute does not have LOGON_EXTRA_SIDS\n"));
1864 /* return False; */
1867 if (!prs_uint32("num_other_sids", ps, depth,
1868 &num_other_sids))
1869 return False;
1871 if (num_other_sids != usr->num_other_sids)
1872 return False;
1874 if (UNMARSHALLING(ps)) {
1875 if (usr->num_other_sids) {
1876 usr->other_sids = PRS_ALLOC_MEM(ps, DOM_SID2, usr->num_other_sids);
1877 usr->other_sids_attrib =
1878 PRS_ALLOC_MEM(ps, uint32, usr->num_other_sids);
1879 } else {
1880 usr->other_sids = NULL;
1881 usr->other_sids_attrib = NULL;
1884 if ((num_other_sids != 0) &&
1885 ((usr->other_sids == NULL) ||
1886 (usr->other_sids_attrib == NULL)))
1887 return False;
1890 /* First the pointers to the SIDS and attributes */
1892 depth++;
1894 for (i=0; i<usr->num_other_sids; i++) {
1895 uint32 ptr = 1;
1897 if (!prs_uint32("sid_ptr", ps, depth, &ptr))
1898 return False;
1900 if (UNMARSHALLING(ps) && (ptr == 0))
1901 return False;
1903 if (!prs_uint32("attribute", ps, depth,
1904 &usr->other_sids_attrib[i]))
1905 return False;
1908 for (i = 0; i < usr->num_other_sids; i++) {
1909 if(!smb_io_dom_sid2("", &usr->other_sids[i], ps, depth)) /* other domain SIDs */
1910 return False;
1913 depth--;
1916 return True;
1919 /*******************************************************************
1920 Reads or writes a structure.
1921 ********************************************************************/
1923 bool net_io_q_sam_logon(const char *desc, NET_Q_SAM_LOGON *q_l, prs_struct *ps, int depth)
1925 if (q_l == NULL)
1926 return False;
1928 prs_debug(ps, depth, desc, "net_io_q_sam_logon");
1929 depth++;
1931 if(!prs_align(ps))
1932 return False;
1934 if(!smb_io_sam_info("", &q_l->sam_id, ps, depth))
1935 return False;
1937 if(!prs_align_uint16(ps))
1938 return False;
1940 if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level))
1941 return False;
1943 return True;
1946 /*******************************************************************
1947 Reads or writes a structure.
1948 ********************************************************************/
1950 bool net_io_r_sam_logon(const char *desc, NET_R_SAM_LOGON *r_l, prs_struct *ps, int depth)
1952 if (r_l == NULL)
1953 return False;
1955 prs_debug(ps, depth, desc, "net_io_r_sam_logon");
1956 depth++;
1958 if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */
1959 return False;
1960 if (&r_l->buffer_creds) {
1961 if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials. server time stamp appears to be ignored. */
1962 return False;
1965 if(!prs_uint16("switch_value", ps, depth, &r_l->switch_value))
1966 return False;
1967 if(!prs_align(ps))
1968 return False;
1970 #if 1 /* W2k always needs this - even for bad passwd. JRA */
1971 if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
1972 return False;
1973 #else
1974 if (r_l->switch_value != 0) {
1975 if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
1976 return False;
1978 #endif
1980 if(!prs_uint32("auth_resp ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */
1981 return False;
1983 if(!prs_ntstatus("status ", ps, depth, &r_l->status))
1984 return False;
1986 if(!prs_align(ps))
1987 return False;
1989 return True;
1992 /*******************************************************************
1993 Reads or writes a structure.
1994 ********************************************************************/
1996 bool net_io_q_sam_logon_ex(const char *desc, NET_Q_SAM_LOGON_EX *q_l, prs_struct *ps, int depth)
1998 if (q_l == NULL)
1999 return False;
2001 prs_debug(ps, depth, desc, "net_io_q_sam_logon_ex");
2002 depth++;
2004 if(!prs_align(ps))
2005 return False;
2007 if(!smb_io_sam_info_ex("", &q_l->sam_id, ps, depth))
2008 return False;
2010 if(!prs_align_uint16(ps))
2011 return False;
2013 if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level))
2014 return False;
2016 if (!prs_align(ps))
2017 return False;
2019 if(!prs_uint32("flags ", ps, depth, &q_l->flags))
2020 return False;
2022 return True;
2025 /*******************************************************************
2026 Reads or writes a structure.
2027 ********************************************************************/
2029 bool net_io_r_sam_logon_ex(const char *desc, NET_R_SAM_LOGON_EX *r_l, prs_struct *ps, int depth)
2031 if (r_l == NULL)
2032 return False;
2034 prs_debug(ps, depth, desc, "net_io_r_sam_logon_ex");
2035 depth++;
2037 if(!prs_uint16("switch_value", ps, depth, &r_l->switch_value))
2038 return False;
2039 if(!prs_align(ps))
2040 return False;
2042 #if 1 /* W2k always needs this - even for bad passwd. JRA */
2043 if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
2044 return False;
2045 #else
2046 if (r_l->switch_value != 0) {
2047 if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
2048 return False;
2050 #endif
2052 if(!prs_uint32("auth_resp ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */
2053 return False;
2055 if(!prs_uint32("flags ", ps, depth, &r_l->flags))
2056 return False;
2058 if(!prs_ntstatus("status ", ps, depth, &r_l->status))
2059 return False;
2061 if(!prs_align(ps))
2062 return False;
2064 return True;
2068 /*******************************************************************
2069 Reads or writes a structure.
2070 ********************************************************************/
2072 bool net_io_q_sam_logoff(const char *desc, NET_Q_SAM_LOGOFF *q_l, prs_struct *ps, int depth)
2074 if (q_l == NULL)
2075 return False;
2077 prs_debug(ps, depth, desc, "net_io_q_sam_logoff");
2078 depth++;
2080 if(!prs_align(ps))
2081 return False;
2083 if(!smb_io_sam_info("", &q_l->sam_id, ps, depth)) /* domain SID */
2084 return False;
2086 return True;
2089 /*******************************************************************
2090 Reads or writes a structure.
2091 ********************************************************************/
2093 bool net_io_r_sam_logoff(const char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int depth)
2095 if (r_l == NULL)
2096 return False;
2098 prs_debug(ps, depth, desc, "net_io_r_sam_logoff");
2099 depth++;
2101 if(!prs_align(ps))
2102 return False;
2104 if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */
2105 return False;
2106 if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials. server time stamp appears to be ignored. */
2107 return False;
2109 if(!prs_ntstatus("status ", ps, depth, &r_l->status))
2110 return False;
2112 return True;
2115 /*******************************************************************
2116 makes a NET_Q_SAM_SYNC structure.
2117 ********************************************************************/
2118 bool init_net_q_sam_sync(NET_Q_SAM_SYNC * q_s, const char *srv_name,
2119 const char *cli_name, DOM_CRED *cli_creds,
2120 DOM_CRED *ret_creds, uint32 database_id,
2121 uint32 next_rid)
2123 DEBUG(5, ("init_q_sam_sync\n"));
2125 init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE);
2126 init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE);
2128 if (cli_creds)
2129 memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));
2131 if (cli_creds)
2132 memcpy(&q_s->ret_creds, ret_creds, sizeof(q_s->ret_creds));
2133 else
2134 memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds));
2136 q_s->database_id = database_id;
2137 q_s->restart_state = 0;
2138 q_s->sync_context = next_rid;
2139 q_s->max_size = 0xffff;
2141 return True;
2144 /*******************************************************************
2145 reads or writes a structure.
2146 ********************************************************************/
2147 bool net_io_q_sam_sync(const char *desc, NET_Q_SAM_SYNC * q_s, prs_struct *ps,
2148 int depth)
2150 prs_debug(ps, depth, desc, "net_io_q_sam_sync");
2151 depth++;
2153 if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth))
2154 return False;
2155 if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth))
2156 return False;
2158 if (!smb_io_cred("", &q_s->cli_creds, ps, depth))
2159 return False;
2160 if (!smb_io_cred("", &q_s->ret_creds, ps, depth))
2161 return False;
2163 if (!prs_uint32("database_id ", ps, depth, &q_s->database_id))
2164 return False;
2165 if (!prs_uint32("restart_state", ps, depth, &q_s->restart_state))
2166 return False;
2167 if (!prs_uint32("sync_context ", ps, depth, &q_s->sync_context))
2168 return False;
2170 if (!prs_uint32("max_size", ps, depth, &q_s->max_size))
2171 return False;
2173 return True;
2176 /*******************************************************************
2177 reads or writes a structure.
2178 ********************************************************************/
2179 static bool net_io_sam_delta_hdr(const char *desc, SAM_DELTA_HDR * delta,
2180 prs_struct *ps, int depth)
2182 prs_debug(ps, depth, desc, "net_io_sam_delta_hdr");
2183 depth++;
2185 if (!prs_uint16("type", ps, depth, &delta->type))
2186 return False;
2187 if (!prs_uint16("type2", ps, depth, &delta->type2))
2188 return False;
2189 if (!prs_uint32("target_rid", ps, depth, &delta->target_rid))
2190 return False;
2192 if (!prs_uint32("type3", ps, depth, &delta->type3))
2193 return False;
2195 /* Not sure why we need this but it seems to be necessary to get
2196 sam deltas working. */
2198 if (delta->type != 0x16) {
2199 if (!prs_uint32("ptr_delta", ps, depth, &delta->ptr_delta))
2200 return False;
2203 return True;
2206 /*******************************************************************
2207 reads or writes a structure.
2208 ********************************************************************/
2209 static bool net_io_sam_delta_mod_count(const char *desc, SAM_DELTA_MOD_COUNT *info,
2210 prs_struct *ps, int depth)
2212 prs_debug(ps, depth, desc, "net_io_sam_delta_stamp");
2213 depth++;
2215 if (!prs_uint32("seqnum", ps, depth, &info->seqnum))
2216 return False;
2217 if (!prs_uint32("dom_mod_count_ptr", ps, depth,
2218 &info->dom_mod_count_ptr))
2219 return False;
2221 if (info->dom_mod_count_ptr) {
2222 if (!prs_uint64("dom_mod_count", ps, depth,
2223 &info->dom_mod_count))
2224 return False;
2227 return True;
2230 /*******************************************************************
2231 reads or writes a structure.
2232 ********************************************************************/
2233 static bool net_io_sam_domain_info(const char *desc, SAM_DOMAIN_INFO * info,
2234 prs_struct *ps, int depth)
2236 prs_debug(ps, depth, desc, "net_io_sam_domain_info");
2237 depth++;
2239 if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth))
2240 return False;
2241 if (!smb_io_unihdr("hdr_oem_info", &info->hdr_oem_info, ps, depth))
2242 return False;
2244 if (!prs_uint64("force_logoff", ps, depth, &info->force_logoff))
2245 return False;
2246 if (!prs_uint16("min_pwd_len", ps, depth, &info->min_pwd_len))
2247 return False;
2248 if (!prs_uint16("pwd_history_len", ps, depth, &info->pwd_history_len))
2249 return False;
2250 if (!prs_uint64("max_pwd_age", ps, depth, &info->max_pwd_age))
2251 return False;
2252 if (!prs_uint64("min_pwd_age", ps, depth, &info->min_pwd_age))
2253 return False;
2254 if (!prs_uint64("dom_mod_count", ps, depth, &info->dom_mod_count))
2255 return False;
2256 if (!smb_io_time("creation_time", &info->creation_time, ps, depth))
2257 return False;
2258 if (!prs_uint32("security_information", ps, depth, &info->security_information))
2259 return False;
2260 if (!smb_io_bufhdr4("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2261 return False;
2262 if (!smb_io_lockout_string_hdr("hdr_account_lockout_string", &info->hdr_account_lockout, ps, depth))
2263 return False;
2264 if (!smb_io_unihdr("hdr_unknown2", &info->hdr_unknown2, ps, depth))
2265 return False;
2266 if (!smb_io_unihdr("hdr_unknown3", &info->hdr_unknown3, ps, depth))
2267 return False;
2268 if (!smb_io_unihdr("hdr_unknown4", &info->hdr_unknown4, ps, depth))
2269 return False;
2270 if (!prs_uint32("logon_chgpass", ps, depth, &info->logon_chgpass))
2271 return False;
2272 if (!prs_uint32("unknown6", ps, depth, &info->unknown6))
2273 return False;
2274 if (!prs_uint32("unknown7", ps, depth, &info->unknown7))
2275 return False;
2276 if (!prs_uint32("unknown8", ps, depth, &info->unknown8))
2277 return False;
2279 if (!smb_io_unistr2("uni_dom_name", &info->uni_dom_name,
2280 info->hdr_dom_name.buffer, ps, depth))
2281 return False;
2282 if (!smb_io_unistr2("buf_oem_info", &info->buf_oem_info,
2283 info->hdr_oem_info.buffer, ps, depth))
2284 return False;
2286 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
2287 return False;
2289 if (!smb_io_account_lockout_str("account_lockout", &info->account_lockout,
2290 info->hdr_account_lockout.buffer, ps, depth))
2291 return False;
2293 if (!smb_io_unistr2("buf_unknown2", &info->buf_unknown2,
2294 info->hdr_unknown2.buffer, ps, depth))
2295 return False;
2296 if (!smb_io_unistr2("buf_unknown3", &info->buf_unknown3,
2297 info->hdr_unknown3.buffer, ps, depth))
2298 return False;
2299 if (!smb_io_unistr2("buf_unknown4", &info->buf_unknown4,
2300 info->hdr_unknown4.buffer, ps, depth))
2301 return False;
2303 return True;
2306 /*******************************************************************
2307 reads or writes a structure.
2308 ********************************************************************/
2309 static bool net_io_sam_group_info(const char *desc, SAM_GROUP_INFO * info,
2310 prs_struct *ps, int depth)
2312 prs_debug(ps, depth, desc, "net_io_sam_group_info");
2313 depth++;
2315 if (!smb_io_unihdr("hdr_grp_name", &info->hdr_grp_name, ps, depth))
2316 return False;
2317 if (!smb_io_gid("gid", &info->gid, ps, depth))
2318 return False;
2319 if (!smb_io_unihdr("hdr_grp_desc", &info->hdr_grp_desc, ps, depth))
2320 return False;
2321 if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2322 return False;
2324 if (ps->data_offset + 48 > ps->buffer_size)
2325 return False;
2326 ps->data_offset += 48;
2328 if (!smb_io_unistr2("uni_grp_name", &info->uni_grp_name,
2329 info->hdr_grp_name.buffer, ps, depth))
2330 return False;
2331 if (!smb_io_unistr2("uni_grp_desc", &info->uni_grp_desc,
2332 info->hdr_grp_desc.buffer, ps, depth))
2333 return False;
2334 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
2335 return False;
2337 return True;
2340 /*******************************************************************
2341 reads or writes a structure.
2342 ********************************************************************/
2343 static bool net_io_sam_passwd_info(const char *desc, SAM_PWD * pwd,
2344 prs_struct *ps, int depth)
2346 prs_debug(ps, depth, desc, "net_io_sam_passwd_info");
2347 depth++;
2349 if (!prs_uint32("unk_0 ", ps, depth, &pwd->unk_0))
2350 return False;
2352 if (!smb_io_unihdr("hdr_lm_pwd", &pwd->hdr_lm_pwd, ps, depth))
2353 return False;
2354 if (!prs_uint8s(False, "buf_lm_pwd", ps, depth, pwd->buf_lm_pwd, 16))
2355 return False;
2357 if (!smb_io_unihdr("hdr_nt_pwd", &pwd->hdr_nt_pwd, ps, depth))
2358 return False;
2359 if (!prs_uint8s(False, "buf_nt_pwd", ps, depth, pwd->buf_nt_pwd, 16))
2360 return False;
2362 if (!smb_io_unihdr("", &pwd->hdr_empty_lm, ps, depth))
2363 return False;
2364 if (!smb_io_unihdr("", &pwd->hdr_empty_nt, ps, depth))
2365 return False;
2367 return True;
2370 /*******************************************************************
2371 reads or writes a structure.
2372 ********************************************************************/
2373 static bool net_io_sam_account_info(const char *desc, SAM_ACCOUNT_INFO *info,
2374 prs_struct *ps, int depth)
2376 BUFHDR2 hdr_priv_data;
2377 uint32 i;
2379 prs_debug(ps, depth, desc, "net_io_sam_account_info");
2380 depth++;
2382 if (!smb_io_unihdr("hdr_acct_name", &info->hdr_acct_name, ps, depth))
2383 return False;
2384 if (!smb_io_unihdr("hdr_full_name", &info->hdr_full_name, ps, depth))
2385 return False;
2387 if (!prs_uint32("user_rid ", ps, depth, &info->user_rid))
2388 return False;
2389 if (!prs_uint32("group_rid", ps, depth, &info->group_rid))
2390 return False;
2392 if (!smb_io_unihdr("hdr_home_dir ", &info->hdr_home_dir, ps, depth))
2393 return False;
2394 if (!smb_io_unihdr("hdr_dir_drive", &info->hdr_dir_drive, ps, depth))
2395 return False;
2396 if (!smb_io_unihdr("hdr_logon_script", &info->hdr_logon_script, ps,
2397 depth))
2398 return False;
2400 if (!smb_io_unihdr("hdr_acct_desc", &info->hdr_acct_desc, ps, depth))
2401 return False;
2402 if (!smb_io_unihdr("hdr_workstations", &info->hdr_workstations, ps,
2403 depth))
2404 return False;
2406 if (!smb_io_time("logon_time", &info->logon_time, ps, depth))
2407 return False;
2408 if (!smb_io_time("logoff_time", &info->logoff_time, ps, depth))
2409 return False;
2411 if (!prs_uint32("logon_divs ", ps, depth, &info->logon_divs))
2412 return False;
2413 if (!prs_uint32("ptr_logon_hrs", ps, depth, &info->ptr_logon_hrs))
2414 return False;
2416 if (!prs_uint16("bad_pwd_count", ps, depth, &info->bad_pwd_count))
2417 return False;
2418 if (!prs_uint16("logon_count", ps, depth, &info->logon_count))
2419 return False;
2420 if (!smb_io_time("pwd_last_set_time", &info->pwd_last_set_time, ps,
2421 depth))
2422 return False;
2423 if (!smb_io_time("acct_expiry_time", &info->acct_expiry_time, ps,
2424 depth))
2425 return False;
2427 if (!prs_uint32("acb_info", ps, depth, &info->acb_info))
2428 return False;
2429 if (!prs_uint8s(False, "nt_pwd", ps, depth, info->nt_pwd, 16))
2430 return False;
2431 if (!prs_uint8s(False, "lm_pwd", ps, depth, info->lm_pwd, 16))
2432 return False;
2433 if (!prs_uint8("lm_pwd_present", ps, depth, &info->lm_pwd_present))
2434 return False;
2435 if (!prs_uint8("nt_pwd_present", ps, depth, &info->nt_pwd_present))
2436 return False;
2437 if (!prs_uint8("pwd_expired", ps, depth, &info->pwd_expired))
2438 return False;
2440 if (!smb_io_unihdr("hdr_comment", &info->hdr_comment, ps, depth))
2441 return False;
2442 if (!smb_io_unihdr("hdr_parameters", &info->hdr_parameters, ps,
2443 depth))
2444 return False;
2445 if (!prs_uint16("country", ps, depth, &info->country))
2446 return False;
2447 if (!prs_uint16("codepage", ps, depth, &info->codepage))
2448 return False;
2450 if (!smb_io_bufhdr2("hdr_priv_data", &hdr_priv_data, ps, depth))
2451 return False;
2452 if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2453 return False;
2454 if (!smb_io_unihdr("hdr_profile", &info->hdr_profile, ps, depth))
2455 return False;
2457 for (i = 0; i < 3; i++)
2459 if (!smb_io_unihdr("hdr_reserved", &info->hdr_reserved[i],
2460 ps, depth))
2461 return False;
2464 for (i = 0; i < 4; i++)
2466 if (!prs_uint32("dw_reserved", ps, depth,
2467 &info->dw_reserved[i]))
2468 return False;
2471 if (!smb_io_unistr2("uni_acct_name", &info->uni_acct_name,
2472 info->hdr_acct_name.buffer, ps, depth))
2473 return False;
2474 prs_align(ps);
2475 if (!smb_io_unistr2("uni_full_name", &info->uni_full_name,
2476 info->hdr_full_name.buffer, ps, depth))
2477 return False;
2478 prs_align(ps);
2479 if (!smb_io_unistr2("uni_home_dir ", &info->uni_home_dir,
2480 info->hdr_home_dir.buffer, ps, depth))
2481 return False;
2482 prs_align(ps);
2483 if (!smb_io_unistr2("uni_dir_drive", &info->uni_dir_drive,
2484 info->hdr_dir_drive.buffer, ps, depth))
2485 return False;
2486 prs_align(ps);
2487 if (!smb_io_unistr2("uni_logon_script", &info->uni_logon_script,
2488 info->hdr_logon_script.buffer, ps, depth))
2489 return False;
2490 prs_align(ps);
2491 if (!smb_io_unistr2("uni_acct_desc", &info->uni_acct_desc,
2492 info->hdr_acct_desc.buffer, ps, depth))
2493 return False;
2494 prs_align(ps);
2495 if (!smb_io_unistr2("uni_workstations", &info->uni_workstations,
2496 info->hdr_workstations.buffer, ps, depth))
2497 return False;
2498 prs_align(ps);
2500 if (!prs_uint32("unknown1", ps, depth, &info->unknown1))
2501 return False;
2502 if (!prs_uint32("unknown2", ps, depth, &info->unknown2))
2503 return False;
2505 if (!smb_io_rpc_blob("buf_logon_hrs", &info->buf_logon_hrs, ps, depth))
2506 return False;
2507 prs_align(ps);
2508 if (!smb_io_unistr2("uni_comment", &info->uni_comment,
2509 info->hdr_comment.buffer, ps, depth))
2510 return False;
2511 prs_align(ps);
2512 if (!smb_io_unistr2("uni_parameters", &info->uni_parameters,
2513 info->hdr_parameters.buffer, ps, depth))
2514 return False;
2515 prs_align(ps);
2516 if (hdr_priv_data.buffer != 0)
2518 int old_offset = 0;
2519 uint32 len = 0x44;
2520 if (!prs_uint32("pwd_len", ps, depth, &len))
2521 return False;
2522 old_offset = ps->data_offset;
2523 if (len > 0)
2525 if (ps->io)
2527 /* reading */
2528 if (!prs_hash1(ps, ps->data_offset, len))
2529 return False;
2531 if (!net_io_sam_passwd_info("pass", &info->pass,
2532 ps, depth))
2533 return False;
2535 if (!ps->io)
2537 /* writing */
2538 if (!prs_hash1(ps, old_offset, len))
2539 return False;
2542 if (old_offset + len > ps->buffer_size)
2543 return False;
2544 ps->data_offset = old_offset + len;
2546 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
2547 return False;
2548 prs_align(ps);
2549 if (!smb_io_unistr2("uni_profile", &info->uni_profile,
2550 info->hdr_profile.buffer, ps, depth))
2551 return False;
2553 prs_align(ps);
2555 return True;
2558 /*******************************************************************
2559 reads or writes a structure.
2560 ********************************************************************/
2561 static bool net_io_sam_group_mem_info(const char *desc, SAM_GROUP_MEM_INFO * info,
2562 prs_struct *ps, int depth)
2564 uint32 i;
2565 fstring tmp;
2567 prs_debug(ps, depth, desc, "net_io_sam_group_mem_info");
2568 depth++;
2570 prs_align(ps);
2571 if (!prs_uint32("ptr_rids ", ps, depth, &info->ptr_rids))
2572 return False;
2573 if (!prs_uint32("ptr_attribs", ps, depth, &info->ptr_attribs))
2574 return False;
2575 if (!prs_uint32("num_members", ps, depth, &info->num_members))
2576 return False;
2578 if (ps->data_offset + 16 > ps->buffer_size)
2579 return False;
2580 ps->data_offset += 16;
2582 if (info->ptr_rids != 0)
2584 if (!prs_uint32("num_members2", ps, depth,
2585 &info->num_members2))
2586 return False;
2588 if (info->num_members2 != info->num_members)
2590 /* RPC fault */
2591 return False;
2594 if (UNMARSHALLING(ps)) {
2595 if (info->num_members2) {
2596 info->rids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members2);
2598 if (info->rids == NULL) {
2599 DEBUG(0, ("out of memory allocating %d rids\n",
2600 info->num_members2));
2601 return False;
2603 } else {
2604 info->rids = NULL;
2608 for (i = 0; i < info->num_members2; i++)
2610 slprintf(tmp, sizeof(tmp) - 1, "rids[%02d]", i);
2611 if (!prs_uint32(tmp, ps, depth, &info->rids[i]))
2612 return False;
2616 if (info->ptr_attribs != 0)
2618 if (!prs_uint32("num_members3", ps, depth,
2619 &info->num_members3))
2620 return False;
2621 if (info->num_members3 != info->num_members)
2623 /* RPC fault */
2624 return False;
2627 if (UNMARSHALLING(ps)) {
2628 if (info->num_members3) {
2629 info->attribs = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members3);
2631 if (info->attribs == NULL) {
2632 DEBUG(0, ("out of memory allocating %d attribs\n",
2633 info->num_members3));
2634 return False;
2636 } else {
2637 info->attribs = NULL;
2641 for (i = 0; i < info->num_members3; i++)
2643 slprintf(tmp, sizeof(tmp) - 1, "attribs[%02d]", i);
2644 if (!prs_uint32(tmp, ps, depth, &info->attribs[i]))
2645 return False;
2649 return True;
2652 /*******************************************************************
2653 reads or writes a structure.
2654 ********************************************************************/
2655 static bool net_io_sam_alias_info(const char *desc, SAM_ALIAS_INFO * info,
2656 prs_struct *ps, int depth)
2658 prs_debug(ps, depth, desc, "net_io_sam_alias_info");
2659 depth++;
2661 if (!smb_io_unihdr("hdr_als_name", &info->hdr_als_name, ps, depth))
2662 return False;
2663 if (!prs_uint32("als_rid", ps, depth, &info->als_rid))
2664 return False;
2665 if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2666 return False;
2667 if (!smb_io_unihdr("hdr_als_desc", &info->hdr_als_desc, ps, depth))
2668 return False;
2670 if (ps->data_offset + 40 > ps->buffer_size)
2671 return False;
2672 ps->data_offset += 40;
2674 if (!smb_io_unistr2("uni_als_name", &info->uni_als_name,
2675 info->hdr_als_name.buffer, ps, depth))
2676 return False;
2677 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
2678 return False;
2680 if (!smb_io_unistr2("uni_als_desc", &info->uni_als_desc,
2681 info->hdr_als_desc.buffer, ps, depth))
2682 return False;
2684 return True;
2687 /*******************************************************************
2688 reads or writes a structure.
2689 ********************************************************************/
2690 static bool net_io_sam_alias_mem_info(const char *desc, SAM_ALIAS_MEM_INFO * info,
2691 prs_struct *ps, int depth)
2693 uint32 i;
2694 fstring tmp;
2696 prs_debug(ps, depth, desc, "net_io_sam_alias_mem_info");
2697 depth++;
2699 prs_align(ps);
2700 if (!prs_uint32("num_members", ps, depth, &info->num_members))
2701 return False;
2702 if (!prs_uint32("ptr_members", ps, depth, &info->ptr_members))
2703 return False;
2705 if (ps->data_offset + 16 > ps->buffer_size)
2706 return False;
2707 ps->data_offset += 16;
2709 if (info->ptr_members != 0)
2711 if (!prs_uint32("num_sids", ps, depth, &info->num_sids))
2712 return False;
2713 if (info->num_sids != info->num_members)
2715 /* RPC fault */
2716 return False;
2719 if (UNMARSHALLING(ps)) {
2720 if (info->num_sids) {
2721 info->ptr_sids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_sids);
2723 if (info->ptr_sids == NULL) {
2724 DEBUG(0, ("out of memory allocating %d ptr_sids\n",
2725 info->num_sids));
2726 return False;
2728 } else {
2729 info->ptr_sids = NULL;
2733 for (i = 0; i < info->num_sids; i++)
2735 slprintf(tmp, sizeof(tmp) - 1, "ptr_sids[%02d]", i);
2736 if (!prs_uint32(tmp, ps, depth, &info->ptr_sids[i]))
2737 return False;
2740 if (UNMARSHALLING(ps)) {
2741 if (info->num_sids) {
2742 info->sids = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, info->num_sids);
2744 if (info->sids == NULL) {
2745 DEBUG(0, ("error allocating %d sids\n",
2746 info->num_sids));
2747 return False;
2749 } else {
2750 info->sids = NULL;
2754 for (i = 0; i < info->num_sids; i++)
2756 if (info->ptr_sids[i] != 0)
2758 slprintf(tmp, sizeof(tmp) - 1, "sids[%02d]",
2760 if (!smb_io_dom_sid2(tmp, &info->sids[i],
2761 ps, depth))
2762 return False;
2767 return True;
2770 /*******************************************************************
2771 reads or writes a structure.
2772 ********************************************************************/
2773 static bool net_io_sam_policy_info(const char *desc, SAM_DELTA_POLICY *info,
2774 prs_struct *ps, int depth)
2776 unsigned int i;
2777 prs_debug(ps, depth, desc, "net_io_sam_policy_info");
2778 depth++;
2780 if(!prs_align(ps))
2781 return False;
2783 if (!prs_uint32("max_log_size", ps, depth, &info->max_log_size))
2784 return False;
2785 if (!prs_uint64("audit_retention_period", ps, depth,
2786 &info->audit_retention_period))
2787 return False;
2788 if (!prs_uint32("auditing_mode", ps, depth, &info->auditing_mode))
2789 return False;
2790 if (!prs_uint32("num_events", ps, depth, &info->num_events))
2791 return False;
2792 if (!prs_uint32("ptr_events", ps, depth, &info->ptr_events))
2793 return False;
2795 if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth))
2796 return False;
2798 if (!prs_uint32("sid_ptr", ps, depth, &info->sid_ptr))
2799 return False;
2801 if (!prs_uint32("paged_pool_limit", ps, depth, &info->paged_pool_limit))
2802 return False;
2803 if (!prs_uint32("non_paged_pool_limit", ps, depth,
2804 &info->non_paged_pool_limit))
2805 return False;
2806 if (!prs_uint32("min_workset_size", ps, depth, &info->min_workset_size))
2807 return False;
2808 if (!prs_uint32("max_workset_size", ps, depth, &info->max_workset_size))
2809 return False;
2810 if (!prs_uint32("page_file_limit", ps, depth, &info->page_file_limit))
2811 return False;
2812 if (!prs_uint64("time_limit", ps, depth, &info->time_limit))
2813 return False;
2814 if (!smb_io_time("modify_time", &info->modify_time, ps, depth))
2815 return False;
2816 if (!smb_io_time("create_time", &info->create_time, ps, depth))
2817 return False;
2818 if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
2819 return False;
2821 for (i=0; i<4; i++) {
2822 UNIHDR dummy;
2823 if (!smb_io_unihdr("dummy", &dummy, ps, depth))
2824 return False;
2827 for (i=0; i<4; i++) {
2828 uint32 reserved;
2829 if (!prs_uint32("reserved", ps, depth, &reserved))
2830 return False;
2833 if (!prs_uint32("num_event_audit_options", ps, depth,
2834 &info->num_event_audit_options))
2835 return False;
2837 for (i=0; i<info->num_event_audit_options; i++)
2838 if (!prs_uint32("event_audit_option", ps, depth,
2839 &info->event_audit_option))
2840 return False;
2842 if (!smb_io_unistr2("domain_name", &info->domain_name, True, ps, depth))
2843 return False;
2845 if(!smb_io_dom_sid2("domain_sid", &info->domain_sid, ps, depth))
2846 return False;
2848 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
2850 return False;
2852 return True;
2855 #if 0
2857 /* This function is pretty broken - see bug #334 */
2859 /*******************************************************************
2860 reads or writes a structure.
2861 ********************************************************************/
2862 static bool net_io_sam_trustdoms_info(const char *desc, SAM_DELTA_TRUSTDOMS *info,
2863 prs_struct *ps, int depth)
2865 int i;
2867 prs_debug(ps, depth, desc, "net_io_sam_trustdoms_info");
2868 depth++;
2870 if(!prs_align(ps))
2871 return False;
2873 if(!prs_uint32("buf_size", ps, depth, &info->buf_size))
2874 return False;
2876 if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth))
2877 return False;
2879 if(!smb_io_dom_sid2("sid", &info->sid, ps, depth))
2880 return False;
2882 if(!smb_io_unihdr("hdr_domain", &info->hdr_domain, ps, depth))
2883 return False;
2885 if(!prs_uint32("unknown0", ps, depth, &info->unknown0))
2886 return False;
2887 if(!prs_uint32("unknown1", ps, depth, &info->unknown1))
2888 return False;
2889 if(!prs_uint32("unknown2", ps, depth, &info->unknown2))
2890 return False;
2892 if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2))
2893 return False;
2894 if(!prs_uint32("ptr", ps, depth, &info->ptr))
2895 return False;
2897 for (i=0; i<12; i++)
2898 if(!prs_uint32("unknown3", ps, depth, &info->unknown3))
2899 return False;
2901 if (!smb_io_unistr2("domain", &info->domain, True, ps, depth))
2902 return False;
2904 return True;
2907 #endif
2909 #if 0
2911 /* This function doesn't work - see bug #334 */
2913 /*******************************************************************
2914 reads or writes a structure.
2915 ********************************************************************/
2916 static bool net_io_sam_secret_info(const char *desc, SAM_DELTA_SECRET *info,
2917 prs_struct *ps, int depth)
2919 int i;
2921 prs_debug(ps, depth, desc, "net_io_sam_secret_info");
2922 depth++;
2924 if(!prs_align(ps))
2925 return False;
2927 if(!prs_uint32("buf_size", ps, depth, &info->buf_size))
2928 return False;
2930 if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth))
2931 return False;
2933 if (!smb_io_unistr2("secret", &info->secret, True, ps, depth))
2934 return False;
2936 if(!prs_align(ps))
2937 return False;
2939 if(!prs_uint32("count1", ps, depth, &info->count1))
2940 return False;
2941 if(!prs_uint32("count2", ps, depth, &info->count2))
2942 return False;
2943 if(!prs_uint32("ptr", ps, depth, &info->ptr))
2944 return False;
2947 if(!smb_io_time("time1", &info->time1, ps, depth)) /* logon time */
2948 return False;
2949 if(!prs_uint32("count3", ps, depth, &info->count3))
2950 return False;
2951 if(!prs_uint32("count4", ps, depth, &info->count4))
2952 return False;
2953 if(!prs_uint32("ptr2", ps, depth, &info->ptr2))
2954 return False;
2955 if(!smb_io_time("time2", &info->time2, ps, depth)) /* logon time */
2956 return False;
2957 if(!prs_uint32("unknow1", ps, depth, &info->unknow1))
2958 return False;
2961 if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2))
2962 return False;
2963 if(!prs_uint32("ptr3", ps, depth, &info->ptr3))
2964 return False;
2965 for(i=0; i<12; i++)
2966 if(!prs_uint32("unknow2", ps, depth, &info->unknow2))
2967 return False;
2969 if(!prs_uint32("chal_len", ps, depth, &info->chal_len))
2970 return False;
2971 if(!prs_uint32("reserved1", ps, depth, &info->reserved1))
2972 return False;
2973 if(!prs_uint32("chal_len2", ps, depth, &info->chal_len2))
2974 return False;
2976 if(!prs_uint8s (False, "chal", ps, depth, info->chal, info->chal_len2))
2977 return False;
2979 if(!prs_uint32("key_len", ps, depth, &info->key_len))
2980 return False;
2981 if(!prs_uint32("reserved2", ps, depth, &info->reserved2))
2982 return False;
2983 if(!prs_uint32("key_len2", ps, depth, &info->key_len2))
2984 return False;
2986 if(!prs_uint8s (False, "key", ps, depth, info->key, info->key_len2))
2987 return False;
2990 if(!prs_uint32("buf_size3", ps, depth, &info->buf_size3))
2991 return False;
2993 if(!sec_io_desc("sec_desc2", &info->sec_desc2, ps, depth))
2994 return False;
2997 return True;
3000 #endif
3002 /*******************************************************************
3003 reads or writes a structure.
3004 ********************************************************************/
3005 static bool net_io_sam_privs_info(const char *desc, SAM_DELTA_PRIVS *info,
3006 prs_struct *ps, int depth)
3008 unsigned int i;
3010 prs_debug(ps, depth, desc, "net_io_sam_privs_info");
3011 depth++;
3013 if(!prs_align(ps))
3014 return False;
3016 if(!smb_io_dom_sid2("sid", &info->sid, ps, depth))
3017 return False;
3019 if(!prs_uint32("priv_count", ps, depth, &info->priv_count))
3020 return False;
3021 if(!prs_uint32("priv_control", ps, depth, &info->priv_control))
3022 return False;
3024 if(!prs_uint32("priv_attr_ptr", ps, depth, &info->priv_attr_ptr))
3025 return False;
3026 if(!prs_uint32("priv_name_ptr", ps, depth, &info->priv_name_ptr))
3027 return False;
3029 if (!prs_uint32("paged_pool_limit", ps, depth, &info->paged_pool_limit))
3030 return False;
3031 if (!prs_uint32("non_paged_pool_limit", ps, depth,
3032 &info->non_paged_pool_limit))
3033 return False;
3034 if (!prs_uint32("min_workset_size", ps, depth, &info->min_workset_size))
3035 return False;
3036 if (!prs_uint32("max_workset_size", ps, depth, &info->max_workset_size))
3037 return False;
3038 if (!prs_uint32("page_file_limit", ps, depth, &info->page_file_limit))
3039 return False;
3040 if (!prs_uint64("time_limit", ps, depth, &info->time_limit))
3041 return False;
3042 if (!prs_uint32("system_flags", ps, depth, &info->system_flags))
3043 return False;
3044 if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
3045 return False;
3047 for (i=0; i<4; i++) {
3048 UNIHDR dummy;
3049 if (!smb_io_unihdr("dummy", &dummy, ps, depth))
3050 return False;
3053 for (i=0; i<4; i++) {
3054 uint32 reserved;
3055 if (!prs_uint32("reserved", ps, depth, &reserved))
3056 return False;
3059 if(!prs_uint32("attribute_count", ps, depth, &info->attribute_count))
3060 return False;
3062 if (UNMARSHALLING(ps)) {
3063 if (info->attribute_count) {
3064 info->attributes = TALLOC_ARRAY(ps->mem_ctx, uint32, info->attribute_count);
3065 if (!info->attributes) {
3066 return False;
3068 } else {
3069 info->attributes = NULL;
3073 for (i=0; i<info->attribute_count; i++)
3074 if(!prs_uint32("attributes", ps, depth, &info->attributes[i]))
3075 return False;
3077 if(!prs_uint32("privlist_count", ps, depth, &info->privlist_count))
3078 return False;
3080 if (UNMARSHALLING(ps)) {
3081 if (info->privlist_count) {
3082 info->hdr_privslist = TALLOC_ARRAY(ps->mem_ctx, UNIHDR, info->privlist_count);
3083 info->uni_privslist = TALLOC_ARRAY(ps->mem_ctx, UNISTR2, info->privlist_count);
3084 if (!info->hdr_privslist) {
3085 return False;
3087 if (!info->uni_privslist) {
3088 return False;
3090 } else {
3091 info->hdr_privslist = NULL;
3092 info->uni_privslist = NULL;
3096 for (i=0; i<info->privlist_count; i++)
3097 if(!smb_io_unihdr("hdr_privslist", &info->hdr_privslist[i], ps, depth))
3098 return False;
3100 for (i=0; i<info->privlist_count; i++)
3101 if (!smb_io_unistr2("uni_privslist", &info->uni_privslist[i], True, ps, depth))
3102 return False;
3104 if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
3105 return False;
3107 return True;
3110 /*******************************************************************
3111 reads or writes a structure.
3112 ********************************************************************/
3113 static bool net_io_sam_delta_ctr(const char *desc,
3114 SAM_DELTA_CTR * delta, uint16 type,
3115 prs_struct *ps, int depth)
3117 prs_debug(ps, depth, desc, "net_io_sam_delta_ctr");
3118 depth++;
3120 switch (type) {
3121 /* Seen in sam deltas */
3122 case SAM_DELTA_MODIFIED_COUNT:
3123 if (!net_io_sam_delta_mod_count("", &delta->mod_count, ps, depth))
3124 return False;
3125 break;
3127 case SAM_DELTA_DOMAIN_INFO:
3128 if (!net_io_sam_domain_info("", &delta->domain_info, ps, depth))
3129 return False;
3130 break;
3132 case SAM_DELTA_GROUP_INFO:
3133 if (!net_io_sam_group_info("", &delta->group_info, ps, depth))
3134 return False;
3135 break;
3137 case SAM_DELTA_ACCOUNT_INFO:
3138 if (!net_io_sam_account_info("", &delta->account_info, ps, depth))
3139 return False;
3140 break;
3142 case SAM_DELTA_GROUP_MEM:
3143 if (!net_io_sam_group_mem_info("", &delta->grp_mem_info, ps, depth))
3144 return False;
3145 break;
3147 case SAM_DELTA_ALIAS_INFO:
3148 if (!net_io_sam_alias_info("", &delta->alias_info, ps, depth))
3149 return False;
3150 break;
3152 case SAM_DELTA_POLICY_INFO:
3153 if (!net_io_sam_policy_info("", &delta->policy_info, ps, depth))
3154 return False;
3155 break;
3157 case SAM_DELTA_ALIAS_MEM:
3158 if (!net_io_sam_alias_mem_info("", &delta->als_mem_info, ps, depth))
3159 return False;
3160 break;
3162 case SAM_DELTA_PRIVS_INFO:
3163 if (!net_io_sam_privs_info("", &delta->privs_info, ps, depth))
3164 return False;
3165 break;
3167 /* These guys are implemented but broken */
3169 case SAM_DELTA_TRUST_DOMS:
3170 case SAM_DELTA_SECRET_INFO:
3171 break;
3173 /* These guys are not implemented yet */
3175 case SAM_DELTA_RENAME_GROUP:
3176 case SAM_DELTA_RENAME_USER:
3177 case SAM_DELTA_RENAME_ALIAS:
3178 case SAM_DELTA_DELETE_GROUP:
3179 case SAM_DELTA_DELETE_USER:
3180 default:
3181 DEBUG(0, ("Replication error: Unknown delta type 0x%x\n", type));
3182 break;
3185 return True;
3188 /*******************************************************************
3189 reads or writes a structure.
3190 ********************************************************************/
3191 bool net_io_r_sam_sync(const char *desc,
3192 NET_R_SAM_SYNC * r_s, prs_struct *ps, int depth)
3194 uint32 i;
3196 prs_debug(ps, depth, desc, "net_io_r_sam_sync");
3197 depth++;
3199 if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth))
3200 return False;
3201 if (!prs_uint32("sync_context", ps, depth, &r_s->sync_context))
3202 return False;
3204 if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas))
3205 return False;
3206 if (r_s->ptr_deltas != 0)
3208 if (!prs_uint32("num_deltas ", ps, depth, &r_s->num_deltas))
3209 return False;
3210 if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->ptr_deltas2))
3211 return False;
3212 if (r_s->ptr_deltas2 != 0)
3214 if (!prs_uint32("num_deltas2", ps, depth,
3215 &r_s->num_deltas2))
3216 return False;
3218 if (r_s->num_deltas2 != r_s->num_deltas)
3220 /* RPC fault */
3221 return False;
3224 if (UNMARSHALLING(ps)) {
3225 if (r_s->num_deltas2) {
3226 r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas2);
3227 if (r_s->hdr_deltas == NULL) {
3228 DEBUG(0, ("error tallocating memory "
3229 "for %d delta headers\n",
3230 r_s->num_deltas2));
3231 return False;
3233 } else {
3234 r_s->hdr_deltas = NULL;
3238 for (i = 0; i < r_s->num_deltas2; i++)
3240 if (!net_io_sam_delta_hdr("",
3241 &r_s->hdr_deltas[i],
3242 ps, depth))
3243 return False;
3246 if (UNMARSHALLING(ps)) {
3247 if (r_s->num_deltas2) {
3248 r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas2);
3249 if (r_s->deltas == NULL) {
3250 DEBUG(0, ("error tallocating memory "
3251 "for %d deltas\n",
3252 r_s->num_deltas2));
3253 return False;
3255 } else {
3256 r_s->deltas = NULL;
3260 for (i = 0; i < r_s->num_deltas2; i++)
3262 if (!net_io_sam_delta_ctr(
3263 "", &r_s->deltas[i],
3264 r_s->hdr_deltas[i].type3,
3265 ps, depth)) {
3266 DEBUG(0, ("hmm, failed on i=%d\n", i));
3267 return False;
3273 prs_align(ps);
3274 if (!prs_ntstatus("status", ps, depth, &(r_s->status)))
3275 return False;
3277 return True;
3280 /*******************************************************************
3281 makes a NET_Q_SAM_DELTAS structure.
3282 ********************************************************************/
3283 bool init_net_q_sam_deltas(NET_Q_SAM_DELTAS *q_s, const char *srv_name,
3284 const char *cli_name, DOM_CRED *cli_creds,
3285 uint32 database_id, uint64 dom_mod_count)
3287 DEBUG(5, ("init_net_q_sam_deltas\n"));
3289 init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE);
3290 init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE);
3292 memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));
3293 memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds));
3295 q_s->database_id = database_id;
3296 q_s->dom_mod_count = dom_mod_count;
3297 q_s->max_size = 0xffff;
3299 return True;
3302 /*******************************************************************
3303 reads or writes a structure.
3304 ********************************************************************/
3305 bool net_io_q_sam_deltas(const char *desc, NET_Q_SAM_DELTAS *q_s, prs_struct *ps,
3306 int depth)
3308 prs_debug(ps, depth, desc, "net_io_q_sam_deltas");
3309 depth++;
3311 if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth))
3312 return False;
3313 if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth))
3314 return False;
3316 if (!smb_io_cred("", &q_s->cli_creds, ps, depth))
3317 return False;
3318 if (!smb_io_cred("", &q_s->ret_creds, ps, depth))
3319 return False;
3321 if (!prs_uint32("database_id ", ps, depth, &q_s->database_id))
3322 return False;
3323 if (!prs_uint64("dom_mod_count", ps, depth, &q_s->dom_mod_count))
3324 return False;
3325 if (!prs_uint32("max_size", ps, depth, &q_s->max_size))
3326 return False;
3328 return True;
3331 /*******************************************************************
3332 reads or writes a structure.
3333 ********************************************************************/
3334 bool net_io_r_sam_deltas(const char *desc,
3335 NET_R_SAM_DELTAS *r_s, prs_struct *ps, int depth)
3337 unsigned int i;
3339 prs_debug(ps, depth, desc, "net_io_r_sam_deltas");
3340 depth++;
3342 if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth))
3343 return False;
3344 if (!prs_uint64("dom_mod_count", ps, depth, &r_s->dom_mod_count))
3345 return False;
3347 if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas))
3348 return False;
3349 if (!prs_uint32("num_deltas", ps, depth, &r_s->num_deltas))
3350 return False;
3351 if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->num_deltas2))
3352 return False;
3354 if (r_s->num_deltas2 != 0)
3356 if (!prs_uint32("num_deltas2 ", ps, depth, &r_s->num_deltas2))
3357 return False;
3359 if (r_s->ptr_deltas != 0)
3361 if (UNMARSHALLING(ps)) {
3362 if (r_s->num_deltas) {
3363 r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas);
3364 if (r_s->hdr_deltas == NULL) {
3365 DEBUG(0, ("error tallocating memory "
3366 "for %d delta headers\n",
3367 r_s->num_deltas));
3368 return False;
3370 } else {
3371 r_s->hdr_deltas = NULL;
3375 for (i = 0; i < r_s->num_deltas; i++)
3377 net_io_sam_delta_hdr("", &r_s->hdr_deltas[i],
3378 ps, depth);
3381 if (UNMARSHALLING(ps)) {
3382 if (r_s->num_deltas) {
3383 r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas);
3384 if (r_s->deltas == NULL) {
3385 DEBUG(0, ("error tallocating memory "
3386 "for %d deltas\n",
3387 r_s->num_deltas));
3388 return False;
3390 } else {
3391 r_s->deltas = NULL;
3395 for (i = 0; i < r_s->num_deltas; i++)
3397 if (!net_io_sam_delta_ctr(
3399 &r_s->deltas[i],
3400 r_s->hdr_deltas[i].type2,
3401 ps, depth))
3403 return False;
3408 prs_align(ps);
3409 if (!prs_ntstatus("status", ps, depth, &r_s->status))
3410 return False;
3412 return True;
3415 /*******************************************************************
3416 Inits a NET_Q_DSR_GETDCNAME structure.
3417 ********************************************************************/
3419 void init_net_q_dsr_getdcname(NET_Q_DSR_GETDCNAME *r_t, const char *server_unc,
3420 const char *domain_name,
3421 struct GUID *domain_guid,
3422 struct GUID *site_guid,
3423 uint32_t flags)
3425 DEBUG(5, ("init_net_q_dsr_getdcname\n"));
3427 r_t->ptr_server_unc = (server_unc != NULL);
3428 init_unistr2(&r_t->uni_server_unc, server_unc, UNI_STR_TERMINATE);
3430 r_t->ptr_domain_name = (domain_name != NULL);
3431 init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE);
3433 r_t->ptr_domain_guid = (domain_guid != NULL);
3434 r_t->domain_guid = domain_guid;
3436 r_t->ptr_site_guid = (site_guid != NULL);
3437 r_t->site_guid = site_guid;
3439 r_t->flags = flags;
3442 /*******************************************************************
3443 Inits a NET_Q_DSR_GETDCNAMEEX structure.
3444 ********************************************************************/
3446 void init_net_q_dsr_getdcnameex(NET_Q_DSR_GETDCNAMEEX *r_t, const char *server_unc,
3447 const char *domain_name,
3448 struct GUID *domain_guid,
3449 const char *site_name,
3450 uint32_t flags)
3452 DEBUG(5, ("init_net_q_dsr_getdcnameex\n"));
3454 r_t->ptr_server_unc = (server_unc != NULL);
3455 init_unistr2(&r_t->uni_server_unc, server_unc, UNI_STR_TERMINATE);
3457 r_t->ptr_domain_name = (domain_name != NULL);
3458 init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE);
3460 r_t->ptr_domain_guid = (domain_guid != NULL);
3461 r_t->domain_guid = domain_guid;
3463 r_t->ptr_site_name = (site_name != NULL);
3464 init_unistr2(&r_t->uni_site_name, site_name, UNI_STR_TERMINATE);
3466 r_t->flags = flags;
3469 /*******************************************************************
3470 Inits a NET_Q_DSR_GETDCNAMEEX2 structure.
3471 ********************************************************************/
3473 void init_net_q_dsr_getdcnameex2(NET_Q_DSR_GETDCNAMEEX2 *r_t, const char *server_unc,
3474 const char *domain_name,
3475 const char *client_account,
3476 uint32 mask,
3477 struct GUID *domain_guid,
3478 const char *site_name,
3479 uint32_t flags)
3481 DEBUG(5, ("init_net_q_dsr_getdcnameex2\n"));
3483 r_t->ptr_server_unc = (server_unc != NULL);
3484 init_unistr2(&r_t->uni_server_unc, server_unc, UNI_STR_TERMINATE);
3486 r_t->ptr_client_account = (client_account != NULL);
3487 init_unistr2(&r_t->uni_client_account, client_account, UNI_STR_TERMINATE);
3489 r_t->mask = mask;
3491 r_t->ptr_domain_name = (domain_name != NULL);
3492 init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE);
3494 r_t->ptr_domain_guid = (domain_guid != NULL);
3495 r_t->domain_guid = domain_guid;
3497 r_t->ptr_site_name = (site_name != NULL);
3498 init_unistr2(&r_t->uni_site_name, site_name, UNI_STR_TERMINATE);
3500 r_t->flags = flags;
3503 /*******************************************************************
3504 Reads or writes an NET_Q_DSR_GETDCNAME structure.
3505 ********************************************************************/
3507 bool net_io_q_dsr_getdcname(const char *desc, NET_Q_DSR_GETDCNAME *r_t,
3508 prs_struct *ps, int depth)
3510 if (r_t == NULL)
3511 return False;
3513 prs_debug(ps, depth, desc, "net_io_q_dsr_getdcname");
3514 depth++;
3516 if (!prs_uint32("ptr_server_unc", ps, depth, &r_t->ptr_server_unc))
3517 return False;
3519 if (!smb_io_unistr2("server_unc", &r_t->uni_server_unc,
3520 r_t->ptr_server_unc, ps, depth))
3521 return False;
3523 if (!prs_align(ps))
3524 return False;
3526 if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name))
3527 return False;
3529 if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name,
3530 r_t->ptr_domain_name, ps, depth))
3531 return False;
3533 if (!prs_align(ps))
3534 return False;
3536 if (!prs_uint32("ptr_domain_guid", ps, depth, &r_t->ptr_domain_guid))
3537 return False;
3539 if (UNMARSHALLING(ps) && (r_t->ptr_domain_guid)) {
3540 r_t->domain_guid = PRS_ALLOC_MEM(ps, struct GUID, 1);
3541 if (r_t->domain_guid == NULL)
3542 return False;
3545 if ((r_t->ptr_domain_guid) &&
3546 (!smb_io_uuid("domain_guid", r_t->domain_guid, ps, depth)))
3547 return False;
3549 if (!prs_align(ps))
3550 return False;
3552 if (!prs_uint32("ptr_site_guid", ps, depth, &r_t->ptr_site_guid))
3553 return False;
3555 if (UNMARSHALLING(ps) && (r_t->ptr_site_guid)) {
3556 r_t->site_guid = PRS_ALLOC_MEM(ps, struct GUID, 1);
3557 if (r_t->site_guid == NULL)
3558 return False;
3561 if ((r_t->ptr_site_guid) &&
3562 (!smb_io_uuid("site_guid", r_t->site_guid, ps, depth)))
3563 return False;
3565 if (!prs_align(ps))
3566 return False;
3568 if (!prs_uint32("flags", ps, depth, &r_t->flags))
3569 return False;
3571 return True;
3574 /*******************************************************************
3575 Reads or writes an NET_Q_DSR_GETDCNAMEEX structure.
3576 ********************************************************************/
3578 bool net_io_q_dsr_getdcnameex(const char *desc, NET_Q_DSR_GETDCNAMEEX *r_t,
3579 prs_struct *ps, int depth)
3581 if (r_t == NULL)
3582 return False;
3584 prs_debug(ps, depth, desc, "net_io_q_dsr_getdcnameex");
3585 depth++;
3587 if (!prs_uint32("ptr_server_unc", ps, depth, &r_t->ptr_server_unc))
3588 return False;
3590 if (!smb_io_unistr2("server_unc", &r_t->uni_server_unc,
3591 r_t->ptr_server_unc, ps, depth))
3592 return False;
3594 if (!prs_align(ps))
3595 return False;
3597 if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name))
3598 return False;
3600 if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name,
3601 r_t->ptr_domain_name, ps, depth))
3602 return False;
3604 if (!prs_align(ps))
3605 return False;
3607 if (!prs_uint32("ptr_domain_guid", ps, depth, &r_t->ptr_domain_guid))
3608 return False;
3610 if (UNMARSHALLING(ps) && (r_t->ptr_domain_guid)) {
3611 r_t->domain_guid = PRS_ALLOC_MEM(ps, struct GUID, 1);
3612 if (r_t->domain_guid == NULL)
3613 return False;
3616 if ((r_t->ptr_domain_guid) &&
3617 (!smb_io_uuid("domain_guid", r_t->domain_guid, ps, depth)))
3618 return False;
3620 if (!prs_align(ps))
3621 return False;
3623 if (!prs_uint32("ptr_site_name", ps, depth, &r_t->ptr_site_name))
3624 return False;
3626 if (!smb_io_unistr2("site_name", &r_t->uni_site_name,
3627 r_t->ptr_site_name, ps, depth))
3628 return False;
3630 if (!prs_align(ps))
3631 return False;
3633 if (!prs_uint32("flags", ps, depth, &r_t->flags))
3634 return False;
3636 return True;
3639 /*******************************************************************
3640 Reads or writes an NET_Q_DSR_GETDCNAMEEX2 structure.
3641 ********************************************************************/
3643 bool net_io_q_dsr_getdcnameex2(const char *desc, NET_Q_DSR_GETDCNAMEEX2 *r_t,
3644 prs_struct *ps, int depth)
3646 if (r_t == NULL)
3647 return False;
3649 prs_debug(ps, depth, desc, "net_io_q_dsr_getdcnameex2");
3650 depth++;
3652 if (!prs_uint32("ptr_server_unc", ps, depth, &r_t->ptr_server_unc))
3653 return False;
3655 if (!smb_io_unistr2("server_unc", &r_t->uni_server_unc,
3656 r_t->ptr_server_unc, ps, depth))
3657 return False;
3659 if (!prs_align(ps))
3660 return False;
3662 if (!prs_uint32("ptr_client_account", ps, depth, &r_t->ptr_client_account))
3663 return False;
3665 if (!smb_io_unistr2("client_account", &r_t->uni_client_account,
3666 r_t->ptr_client_account, ps, depth))
3667 return False;
3669 if (!prs_align(ps))
3670 return False;
3672 if (!prs_uint32("mask", ps, depth, &r_t->mask))
3673 return False;
3675 if (!prs_align(ps))
3676 return False;
3678 if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name))
3679 return False;
3681 if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name,
3682 r_t->ptr_domain_name, ps, depth))
3683 return False;
3685 if (!prs_align(ps))
3686 return False;
3688 if (!prs_uint32("ptr_domain_guid", ps, depth, &r_t->ptr_domain_guid))
3689 return False;
3691 if (UNMARSHALLING(ps) && (r_t->ptr_domain_guid)) {
3692 r_t->domain_guid = PRS_ALLOC_MEM(ps, struct GUID, 1);
3693 if (r_t->domain_guid == NULL)
3694 return False;
3697 if ((r_t->ptr_domain_guid) &&
3698 (!smb_io_uuid("domain_guid", r_t->domain_guid, ps, depth)))
3699 return False;
3701 if (!prs_align(ps))
3702 return False;
3704 if (!prs_uint32("ptr_site_name", ps, depth, &r_t->ptr_site_name))
3705 return False;
3707 if (!smb_io_unistr2("site_name", &r_t->uni_site_name,
3708 r_t->ptr_site_name, ps, depth))
3709 return False;
3711 if (!prs_align(ps))
3712 return False;
3714 if (!prs_uint32("flags", ps, depth, &r_t->flags))
3715 return False;
3717 return True;
3722 /*******************************************************************
3723 Inits a NET_R_DSR_GETDCNAME structure.
3724 ********************************************************************/
3725 void init_net_r_dsr_getdcname(NET_R_DSR_GETDCNAME *r_t, const char *dc_unc,
3726 const char *dc_address, int32 dc_address_type,
3727 struct GUID domain_guid, const char *domain_name,
3728 const char *forest_name, uint32 dc_flags,
3729 const char *dc_site_name,
3730 const char *client_site_name)
3732 DEBUG(5, ("init_net_q_dsr_getdcname\n"));
3734 r_t->ptr_dc_unc = (dc_unc != NULL);
3735 init_unistr2(&r_t->uni_dc_unc, dc_unc, UNI_STR_TERMINATE);
3737 r_t->ptr_dc_address = (dc_address != NULL);
3738 init_unistr2(&r_t->uni_dc_address, dc_address, UNI_STR_TERMINATE);
3740 r_t->dc_address_type = dc_address_type;
3741 r_t->domain_guid = domain_guid;
3743 r_t->ptr_domain_name = (domain_name != NULL);
3744 init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE);
3746 r_t->ptr_forest_name = (forest_name != NULL);
3747 init_unistr2(&r_t->uni_forest_name, forest_name, UNI_STR_TERMINATE);
3749 r_t->dc_flags = dc_flags;
3751 r_t->ptr_dc_site_name = (dc_site_name != NULL);
3752 init_unistr2(&r_t->uni_dc_site_name, dc_site_name, UNI_STR_TERMINATE);
3754 r_t->ptr_client_site_name = (client_site_name != NULL);
3755 init_unistr2(&r_t->uni_client_site_name, client_site_name,
3756 UNI_STR_TERMINATE);
3759 /*******************************************************************
3760 Reads or writes an NET_R_DSR_GETDCNAME structure.
3761 ********************************************************************/
3763 bool net_io_r_dsr_getdcname(const char *desc, NET_R_DSR_GETDCNAME *r_t,
3764 prs_struct *ps, int depth)
3766 uint32 info_ptr = 1;
3768 if (r_t == NULL)
3769 return False;
3771 prs_debug(ps, depth, desc, "net_io_r_dsr_getdcname");
3772 depth++;
3774 /* The reply contains *just* an info struct, this is the ptr to it */
3775 if (!prs_uint32("info_ptr", ps, depth, &info_ptr))
3776 return False;
3778 if (info_ptr == 0)
3779 return False;
3781 if (!prs_uint32("ptr_dc_unc", ps, depth, &r_t->ptr_dc_unc))
3782 return False;
3784 if (!prs_uint32("ptr_dc_address", ps, depth, &r_t->ptr_dc_address))
3785 return False;
3787 if (!prs_int32("dc_address_type", ps, depth, &r_t->dc_address_type))
3788 return False;
3790 if (!smb_io_uuid("domain_guid", &r_t->domain_guid, ps, depth))
3791 return False;
3793 if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name))
3794 return False;
3796 if (!prs_uint32("ptr_forest_name", ps, depth, &r_t->ptr_forest_name))
3797 return False;
3799 if (!prs_uint32("dc_flags", ps, depth, &r_t->dc_flags))
3800 return False;
3802 if (!prs_uint32("ptr_dc_site_name", ps, depth, &r_t->ptr_dc_site_name))
3803 return False;
3805 if (!prs_uint32("ptr_client_site_name", ps, depth,
3806 &r_t->ptr_client_site_name))
3807 return False;
3809 if (!prs_align(ps))
3810 return False;
3812 if (!smb_io_unistr2("dc_unc", &r_t->uni_dc_unc,
3813 r_t->ptr_dc_unc, ps, depth))
3814 return False;
3816 if (!prs_align(ps))
3817 return False;
3819 if (!smb_io_unistr2("dc_address", &r_t->uni_dc_address,
3820 r_t->ptr_dc_address, ps, depth))
3821 return False;
3823 if (!prs_align(ps))
3824 return False;
3826 if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name,
3827 r_t->ptr_domain_name, ps, depth))
3828 return False;
3830 if (!prs_align(ps))
3831 return False;
3833 if (!smb_io_unistr2("forest_name", &r_t->uni_forest_name,
3834 r_t->ptr_forest_name, ps, depth))
3835 return False;
3837 if (!prs_align(ps))
3838 return False;
3840 if (!smb_io_unistr2("dc_site_name", &r_t->uni_dc_site_name,
3841 r_t->ptr_dc_site_name, ps, depth))
3842 return False;
3844 if (!prs_align(ps))
3845 return False;
3847 if (!smb_io_unistr2("client_site_name", &r_t->uni_client_site_name,
3848 r_t->ptr_client_site_name, ps, depth))
3849 return False;
3851 if (!prs_align(ps))
3852 return False;
3854 if (!prs_werror("result", ps, depth, &r_t->result))
3855 return False;
3857 return True;
3860 /*******************************************************************
3861 Inits a NET_Q_DSR_GETSITENAME structure.
3862 ********************************************************************/
3864 void init_net_q_dsr_getsitename(NET_Q_DSR_GETSITENAME *r_t, const char *computer_name)
3866 DEBUG(5, ("init_net_q_dsr_getsitename\n"));
3868 r_t->ptr_computer_name = (computer_name != NULL);
3869 init_unistr2(&r_t->uni_computer_name, computer_name, UNI_STR_TERMINATE);
3872 /*******************************************************************
3873 Reads or writes an NET_Q_DSR_GETSITENAME structure.
3874 ********************************************************************/
3876 bool net_io_q_dsr_getsitename(const char *desc, NET_Q_DSR_GETSITENAME *r_t,
3877 prs_struct *ps, int depth)
3879 if (r_t == NULL)
3880 return False;
3882 prs_debug(ps, depth, desc, "net_io_q_dsr_getsitename");
3883 depth++;
3885 if (!prs_uint32("ptr_computer_name", ps, depth, &r_t->ptr_computer_name))
3886 return False;
3888 if (!smb_io_unistr2("computer_name", &r_t->uni_computer_name,
3889 r_t->ptr_computer_name, ps, depth))
3890 return False;
3892 if (!prs_align(ps))
3893 return False;
3895 return True;
3898 /*******************************************************************
3899 Reads or writes an NET_R_DSR_GETSITENAME structure.
3900 ********************************************************************/
3902 bool net_io_r_dsr_getsitename(const char *desc, NET_R_DSR_GETSITENAME *r_t,
3903 prs_struct *ps, int depth)
3905 if (r_t == NULL)
3906 return False;
3908 prs_debug(ps, depth, desc, "net_io_r_dsr_getsitename");
3909 depth++;
3911 if (!prs_uint32("ptr_site_name", ps, depth, &r_t->ptr_site_name))
3912 return False;
3914 if (!prs_align(ps))
3915 return False;
3917 if (!smb_io_unistr2("site_name", &r_t->uni_site_name,
3918 r_t->ptr_site_name, ps, depth))
3919 return False;
3921 if (!prs_align(ps))
3922 return False;
3924 if (!prs_werror("result", ps, depth, &r_t->result))
3925 return False;
3927 return True;