Fixed up the join W2K client to a domain code. We're back with the functionality
[Samba.git] / source / rpc_parse / parse_samr.c
blob703f0431d842ba5112a3e2d52dd9e52fe9ce4415
1 /*
2 * Unix SMB/Netbios implementation.
3 * Version 1.9.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-2000,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
7 * Copyright (C) Paul Ashton 1997-2000,
8 * Copyright (C) Elrond 2000,
9 * Copyright (C) Jeremy Allison 2001
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "includes.h"
28 #include "rpc_parse.h"
29 #include "rpc_client.h"
30 #include "nterr.h"
32 extern int DEBUGLEVEL;
34 /*******************************************************************
35 inits a SAMR_Q_CLOSE_HND structure.
36 ********************************************************************/
38 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
40 DEBUG(5, ("init_samr_q_close_hnd\n"));
42 q_c->pol = *hnd;
45 /*******************************************************************
46 reads or writes a structure.
47 ********************************************************************/
49 BOOL samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND * q_u,
50 prs_struct *ps, int depth)
52 if (q_u == NULL)
53 return False;
55 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
56 depth++;
58 if(!prs_align(ps))
59 return False;
61 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
64 /*******************************************************************
65 reads or writes a structure.
66 ********************************************************************/
68 BOOL samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND * r_u,
69 prs_struct *ps, int depth)
71 if (r_u == NULL)
72 return False;
74 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
75 depth++;
77 if(!prs_align(ps))
78 return False;
80 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
81 return False;
83 if(!prs_uint32("status", ps, depth, &r_u->status))
84 return False;
86 return True;
89 /*******************************************************************
90 inits a SAMR_Q_LOOKUP_DOMAIN structure.
91 ********************************************************************/
93 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
94 POLICY_HND *pol, char *dom_name)
96 int len_name = strlen(dom_name);
98 DEBUG(5, ("init_samr_q_lookup_domain\n"));
100 q_u->connect_pol = *pol;
102 init_uni_hdr(&q_u->hdr_domain, len_name);
103 init_unistr2(&q_u->uni_domain, dom_name, len_name);
106 /*******************************************************************
107 reads or writes a structure.
108 ********************************************************************/
109 BOOL samr_io_q_lookup_domain(char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
110 prs_struct *ps, int depth)
112 if (q_u == NULL)
113 return False;
115 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
116 depth++;
118 if(!prs_align(ps))
119 return False;
121 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
122 return False;
124 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
125 return False;
127 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
128 return False;
130 return True;
133 /*******************************************************************
134 inits a SAMR_R_LOOKUP_DOMAIN structure.
135 ********************************************************************/
137 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
138 DOM_SID *dom_sid, uint32 status)
140 DEBUG(5, ("init_samr_r_lookup_domain\n"));
142 r_u->status = status;
143 r_u->ptr_sid = 0;
144 if (status == 0x0) {
145 r_u->ptr_sid = 1;
146 init_dom_sid2(&r_u->dom_sid, dom_sid);
150 /*******************************************************************
151 reads or writes a structure.
152 ********************************************************************/
154 BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
155 prs_struct *ps, int depth)
157 if (r_u == NULL)
158 return False;
160 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
161 depth++;
163 if(!prs_align(ps))
164 return False;
166 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
167 return False;
169 if (r_u->ptr_sid != 0) {
170 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
171 return False;
172 if(!prs_align(ps))
173 return False;
176 if(!prs_uint32("status", ps, depth, &r_u->status))
177 return False;
179 return True;
182 /*******************************************************************
183 reads or writes a structure.
184 ********************************************************************/
186 void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
188 DEBUG(5, ("samr_init_samr_q_unknown_2d\n"));
190 q_u->dom_pol = *dom_pol;
191 init_dom_sid2(&q_u->sid, sid);
194 /*******************************************************************
195 reads or writes a structure.
196 ********************************************************************/
198 BOOL samr_io_q_unknown_2d(char *desc, SAMR_Q_UNKNOWN_2D * q_u,
199 prs_struct *ps, int depth)
201 if (q_u == NULL)
202 return False;
204 prs_debug(ps, depth, desc, "samr_io_q_unknown_2d");
205 depth++;
207 if(!prs_align(ps))
208 return False;
210 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
211 return False;
213 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
214 return False;
216 if(!prs_align(ps))
217 return False;
219 return True;
222 /*******************************************************************
223 reads or writes a structure.
224 ********************************************************************/
226 BOOL samr_io_r_unknown_2d(char *desc, SAMR_R_UNKNOWN_2D * r_u,
227 prs_struct *ps, int depth)
229 if (r_u == NULL)
230 return False;
232 prs_debug(ps, depth, desc, "samr_io_r_unknown_2d");
233 depth++;
235 if(!prs_align(ps))
236 return False;
238 if(!prs_uint32("status", ps, depth, &r_u->status))
239 return False;
241 return True;
244 /*******************************************************************
245 reads or writes a structure.
246 ********************************************************************/
248 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
249 POLICY_HND *pol, uint32 flags,
250 DOM_SID *sid)
252 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
254 q_u->pol = *pol;
255 q_u->flags = flags;
256 init_dom_sid2(&q_u->dom_sid, sid);
259 /*******************************************************************
260 reads or writes a structure.
261 ********************************************************************/
263 BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
264 prs_struct *ps, int depth)
266 if (q_u == NULL)
267 return False;
269 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
270 depth++;
272 if(!prs_align(ps))
273 return False;
275 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
276 return False;
278 if(!prs_uint32("flags", ps, depth, &q_u->flags))
279 return False;
281 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
282 return False;
284 return True;
287 /*******************************************************************
288 reads or writes a structure.
289 ********************************************************************/
291 BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN * r_u,
292 prs_struct *ps, int depth)
294 if (r_u == NULL)
295 return False;
297 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
298 depth++;
300 if(!prs_align(ps))
301 return False;
303 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
304 return False;
306 if(!prs_uint32("status", ps, depth, &r_u->status))
307 return False;
309 return True;
312 /*******************************************************************
313 reads or writes a structure.
314 ********************************************************************/
316 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
317 POLICY_HND *user_pol)
319 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
321 q_u->user_pol = *user_pol;
324 /*******************************************************************
325 reads or writes a structure.
326 ********************************************************************/
328 BOOL samr_io_q_get_usrdom_pwinfo(char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
329 prs_struct *ps, int depth)
331 if (q_u == NULL)
332 return False;
334 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
335 depth++;
337 if(!prs_align(ps))
338 return False;
340 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
343 /*******************************************************************
344 Init.
345 ********************************************************************/
347 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, uint32 status)
349 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
351 r_u->unknown_0 = 0x0000;
352 r_u->unknown_1 = 0x0015;
353 r_u->unknown_2 = 0x00000000;
355 r_u->status = status;
358 /*******************************************************************
359 reads or writes a structure.
360 ********************************************************************/
362 BOOL samr_io_r_get_usrdom_pwinfo(char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
363 prs_struct *ps, int depth)
365 if (r_u == NULL)
366 return False;
368 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
369 depth++;
371 if(!prs_align(ps))
372 return False;
374 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
375 return False;
376 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
377 return False;
378 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
379 return False;
380 if(!prs_uint32("status ", ps, depth, &r_u->status))
381 return False;
383 return True;
386 /*******************************************************************
387 reads or writes a structure.
388 ********************************************************************/
390 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
391 POLICY_HND *user_pol, uint32 sec_info)
393 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
395 q_u->user_pol = *user_pol;
396 q_u->sec_info = sec_info;
400 /*******************************************************************
401 reads or writes a structure.
402 ********************************************************************/
404 BOOL samr_io_q_query_sec_obj(char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
405 prs_struct *ps, int depth)
407 if (q_u == NULL)
408 return False;
410 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
411 depth++;
413 if(!prs_align(ps))
414 return False;
416 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
417 return False;
419 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
420 return False;
422 return True;
425 /*******************************************************************
426 reads or writes a structure.
427 ********************************************************************/
429 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
430 POLICY_HND *domain_pol, uint16 switch_value)
432 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
434 q_u->domain_pol = *domain_pol;
435 q_u->switch_value = switch_value;
438 /*******************************************************************
439 reads or writes a structure.
440 ********************************************************************/
442 BOOL samr_io_q_query_dom_info(char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
443 prs_struct *ps, int depth)
445 if (q_u == NULL)
446 return False;
448 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
449 depth++;
451 if(!prs_align(ps))
452 return False;
454 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
455 return False;
457 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
458 return False;
460 return True;
464 /*******************************************************************
465 inits a structure.
466 ********************************************************************/
468 void init_unk_info3(SAM_UNK_INFO_3 * u_3)
470 u_3->unknown_0 = 0x00000000;
471 u_3->unknown_1 = 0x80000000;
474 /*******************************************************************
475 reads or writes a structure.
476 ********************************************************************/
478 static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 * u_3,
479 prs_struct *ps, int depth)
481 if (u_3 == NULL)
482 return False;
484 prs_debug(ps, depth, desc, "sam_io_unk_info3");
485 depth++;
487 if(!prs_uint32("unknown_0", ps, depth, &u_3->unknown_0)) /* 0x0000 0000 */
488 return False;
489 if(!prs_uint32("unknown_1", ps, depth, &u_3->unknown_1)) /* 0x8000 0000 */
490 return False;
492 return True;
495 /*******************************************************************
496 inits a structure.
497 ********************************************************************/
499 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
501 u_6->unknown_0 = 0x00000000;
502 u_6->ptr_0 = 1;
503 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
506 /*******************************************************************
507 reads or writes a structure.
508 ********************************************************************/
510 static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 * u_6,
511 prs_struct *ps, int depth)
513 if (u_6 == NULL)
514 return False;
516 prs_debug(ps, depth, desc, "sam_io_unk_info6");
517 depth++;
519 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
520 return False;
521 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
522 return False;
523 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
524 return False;
526 return True;
529 /*******************************************************************
530 inits a structure.
531 ********************************************************************/
533 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
535 u_7->unknown_0 = 0x0003;
538 /*******************************************************************
539 reads or writes a structure.
540 ********************************************************************/
542 static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 * u_7,
543 prs_struct *ps, int depth)
545 if (u_7 == NULL)
546 return False;
548 prs_debug(ps, depth, desc, "sam_io_unk_info7");
549 depth++;
551 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
552 return False;
554 return True;
557 /*******************************************************************
558 inits a structure.
559 ********************************************************************/
561 void init_unk_info12(SAM_UNK_INFO_12 * u_12)
563 u_12->unknown_0 = 0xcf1dcc00;
564 u_12->unknown_1 = 0xfffffffb;
565 u_12->unknown_2 = 0xcf1dcc00;
566 u_12->unknown_3 = 0xfffffffb;
568 u_12->unknown_4 = 0x8a880000;
571 /*******************************************************************
572 reads or writes a structure.
573 ********************************************************************/
575 static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
576 prs_struct *ps, int depth)
578 if (u_12 == NULL)
579 return False;
581 prs_debug(ps, depth, desc, "sam_io_unk_info12");
582 depth++;
584 if(!prs_uint32("unknown_0", ps, depth, &u_12->unknown_0))
585 return False;
586 if(!prs_uint32("unknown_1", ps, depth, &u_12->unknown_1))
587 return False;
588 if(!prs_uint32("unknown_2", ps, depth, &u_12->unknown_2))
589 return False;
590 if(!prs_uint32("unknown_3", ps, depth, &u_12->unknown_3))
591 return False;
592 if(!prs_uint32("unknown_4", ps, depth, &u_12->unknown_4))
593 return False;
595 return True;
598 /*******************************************************************
599 inits a structure.
600 ********************************************************************/
601 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
602 char *domain, char *server,
603 uint32 seq_num)
605 int len_domain = strlen(domain);
606 int len_server = strlen(server);
608 u_2->unknown_0 = 0x00000000;
609 u_2->unknown_1 = 0x80000000;
610 u_2->unknown_2 = 0x00000000;
612 u_2->ptr_0 = 1;
613 init_uni_hdr(&u_2->hdr_domain, len_domain);
614 init_uni_hdr(&u_2->hdr_server, len_server);
616 u_2->seq_num = seq_num;
617 u_2->unknown_3 = 0x00000000;
619 u_2->unknown_4 = 0x00000001;
620 u_2->unknown_5 = 0x00000003;
621 u_2->unknown_6 = 0x00000001;
622 u_2->num_domain_usrs = MAX_SAM_ENTRIES;
623 u_2->num_domain_grps = MAX_SAM_ENTRIES;
624 u_2->num_local_grps = MAX_SAM_ENTRIES;
626 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
628 init_unistr2(&u_2->uni_domain, domain, len_domain);
629 init_unistr2(&u_2->uni_server, server, len_server);
632 /*******************************************************************
633 reads or writes a structure.
634 ********************************************************************/
636 static BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 * u_2,
637 prs_struct *ps, int depth)
639 if (u_2 == NULL)
640 return False;
642 prs_debug(ps, depth, desc, "sam_io_unk_info2");
643 depth++;
645 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
646 return False;
647 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
648 return False;
649 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
650 return False;
652 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
653 return False;
654 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
655 return False;
656 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
657 return False;
659 /* put all the data in here, at the moment, including what the above
660 pointer is referring to
663 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
664 return False;
665 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
666 return False;
668 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
669 return False;
670 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
671 return False;
672 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
673 return False;
674 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
675 return False;
676 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
677 return False;
678 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
679 return False;
681 if(!prs_uint8s(False, "padding", ps, depth, u_2->padding,sizeof(u_2->padding)))
682 return False;
684 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
685 return False;
686 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
687 return False;
689 return True;
692 /*******************************************************************
693 inits a structure.
694 ********************************************************************/
696 void init_unk_info1(SAM_UNK_INFO_1 * u_1)
698 memset(u_1->padding, 0, sizeof(u_1->padding)); /* 12 bytes zeros */
699 u_1->unknown_1 = 0x80000000;
700 u_1->unknown_2 = 0x00000000;
703 /*******************************************************************
704 reads or writes a structure.
705 ********************************************************************/
707 static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 * u_1,
708 prs_struct *ps, int depth)
710 if (u_1 == NULL)
711 return False;
713 prs_debug(ps, depth, desc, "sam_io_unk_info1");
714 depth++;
716 if(!prs_uint8s(False, "padding", ps, depth, u_1->padding, sizeof(u_1->padding)))
717 return False;
719 if(!prs_uint32("unknown_1", ps, depth, &u_1->unknown_1)) /* 0x8000 0000 */
720 return False;
721 if(!prs_uint32("unknown_2", ps, depth, &u_1->unknown_2)) /* 0x0000 0000 */
722 return False;
724 return True;
727 /*******************************************************************
728 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
729 ********************************************************************/
731 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
732 uint16 switch_value, SAM_UNK_CTR * ctr,
733 uint32 status)
735 DEBUG(5, ("init_samr_r_query_dom_info\n"));
737 r_u->ptr_0 = 0;
738 r_u->switch_value = 0;
739 r_u->status = status; /* return status */
741 if (status == 0) {
742 r_u->switch_value = switch_value;
743 r_u->ptr_0 = 1;
744 r_u->ctr = ctr;
748 /*******************************************************************
749 reads or writes a structure.
750 ********************************************************************/
752 BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
753 prs_struct *ps, int depth)
755 if (r_u == NULL)
756 return False;
758 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
759 depth++;
761 if(!prs_align(ps))
762 return False;
764 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
765 return False;
767 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
768 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
769 return False;
770 if(!prs_align(ps))
771 return False;
773 switch (r_u->switch_value) {
774 case 0x0c:
775 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
776 return False;
777 break;
778 case 0x07:
779 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
780 return False;
781 break;
782 case 0x06:
783 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
784 return False;
785 break;
786 case 0x03:
787 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
788 return False;
789 break;
790 case 0x02:
791 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
792 return False;
793 break;
794 case 0x01:
795 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
796 return False;
797 break;
798 default:
799 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
800 r_u->switch_value));
801 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
802 return False;
806 if(!prs_align(ps))
807 return False;
809 if(!prs_uint32("status", ps, depth, &r_u->status))
810 return False;
812 return True;
815 /*******************************************************************
816 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
817 ********************************************************************/
819 BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
820 prs_struct *ps, int depth)
822 if (r_u == NULL)
823 return False;
825 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
826 depth++;
828 if(!prs_align(ps))
829 return False;
831 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
832 return False;
833 if (r_u->ptr != 0) {
834 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
835 return False;
838 if(!prs_uint32("status", ps, depth, &r_u->status))
839 return False;
841 return True;
844 /*******************************************************************
845 reads or writes a SAM_STR1 structure.
846 ********************************************************************/
848 static BOOL sam_io_sam_str1(char *desc, SAM_STR1 * sam, uint32 acct_buf,
849 uint32 name_buf, uint32 desc_buf,
850 prs_struct *ps, int depth)
852 if (sam == NULL)
853 return False;
855 prs_debug(ps, depth, desc, "sam_io_sam_str1");
856 depth++;
858 if(!prs_align(ps))
859 return False;
860 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
861 return False;
863 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
864 return False;
866 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
867 return False;
869 return True;
872 /*******************************************************************
873 inits a SAM_ENTRY1 structure.
874 ********************************************************************/
876 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
877 uint32 len_sam_name, uint32 len_sam_full,
878 uint32 len_sam_desc, uint32 rid_user,
879 uint16 acb_info)
881 DEBUG(5, ("init_sam_entry1\n"));
883 sam->user_idx = user_idx;
884 sam->rid_user = rid_user;
885 sam->acb_info = acb_info;
886 sam->pad = 0;
888 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
889 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
890 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
893 /*******************************************************************
894 reads or writes a SAM_ENTRY1 structure.
895 ********************************************************************/
897 static BOOL sam_io_sam_entry1(char *desc, SAM_ENTRY1 * sam,
898 prs_struct *ps, int depth)
900 if (sam == NULL)
901 return False;
903 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
904 depth++;
906 if(!prs_align(ps))
907 return False;
909 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
910 return False;
912 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
913 return False;
914 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
915 return False;
916 if(!prs_uint16("pad ", ps, depth, &sam->pad))
917 return False;
919 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
920 return False;
921 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
922 return False;
923 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
924 return False;
926 return True;
929 /*******************************************************************
930 reads or writes a SAM_STR2 structure.
931 ********************************************************************/
933 static BOOL sam_io_sam_str2(char *desc, SAM_STR2 * sam, uint32 acct_buf,
934 uint32 desc_buf, prs_struct *ps, int depth)
936 if (sam == NULL)
937 return False;
939 prs_debug(ps, depth, desc, "sam_io_sam_str2");
940 depth++;
942 if(!prs_align(ps))
943 return False;
945 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
946 return False;
947 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
948 return False;
950 return True;
953 /*******************************************************************
954 inits a SAM_ENTRY2 structure.
955 ********************************************************************/
956 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
957 uint32 len_sam_name, uint32 len_sam_desc,
958 uint32 rid_user, uint16 acb_info)
960 DEBUG(5, ("init_sam_entry2\n"));
962 sam->user_idx = user_idx;
963 sam->rid_user = rid_user;
964 sam->acb_info = acb_info;
965 sam->pad = 0;
967 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
968 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
971 /*******************************************************************
972 reads or writes a SAM_ENTRY2 structure.
973 ********************************************************************/
975 static BOOL sam_io_sam_entry2(char *desc, SAM_ENTRY2 * sam,
976 prs_struct *ps, int depth)
978 if (sam == NULL)
979 return False;
981 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
982 depth++;
984 if(!prs_align(ps))
985 return False;
987 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
988 return False;
990 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
991 return False;
992 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
993 return False;
994 if(!prs_uint16("pad ", ps, depth, &sam->pad))
995 return False;
997 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
998 return False;
999 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1000 return False;
1002 return True;
1005 /*******************************************************************
1006 reads or writes a SAM_STR3 structure.
1007 ********************************************************************/
1009 static BOOL sam_io_sam_str3(char *desc, SAM_STR3 * sam, uint32 acct_buf,
1010 uint32 desc_buf, prs_struct *ps, int depth)
1012 if (sam == NULL)
1013 return False;
1015 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1016 depth++;
1018 if(!prs_align(ps))
1019 return False;
1021 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1022 return False;
1023 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1024 return False;
1026 return True;
1029 /*******************************************************************
1030 inits a SAM_ENTRY3 structure.
1031 ********************************************************************/
1033 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1034 uint32 len_grp_name, uint32 len_grp_desc,
1035 uint32 rid_grp)
1037 DEBUG(5, ("init_sam_entry3\n"));
1039 sam->grp_idx = grp_idx;
1040 sam->rid_grp = rid_grp;
1041 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1043 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1044 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1047 /*******************************************************************
1048 reads or writes a SAM_ENTRY3 structure.
1049 ********************************************************************/
1051 static BOOL sam_io_sam_entry3(char *desc, SAM_ENTRY3 * sam,
1052 prs_struct *ps, int depth)
1054 if (sam == NULL)
1055 return False;
1057 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1058 depth++;
1060 if(!prs_align(ps))
1061 return False;
1063 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1064 return False;
1066 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1067 return False;
1068 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1069 return False;
1071 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1072 return False;
1073 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1074 return False;
1076 return True;
1079 /*******************************************************************
1080 inits a SAM_ENTRY4 structure.
1081 ********************************************************************/
1083 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1084 uint32 len_acct_name)
1086 DEBUG(5, ("init_sam_entry4\n"));
1088 sam->user_idx = user_idx;
1089 init_str_hdr(&sam->hdr_acct_name, len_acct_name, len_acct_name,
1090 len_acct_name != 0);
1093 /*******************************************************************
1094 reads or writes a SAM_ENTRY4 structure.
1095 ********************************************************************/
1097 static BOOL sam_io_sam_entry4(char *desc, SAM_ENTRY4 * sam,
1098 prs_struct *ps, int depth)
1100 if (sam == NULL)
1101 return False;
1103 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1104 depth++;
1106 if(!prs_align(ps))
1107 return False;
1109 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1110 return False;
1111 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1112 return False;
1114 return True;
1117 /*******************************************************************
1118 inits a SAM_ENTRY5 structure.
1119 ********************************************************************/
1121 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1122 uint32 len_grp_name)
1124 DEBUG(5, ("init_sam_entry5\n"));
1126 sam->grp_idx = grp_idx;
1127 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1128 len_grp_name != 0);
1131 /*******************************************************************
1132 reads or writes a SAM_ENTRY5 structure.
1133 ********************************************************************/
1135 static BOOL sam_io_sam_entry5(char *desc, SAM_ENTRY5 * sam,
1136 prs_struct *ps, int depth)
1138 if (sam == NULL)
1139 return False;
1141 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1142 depth++;
1144 if(!prs_align(ps))
1145 return False;
1147 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1148 return False;
1149 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1150 return False;
1152 return True;
1155 /*******************************************************************
1156 inits a SAM_ENTRY structure.
1157 ********************************************************************/
1159 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1161 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1163 sam->rid = rid;
1164 init_uni_hdr(&sam->hdr_name, len_sam_name);
1167 /*******************************************************************
1168 reads or writes a SAM_ENTRY structure.
1169 ********************************************************************/
1171 static BOOL sam_io_sam_entry(char *desc, SAM_ENTRY * sam,
1172 prs_struct *ps, int depth)
1174 if (sam == NULL)
1175 return False;
1177 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1178 depth++;
1180 if(!prs_align(ps))
1181 return False;
1182 if(!prs_uint32("rid", ps, depth, &sam->rid))
1183 return False;
1184 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1185 return False;
1187 return True;
1190 /*******************************************************************
1191 inits a SAMR_Q_ENUM_DOM_USERS structure.
1192 ********************************************************************/
1194 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1195 uint32 start_idx,
1196 uint16 acb_mask, uint16 unk_1, uint32 size)
1198 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1200 q_e->pol = *pol;
1202 q_e->start_idx = start_idx; /* zero indicates lots */
1203 q_e->acb_mask = acb_mask;
1204 q_e->unknown_1 = unk_1;
1205 q_e->max_size = size;
1208 /*******************************************************************
1209 reads or writes a structure.
1210 ********************************************************************/
1212 BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1213 prs_struct *ps, int depth)
1215 if (q_e == NULL)
1216 return False;
1218 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1219 depth++;
1221 if(!prs_align(ps))
1222 return False;
1224 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1225 return False;
1227 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1228 return False;
1229 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1230 return False;
1231 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1232 return False;
1234 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1235 return False;
1237 return True;
1241 /*******************************************************************
1242 inits a SAMR_R_ENUM_DOM_USERS structure.
1243 ********************************************************************/
1245 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1246 uint32 next_idx, uint32 num_sam_entries)
1248 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1250 r_u->next_idx = next_idx;
1252 if (num_sam_entries != 0) {
1253 r_u->ptr_entries1 = 1;
1254 r_u->ptr_entries2 = 1;
1255 r_u->num_entries2 = num_sam_entries;
1256 r_u->num_entries3 = num_sam_entries;
1258 r_u->num_entries4 = num_sam_entries;
1259 } else {
1260 r_u->ptr_entries1 = 0;
1261 r_u->num_entries2 = num_sam_entries;
1262 r_u->ptr_entries2 = 1;
1266 /*******************************************************************
1267 reads or writes a structure.
1268 ********************************************************************/
1270 BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1271 prs_struct *ps, int depth)
1273 uint32 i;
1275 if (r_u == NULL)
1276 return False;
1278 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1279 depth++;
1281 if(!prs_align(ps))
1282 return False;
1284 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1285 return False;
1286 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1287 return False;
1289 if (r_u->ptr_entries1 != 0) {
1290 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1291 return False;
1292 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1293 return False;
1294 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1295 return False;
1297 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1298 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1299 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
1302 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1303 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1304 r_u->num_entries4 = 0;
1305 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1306 return False;
1309 for (i = 0; i < r_u->num_entries2; i++) {
1310 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1311 return False;
1314 for (i = 0; i < r_u->num_entries2; i++) {
1315 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1316 return False;
1321 if(!prs_align(ps))
1322 return False;
1324 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1325 return False;
1326 if(!prs_uint32("status", ps, depth, &r_u->status))
1327 return False;
1329 return True;
1332 /*******************************************************************
1333 inits a SAMR_Q_QUERY_DISPINFO structure.
1334 ********************************************************************/
1336 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1337 uint16 switch_level, uint32 start_idx,
1338 uint32 max_entries)
1340 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1342 q_e->domain_pol = *pol;
1344 q_e->switch_level = switch_level;
1346 q_e->start_idx = start_idx;
1347 q_e->max_entries = max_entries;
1348 q_e->max_size = 0xffff; /* Not especially useful */
1351 /*******************************************************************
1352 reads or writes a structure.
1353 ********************************************************************/
1355 BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1356 prs_struct *ps, int depth)
1358 if (q_e == NULL)
1359 return False;
1361 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1362 depth++;
1364 if(!prs_align(ps))
1365 return False;
1367 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1368 return False;
1370 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1371 return False;
1372 if(!prs_align(ps))
1373 return False;
1375 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1376 return False;
1377 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1378 return False;
1379 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1380 return False;
1382 return True;
1385 /*******************************************************************
1386 inits a SAM_DISPINFO_1 structure.
1387 ********************************************************************/
1389 void init_sam_dispinfo_1(SAM_DISPINFO_1 * sam, uint32 *num_entries,
1390 uint32 *data_size, uint32 start_idx,
1391 SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
1393 uint32 len_sam_name, len_sam_full, len_sam_desc;
1394 uint32 max_entries, max_data_size;
1395 uint32 dsize = 0;
1396 uint32 i;
1398 max_entries = *num_entries;
1399 max_data_size = *data_size;
1401 DEBUG(5, ("init_sam_dispinfo_1: max_entries: %d max_dsize: 0x%x\n",
1402 max_entries, max_data_size));
1404 for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
1405 len_sam_name = pass[i].uni_user_name.uni_str_len;
1406 len_sam_full = pass[i].uni_full_name.uni_str_len;
1407 len_sam_desc = pass[i].uni_acct_desc.uni_str_len;
1409 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1410 len_sam_name, len_sam_full, len_sam_desc,
1411 pass[i].user_rid, pass[i].acb_info);
1413 copy_unistr2(&sam->str[i].uni_acct_name, &pass[i].uni_user_name);
1414 copy_unistr2(&sam->str[i].uni_full_name, &pass[i].uni_full_name);
1415 copy_unistr2(&sam->str[i].uni_acct_desc, &pass[i].uni_acct_desc);
1417 dsize += sizeof(SAM_ENTRY1);
1418 dsize += len_sam_name + len_sam_full + len_sam_desc;
1421 *num_entries = i;
1422 *data_size = dsize;
1425 /*******************************************************************
1426 reads or writes a structure.
1427 ********************************************************************/
1429 static BOOL sam_io_sam_dispinfo_1(char *desc, SAM_DISPINFO_1 * sam,
1430 uint32 num_entries,
1431 prs_struct *ps, int depth)
1433 uint32 i;
1435 if (sam == NULL)
1436 return False;
1438 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1439 depth++;
1441 if(!prs_align(ps))
1442 return False;
1444 SMB_ASSERT_ARRAY(sam->sam, num_entries);
1446 for (i = 0; i < num_entries; i++) {
1447 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1448 return False;
1451 for (i = 0; i < num_entries; i++) {
1452 if(!sam_io_sam_str1("", &sam->str[i],
1453 sam->sam[i].hdr_acct_name.buffer,
1454 sam->sam[i].hdr_user_name.buffer,
1455 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1456 return False;
1459 return True;
1462 /*******************************************************************
1463 inits a SAM_DISPINFO_2 structure.
1464 ********************************************************************/
1466 void init_sam_dispinfo_2(SAM_DISPINFO_2 * sam, uint32 *num_entries,
1467 uint32 *data_size, uint32 start_idx,
1468 SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
1470 uint32 len_sam_name, len_sam_desc;
1471 uint32 max_entries, max_data_size;
1472 uint32 dsize = 0;
1473 uint32 i;
1475 DEBUG(5, ("init_sam_dispinfo_2\n"));
1477 max_entries = *num_entries;
1478 max_data_size = *data_size;
1480 for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
1481 len_sam_name = pass[i].uni_user_name.uni_str_len;
1482 len_sam_desc = pass[i].uni_acct_desc.uni_str_len;
1484 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1485 len_sam_name, len_sam_desc,
1486 pass[i].user_rid, pass[i].acb_info);
1488 copy_unistr2(&sam->str[i].uni_srv_name,
1489 &pass[i].uni_user_name);
1490 copy_unistr2(&sam->str[i].uni_srv_desc,
1491 &pass[i].uni_acct_desc);
1493 dsize += sizeof(SAM_ENTRY2);
1494 dsize += len_sam_name + len_sam_desc;
1497 *num_entries = i;
1498 *data_size = dsize;
1501 /*******************************************************************
1502 reads or writes a structure.
1503 ********************************************************************/
1505 static BOOL sam_io_sam_dispinfo_2(char *desc, SAM_DISPINFO_2 * sam,
1506 uint32 num_entries,
1507 prs_struct *ps, int depth)
1509 uint32 i;
1511 if (sam == NULL)
1512 return False;
1514 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1515 depth++;
1517 if(!prs_align(ps))
1518 return False;
1520 SMB_ASSERT_ARRAY(sam->sam, num_entries);
1522 for (i = 0; i < num_entries; i++) {
1523 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1524 return False;
1527 for (i = 0; i < num_entries; i++) {
1528 if(!sam_io_sam_str2("", &sam->str[i],
1529 sam->sam[i].hdr_srv_name.buffer,
1530 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1531 return False;
1534 return True;
1537 /*******************************************************************
1538 inits a SAM_DISPINFO_3 structure.
1539 ********************************************************************/
1541 void init_sam_dispinfo_3(SAM_DISPINFO_3 * sam, uint32 *num_entries,
1542 uint32 *data_size, uint32 start_idx,
1543 DOMAIN_GRP * grp)
1545 uint32 len_sam_name, len_sam_desc;
1546 uint32 max_entries, max_data_size;
1547 uint32 dsize = 0;
1548 uint32 i;
1550 DEBUG(5, ("init_sam_dispinfo_3\n"));
1552 max_entries = *num_entries;
1553 max_data_size = *data_size;
1555 for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
1556 len_sam_name = strlen(grp[i].name);
1557 len_sam_desc = strlen(grp[i].comment);
1559 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp[i].rid);
1561 init_unistr2(&sam->str[i].uni_grp_name, grp[i].name, len_sam_name);
1562 init_unistr2(&sam->str[i].uni_grp_desc, grp[i].comment, len_sam_desc);
1564 dsize += sizeof(SAM_ENTRY3);
1565 dsize += (len_sam_name + len_sam_desc) * 2;
1566 dsize += 14;
1569 *num_entries = i;
1570 *data_size = dsize;
1573 /*******************************************************************
1574 reads or writes a structure.
1575 ********************************************************************/
1577 static BOOL sam_io_sam_dispinfo_3(char *desc, SAM_DISPINFO_3 * sam,
1578 uint32 num_entries,
1579 prs_struct *ps, int depth)
1581 uint32 i;
1583 if (sam == NULL)
1584 return False;
1586 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1587 depth++;
1589 if(!prs_align(ps))
1590 return False;
1592 SMB_ASSERT_ARRAY(sam->sam, num_entries);
1594 for (i = 0; i < num_entries; i++) {
1595 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1596 return False;
1599 for (i = 0; i < num_entries; i++) {
1600 if(!sam_io_sam_str3("", &sam->str[i],
1601 sam->sam[i].hdr_grp_name.buffer,
1602 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1603 return False;
1606 return True;
1609 /*******************************************************************
1610 inits a SAM_DISPINFO_4 structure.
1611 ********************************************************************/
1613 void init_sam_dispinfo_4(SAM_DISPINFO_4 * sam, uint32 *num_entries,
1614 uint32 *data_size, uint32 start_idx,
1615 SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
1617 fstring sam_name;
1618 uint32 len_sam_name;
1619 uint32 max_entries, max_data_size;
1620 uint32 dsize = 0;
1621 uint32 i;
1623 DEBUG(5, ("init_sam_dispinfo_4\n"));
1625 max_entries = *num_entries;
1626 max_data_size = *data_size;
1628 for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
1629 len_sam_name = pass[i].uni_user_name.uni_str_len;
1631 init_sam_entry4(&sam->sam[i], start_idx + i + 1,
1632 len_sam_name);
1634 unistr2_to_ascii(sam_name, &pass[i].uni_user_name,
1635 sizeof(sam_name));
1636 init_string2(&sam->str[i].acct_name, sam_name,
1637 len_sam_name);
1639 dsize += sizeof(SAM_ENTRY4);
1640 dsize += len_sam_name;
1643 *num_entries = i;
1644 *data_size = dsize;
1647 /*******************************************************************
1648 reads or writes a structure.
1649 ********************************************************************/
1651 static BOOL sam_io_sam_dispinfo_4(char *desc, SAM_DISPINFO_4 * sam,
1652 uint32 num_entries,
1653 prs_struct *ps, int depth)
1655 uint32 i;
1657 if (sam == NULL)
1658 return False;
1660 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1661 depth++;
1663 if(!prs_align(ps))
1664 return False;
1666 SMB_ASSERT_ARRAY(sam->sam, num_entries);
1668 for (i = 0; i < num_entries; i++) {
1669 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1670 return False;
1673 for (i = 0; i < num_entries; i++) {
1674 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1675 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1676 return False;
1677 if(!prs_align(ps))
1678 return False;
1681 return True;
1684 /*******************************************************************
1685 inits a SAM_DISPINFO_5 structure.
1686 ********************************************************************/
1688 void init_sam_dispinfo_5(SAM_DISPINFO_5 * sam, uint32 *num_entries,
1689 uint32 *data_size, uint32 start_idx,
1690 DOMAIN_GRP * grp)
1692 uint32 len_sam_name;
1693 uint32 max_entries, max_data_size;
1694 uint32 dsize = 0;
1695 uint32 i;
1697 DEBUG(5, ("init_sam_dispinfo_5\n"));
1699 max_entries = *num_entries;
1700 max_data_size = *data_size;
1702 for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
1703 len_sam_name = strlen(grp[i].name);
1705 init_sam_entry5(&sam->sam[i], start_idx + i + 1,
1706 len_sam_name);
1708 init_string2(&sam->str[i].grp_name, grp[i].name,
1709 len_sam_name);
1711 dsize += sizeof(SAM_ENTRY5);
1712 dsize += len_sam_name;
1715 *num_entries = i;
1716 *data_size = dsize;
1719 /*******************************************************************
1720 reads or writes a structure.
1721 ********************************************************************/
1723 static BOOL sam_io_sam_dispinfo_5(char *desc, SAM_DISPINFO_5 * sam,
1724 uint32 num_entries,
1725 prs_struct *ps, int depth)
1727 uint32 i;
1729 if (sam == NULL)
1730 return False;
1732 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1733 depth++;
1735 if(!prs_align(ps))
1736 return False;
1738 SMB_ASSERT_ARRAY(sam->sam, num_entries);
1740 for (i = 0; i < num_entries; i++) {
1741 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1742 return False;
1745 for (i = 0; i < num_entries; i++) {
1746 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1747 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1748 return False;
1749 if(!prs_align(ps))
1750 return False;
1753 return True;
1756 /*******************************************************************
1757 inits a SAMR_R_QUERY_DISPINFO structure.
1758 ********************************************************************/
1760 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1761 uint32 num_entries, uint32 data_size,
1762 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1763 uint32 status)
1765 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1767 r_u->total_size = data_size; /* not calculated */
1768 r_u->data_size = data_size;
1770 r_u->switch_level = switch_level;
1771 r_u->num_entries = num_entries;
1773 if (num_entries==0)
1774 r_u->ptr_entries = 0;
1775 else
1776 r_u->ptr_entries = 1;
1778 r_u->num_entries2 = num_entries;
1779 r_u->ctr = ctr;
1781 r_u->status = status;
1784 /*******************************************************************
1785 reads or writes a structure.
1786 ********************************************************************/
1788 BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1789 prs_struct *ps, int depth)
1791 if (r_u == NULL)
1792 return False;
1794 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
1795 depth++;
1797 if(!prs_align(ps))
1798 return False;
1800 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
1801 return False;
1802 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
1803 return False;
1804 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
1805 return False;
1806 if(!prs_align(ps))
1807 return False;
1809 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
1810 return False;
1811 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
1812 return False;
1814 if (r_u->ptr_entries==0) {
1815 if(!prs_align(ps))
1816 return False;
1817 if(!prs_uint32("status", ps, depth, &r_u->status))
1818 return False;
1820 return True;
1823 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1824 return False;
1826 switch (r_u->switch_level) {
1827 case 0x1:
1828 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
1829 r_u->num_entries, ps, depth))
1830 return False;
1831 break;
1832 case 0x2:
1833 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
1834 r_u->num_entries, ps, depth))
1835 return False;
1836 break;
1837 case 0x3:
1838 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
1839 r_u->num_entries, ps, depth))
1840 return False;
1841 break;
1842 case 0x4:
1843 if(!sam_io_sam_dispinfo_4("user list",
1844 r_u->ctr->sam.info4,
1845 r_u->num_entries, ps, depth))
1846 return False;
1847 break;
1848 case 0x5:
1849 if(!sam_io_sam_dispinfo_5("group list",
1850 r_u->ctr->sam.info5,
1851 r_u->num_entries, ps, depth))
1852 return False;
1853 break;
1854 default:
1855 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
1856 break;
1859 if(!prs_align(ps))
1860 return False;
1861 if(!prs_uint32("status", ps, depth, &r_u->status))
1862 return False;
1864 return True;
1867 /*******************************************************************
1868 inits a SAMR_Q_OPEN_GROUP structure.
1869 ********************************************************************/
1871 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
1872 POLICY_HND *hnd,
1873 uint32 access_mask, uint32 rid)
1875 DEBUG(5, ("init_samr_q_open_group\n"));
1877 q_c->domain_pol = *hnd;
1878 q_c->access_mask = access_mask;
1879 q_c->rid_group = rid;
1882 /*******************************************************************
1883 reads or writes a structure.
1884 ********************************************************************/
1886 BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
1887 prs_struct *ps, int depth)
1889 if (q_u == NULL)
1890 return False;
1892 prs_debug(ps, depth, desc, "samr_io_q_open_group");
1893 depth++;
1895 if(!prs_align(ps))
1896 return False;
1898 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
1899 return False;
1901 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
1902 return False;
1903 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
1904 return False;
1906 return True;
1909 /*******************************************************************
1910 reads or writes a structure.
1911 ********************************************************************/
1913 BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
1914 prs_struct *ps, int depth)
1916 if (r_u == NULL)
1917 return False;
1919 prs_debug(ps, depth, desc, "samr_io_r_open_group");
1920 depth++;
1922 if(!prs_align(ps))
1923 return False;
1925 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
1926 return False;
1928 if(!prs_uint32("status", ps, depth, &r_u->status))
1929 return False;
1931 return True;
1934 /*******************************************************************
1935 inits a GROUP_INFO1 structure.
1936 ********************************************************************/
1938 void init_samr_group_info1(GROUP_INFO1 * gr1,
1939 char *acct_name, char *acct_desc,
1940 uint32 num_members)
1942 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
1943 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
1945 DEBUG(5, ("init_samr_group_info1\n"));
1947 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
1949 gr1->unknown_1 = 0x3;
1950 gr1->num_members = num_members;
1952 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
1954 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
1955 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
1958 /*******************************************************************
1959 reads or writes a structure.
1960 ********************************************************************/
1962 BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
1963 prs_struct *ps, int depth)
1965 if (gr1 == NULL)
1966 return False;
1968 prs_debug(ps, depth, desc, "samr_io_group_info1");
1969 depth++;
1971 if(!prs_align(ps))
1972 return False;
1974 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
1975 return False;
1977 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
1978 return False;
1979 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
1980 return False;
1982 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
1983 return False;
1985 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
1986 gr1->hdr_acct_name.buffer, ps, depth))
1987 return False;
1989 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
1990 gr1->hdr_acct_desc.buffer, ps, depth))
1991 return False;
1993 return True;
1996 /*******************************************************************
1997 inits a GROUP_INFO4 structure.
1998 ********************************************************************/
2000 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2002 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2004 DEBUG(5, ("init_samr_group_info4\n"));
2006 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2007 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2010 /*******************************************************************
2011 reads or writes a structure.
2012 ********************************************************************/
2014 BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
2015 prs_struct *ps, int depth)
2017 if (gr4 == NULL)
2018 return False;
2020 prs_debug(ps, depth, desc, "samr_io_group_info4");
2021 depth++;
2023 if(!prs_align(ps))
2024 return False;
2026 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2027 return False;
2028 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2029 gr4->hdr_acct_desc.buffer, ps, depth))
2030 return False;
2032 return True;
2035 /*******************************************************************
2036 reads or writes a structure.
2037 ********************************************************************/
2039 static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR * ctr,
2040 prs_struct *ps, int depth)
2042 if (ctr == NULL)
2043 return False;
2045 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2046 depth++;
2048 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
2049 return False;
2050 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
2051 return False;
2053 switch (ctr->switch_value1) {
2054 case 1:
2055 if(!samr_io_group_info1("group_info1",
2056 &ctr->group.info1, ps, depth))
2057 return False;
2058 break;
2059 case 4:
2060 if(!samr_io_group_info4("group_info4",
2061 &ctr->group.info4, ps, depth))
2062 return False;
2063 break;
2064 default:
2065 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2066 break;
2069 return True;
2072 /*******************************************************************
2073 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2074 ********************************************************************/
2076 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2077 POLICY_HND *pol, char *acct_desc,
2078 uint32 access_mask)
2080 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2082 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2084 q_e->pol = *pol;
2086 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2087 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2089 q_e->access_mask = access_mask;
2092 /*******************************************************************
2093 reads or writes a structure.
2094 ********************************************************************/
2096 BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2097 prs_struct *ps, int depth)
2099 if (q_e == NULL)
2100 return False;
2102 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2103 depth++;
2105 if(!prs_align(ps))
2106 return False;
2108 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2109 return False;
2111 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2112 return False;
2113 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2114 q_e->hdr_acct_desc.buffer, ps, depth))
2115 return False;
2117 if(!prs_align(ps))
2118 return False;
2119 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2120 return False;
2122 return True;
2125 /*******************************************************************
2126 reads or writes a structure.
2127 ********************************************************************/
2129 BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2130 prs_struct *ps, int depth)
2132 if (r_u == NULL)
2133 return False;
2135 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2136 depth++;
2138 if(!prs_align(ps))
2139 return False;
2141 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2142 return False;
2144 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2145 return False;
2146 if(!prs_uint32("status", ps, depth, &r_u->status))
2147 return False;
2149 return True;
2152 /*******************************************************************
2153 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2154 ********************************************************************/
2156 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2157 POLICY_HND *hnd)
2159 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2161 q_c->group_pol = *hnd;
2164 /*******************************************************************
2165 reads or writes a structure.
2166 ********************************************************************/
2168 BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2169 prs_struct *ps, int depth)
2171 if (q_u == NULL)
2172 return False;
2174 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2175 depth++;
2177 if(!prs_align(ps))
2178 return False;
2180 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2181 return False;
2183 return True;
2186 /*******************************************************************
2187 reads or writes a structure.
2188 ********************************************************************/
2190 BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2191 prs_struct *ps, int depth)
2193 if (r_u == NULL)
2194 return False;
2196 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2197 depth++;
2199 if(!prs_align(ps))
2200 return False;
2202 if(!prs_uint32("status", ps, depth, &r_u->status))
2203 return False;
2205 return True;
2208 /*******************************************************************
2209 inits a SAMR_Q_DEL_GROUPMEM structure.
2210 ********************************************************************/
2212 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2213 POLICY_HND *pol, uint32 rid)
2215 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2217 q_e->pol = *pol;
2218 q_e->rid = rid;
2221 /*******************************************************************
2222 reads or writes a structure.
2223 ********************************************************************/
2225 BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2226 prs_struct *ps, int depth)
2228 if (q_e == NULL)
2229 return False;
2231 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2232 depth++;
2234 if(!prs_align(ps))
2235 return False;
2237 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2238 return False;
2240 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2241 return False;
2243 return True;
2246 /*******************************************************************
2247 inits a SAMR_R_DEL_GROUPMEM structure.
2248 ********************************************************************/
2250 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2251 uint32 status)
2253 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2255 r_u->status = status;
2258 /*******************************************************************
2259 reads or writes a structure.
2260 ********************************************************************/
2262 BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2263 prs_struct *ps, int depth)
2265 if (r_u == NULL)
2266 return False;
2268 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2269 depth++;
2271 if(!prs_align(ps))
2272 return False;
2274 if(!prs_uint32("status", ps, depth, &r_u->status))
2275 return False;
2277 return True;
2280 /*******************************************************************
2281 inits a SAMR_Q_ADD_GROUPMEM structure.
2282 ********************************************************************/
2284 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2285 POLICY_HND *pol, uint32 rid)
2287 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2289 q_e->pol = *pol;
2290 q_e->rid = rid;
2291 q_e->unknown = 0x0005;
2294 /*******************************************************************
2295 reads or writes a structure.
2296 ********************************************************************/
2298 BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2299 prs_struct *ps, int depth)
2301 if (q_e == NULL)
2302 return False;
2304 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2305 depth++;
2307 if(!prs_align(ps))
2308 return False;
2310 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2311 return False;
2313 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2314 return False;
2315 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2316 return False;
2318 return True;
2321 /*******************************************************************
2322 inits a SAMR_R_ADD_GROUPMEM structure.
2323 ********************************************************************/
2325 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2326 uint32 status)
2328 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2330 r_u->status = status;
2333 /*******************************************************************
2334 reads or writes a structure.
2335 ********************************************************************/
2337 BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2338 prs_struct *ps, int depth)
2340 if (r_u == NULL)
2341 return False;
2343 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2344 depth++;
2346 if(!prs_align(ps))
2347 return False;
2349 if(!prs_uint32("status", ps, depth, &r_u->status))
2350 return False;
2352 return True;
2355 /*******************************************************************
2356 inits a SAMR_Q_SET_GROUPINFO structure.
2357 ********************************************************************/
2359 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2360 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2362 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2364 q_e->pol = *pol;
2365 q_e->ctr = ctr;
2368 /*******************************************************************
2369 reads or writes a structure.
2370 ********************************************************************/
2372 BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2373 prs_struct *ps, int depth)
2375 if (q_e == NULL)
2376 return False;
2378 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2379 depth++;
2381 if(!prs_align(ps))
2382 return False;
2384 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2385 return False;
2387 if(!samr_group_info_ctr("ctr", q_e->ctr, ps, depth))
2388 return False;
2390 return True;
2393 /*******************************************************************
2394 inits a SAMR_R_SET_GROUPINFO structure.
2395 ********************************************************************/
2397 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, uint32 status)
2399 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2401 r_u->status = status;
2404 /*******************************************************************
2405 reads or writes a structure.
2406 ********************************************************************/
2408 BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
2409 prs_struct *ps, int depth)
2411 if (r_u == NULL)
2412 return False;
2414 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2415 depth++;
2417 if(!prs_align(ps))
2418 return False;
2420 if(!prs_uint32("status", ps, depth, &r_u->status))
2421 return False;
2423 return True;
2426 /*******************************************************************
2427 inits a SAMR_Q_QUERY_GROUPINFO structure.
2428 ********************************************************************/
2430 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2431 POLICY_HND *pol, uint16 switch_level)
2433 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2435 q_e->pol = *pol;
2437 q_e->switch_level = switch_level;
2440 /*******************************************************************
2441 reads or writes a structure.
2442 ********************************************************************/
2444 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2445 prs_struct *ps, int depth)
2447 if (q_e == NULL)
2448 return False;
2450 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2451 depth++;
2453 if(!prs_align(ps))
2454 return False;
2456 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2457 return False;
2459 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2460 return False;
2462 return True;
2465 /*******************************************************************
2466 inits a SAMR_R_QUERY_GROUPINFO structure.
2467 ********************************************************************/
2469 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2470 GROUP_INFO_CTR * ctr, uint32 status)
2472 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2474 r_u->ptr = (status == 0x0 && ctr != NULL) ? 1 : 0;
2475 r_u->ctr = ctr;
2476 r_u->status = status;
2479 /*******************************************************************
2480 reads or writes a structure.
2481 ********************************************************************/
2483 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2484 prs_struct *ps, int depth)
2486 if (r_u == NULL)
2487 return False;
2489 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2490 depth++;
2492 if(!prs_align(ps))
2493 return False;
2495 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2496 return False;
2498 if (r_u->ptr != 0) {
2499 if(!samr_group_info_ctr("ctr", r_u->ctr, ps, depth))
2500 return False;
2503 if(!prs_align(ps))
2504 return False;
2505 if(!prs_uint32("status", ps, depth, &r_u->status))
2506 return False;
2508 return True;
2511 /*******************************************************************
2512 inits a SAMR_Q_QUERY_GROUPMEM structure.
2513 ********************************************************************/
2515 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2517 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2519 q_c->group_pol = *hnd;
2522 /*******************************************************************
2523 reads or writes a structure.
2524 ********************************************************************/
2526 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2527 prs_struct *ps, int depth)
2529 if (q_u == NULL)
2530 return False;
2532 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2533 depth++;
2535 if(!prs_align(ps))
2536 return False;
2538 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2539 return False;
2541 return True;
2544 /*******************************************************************
2545 inits a SAMR_R_QUERY_GROUPMEM structure.
2546 ********************************************************************/
2548 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2549 uint32 num_entries, uint32 *rid,
2550 uint32 *attr, uint32 status)
2552 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2554 if (status == 0x0) {
2555 r_u->ptr = 1;
2556 r_u->num_entries = num_entries;
2558 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2559 r_u->ptr_rids = rid != NULL ? 1 : 0;
2561 r_u->num_rids = num_entries;
2562 r_u->rid = rid;
2564 r_u->num_attrs = num_entries;
2565 r_u->attr = attr;
2566 } else {
2567 r_u->ptr = 0;
2568 r_u->num_entries = 0;
2571 r_u->status = status;
2574 /*******************************************************************
2575 reads or writes a structure.
2576 ********************************************************************/
2578 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2579 prs_struct *ps, int depth)
2581 uint32 i;
2583 if (r_u == NULL)
2584 return False;
2586 if (UNMARSHALLING(ps))
2587 ZERO_STRUCTP(r_u);
2589 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2590 depth++;
2592 if(!prs_align(ps))
2593 return False;
2595 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2596 return False;
2597 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2598 return False;
2600 if (r_u->ptr != 0) {
2601 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2602 return False;
2603 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2604 return False;
2606 if (r_u->ptr_rids != 0) {
2607 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2608 return False;
2609 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2610 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2611 if (r_u->rid == NULL)
2612 return False;
2615 for (i = 0; i < r_u->num_rids; i++) {
2616 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2617 return False;
2621 if (r_u->ptr_attrs != 0) {
2622 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2623 return False;
2625 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2626 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2627 if (r_u->attr == NULL)
2628 return False;
2631 for (i = 0; i < r_u->num_attrs; i++) {
2632 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2633 return False;
2638 if(!prs_uint32("status", ps, depth, &r_u->status))
2639 return False;
2641 return True;
2644 /*******************************************************************
2645 inits a SAMR_Q_QUERY_USERGROUPS structure.
2646 ********************************************************************/
2648 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2649 POLICY_HND *hnd)
2651 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2653 q_u->pol = *hnd;
2656 /*******************************************************************
2657 reads or writes a structure.
2658 ********************************************************************/
2660 BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2661 prs_struct *ps, int depth)
2663 if (q_u == NULL)
2664 return False;
2666 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2667 depth++;
2669 if(!prs_align(ps))
2670 return False;
2672 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2673 return False;
2675 return True;
2678 /*******************************************************************
2679 inits a SAMR_R_QUERY_USERGROUPS structure.
2680 ********************************************************************/
2682 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2683 uint32 num_gids, DOM_GID * gid,
2684 uint32 status)
2686 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2688 if (status == 0) {
2689 r_u->ptr_0 = 1;
2690 r_u->num_entries = num_gids;
2691 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2692 r_u->num_entries2 = num_gids;
2694 r_u->gid = gid;
2695 } else {
2696 r_u->ptr_0 = 0;
2697 r_u->num_entries = 0;
2698 r_u->ptr_1 = 0;
2699 r_u->gid = NULL;
2702 r_u->status = status;
2705 /*******************************************************************
2706 reads or writes a structure.
2707 ********************************************************************/
2709 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
2710 prs_struct *ps, int depth)
2712 uint32 i;
2713 if (gid == NULL)
2714 return False;
2716 prs_debug(ps, depth, desc, "samr_io_gids");
2717 depth++;
2719 if(!prs_align(ps))
2720 return False;
2722 if(!prs_uint32("num_gids", ps, depth, num_gids))
2723 return False;
2725 if ((*num_gids) != 0) {
2726 if (UNMARSHALLING(ps)) {
2727 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
2730 if ((*gid) == NULL) {
2731 return False;
2734 for (i = 0; i < (*num_gids); i++) {
2735 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
2736 return False;
2740 return True;
2743 /*******************************************************************
2744 reads or writes a structure.
2745 ********************************************************************/
2747 BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
2748 prs_struct *ps, int depth)
2750 if (r_u == NULL)
2751 return False;
2753 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
2754 depth++;
2756 if(!prs_align(ps))
2757 return False;
2759 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
2760 return False;
2762 if (r_u->ptr_0 != 0) {
2763 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2764 return False;
2765 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
2766 return False;
2768 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
2769 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
2770 return False;
2774 if(!prs_align(ps))
2775 return False;
2776 if(!prs_uint32("status", ps, depth, &r_u->status))
2777 return False;
2779 return True;
2782 /*******************************************************************
2783 inits a SAMR_Q_ENUM_DOMAINS structure.
2784 ********************************************************************/
2786 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
2787 POLICY_HND *pol,
2788 uint32 start_idx, uint32 size)
2790 DEBUG(5, ("init_samr_q_enum_domains\n"));
2792 q_e->pol = *pol;
2794 q_e->start_idx = start_idx;
2795 q_e->max_size = size;
2798 /*******************************************************************
2799 reads or writes a structure.
2800 ********************************************************************/
2802 BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
2803 prs_struct *ps, int depth)
2805 if (q_e == NULL)
2806 return False;
2808 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
2809 depth++;
2811 if(!prs_align(ps))
2812 return False;
2814 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2815 return False;
2817 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
2818 return False;
2819 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
2820 return False;
2822 return True;
2825 /*******************************************************************
2826 inits a SAMR_R_ENUM_DOMAINS structure.
2827 ********************************************************************/
2829 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
2830 uint32 next_idx, uint32 num_sam_entries)
2832 DEBUG(5, ("init_samr_r_enum_domains\n"));
2834 r_u->next_idx = next_idx;
2836 if (num_sam_entries != 0) {
2837 r_u->ptr_entries1 = 1;
2838 r_u->ptr_entries2 = 1;
2839 r_u->num_entries2 = num_sam_entries;
2840 r_u->num_entries3 = num_sam_entries;
2842 r_u->num_entries4 = num_sam_entries;
2843 } else {
2844 r_u->ptr_entries1 = 0;
2845 r_u->num_entries2 = num_sam_entries;
2846 r_u->ptr_entries2 = 1;
2850 /*******************************************************************
2851 reads or writes a structure.
2852 ********************************************************************/
2854 BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
2855 prs_struct *ps, int depth)
2857 uint32 i;
2859 if (r_u == NULL)
2860 return False;
2862 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
2863 depth++;
2865 if(!prs_align(ps))
2866 return False;
2868 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
2869 return False;
2870 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
2871 return False;
2873 if (r_u->ptr_entries1 != 0) {
2874 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2875 return False;
2876 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
2877 return False;
2878 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
2879 return False;
2881 if (UNMARSHALLING(ps)) {
2882 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
2883 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
2886 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
2887 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
2888 r_u->num_entries4 = 0;
2889 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
2890 return False;
2893 for (i = 0; i < r_u->num_entries2; i++) {
2894 fstring tmp;
2895 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
2896 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
2897 return False;
2900 for (i = 0; i < r_u->num_entries2; i++) {
2901 fstring tmp;
2902 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
2903 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
2904 r_u->sam[i].hdr_name.buffer, ps,
2905 depth))
2906 return False;
2911 if(!prs_align(ps))
2912 return False;
2913 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
2914 return False;
2915 if(!prs_uint32("status", ps, depth, &r_u->status))
2916 return False;
2918 return True;
2921 /*******************************************************************
2922 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
2923 ********************************************************************/
2925 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
2926 POLICY_HND *pol,
2927 uint32 start_idx, uint32 size)
2929 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
2931 q_e->pol = *pol;
2933 q_e->start_idx = start_idx;
2934 q_e->max_size = size;
2937 /*******************************************************************
2938 reads or writes a structure.
2939 ********************************************************************/
2941 BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
2942 prs_struct *ps, int depth)
2944 if (q_e == NULL)
2945 return False;
2947 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
2948 depth++;
2950 if(!prs_align(ps))
2951 return False;
2953 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
2954 return False;
2956 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
2957 return False;
2958 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
2959 return False;
2961 return True;
2964 /*******************************************************************
2965 inits a SAMR_R_ENUM_DOM_GROUPS structure.
2966 ********************************************************************/
2968 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
2969 uint32 next_idx, uint32 num_sam_entries)
2971 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
2973 r_u->next_idx = next_idx;
2975 if (num_sam_entries != 0) {
2976 r_u->ptr_entries1 = 1;
2977 r_u->ptr_entries2 = 1;
2978 r_u->num_entries2 = num_sam_entries;
2979 r_u->num_entries3 = num_sam_entries;
2981 r_u->num_entries4 = num_sam_entries;
2982 } else {
2983 r_u->ptr_entries1 = 0;
2984 r_u->num_entries2 = num_sam_entries;
2985 r_u->ptr_entries2 = 1;
2989 /*******************************************************************
2990 reads or writes a structure.
2991 ********************************************************************/
2993 BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
2994 prs_struct *ps, int depth)
2996 uint32 i;
2998 if (r_u == NULL)
2999 return False;
3001 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3002 depth++;
3004 if(!prs_align(ps))
3005 return False;
3007 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3008 return False;
3009 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3010 return False;
3012 if (r_u->ptr_entries1 != 0) {
3013 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3014 return False;
3015 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3016 return False;
3017 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3018 return False;
3020 if (UNMARSHALLING(ps)) {
3021 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3022 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3025 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3026 DEBUG(0,
3027 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3028 r_u->num_entries4 = 0;
3029 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3030 return False;
3033 for (i = 0; i < r_u->num_entries2; i++) {
3034 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3035 return False;
3038 for (i = 0; i < r_u->num_entries2; i++) {
3039 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3040 r_u->sam[i].hdr_name.buffer, ps, depth))
3041 return False;
3045 if(!prs_align(ps))
3046 return False;
3047 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3048 return False;
3049 if(!prs_uint32("status", ps, depth, &r_u->status))
3050 return False;
3052 return True;
3055 /*******************************************************************
3056 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3057 ********************************************************************/
3059 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3060 POLICY_HND *pol, uint32 start_idx,
3061 uint32 size)
3063 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3065 q_e->pol = *pol;
3067 q_e->start_idx = start_idx;
3068 q_e->max_size = size;
3072 /*******************************************************************
3073 reads or writes a structure.
3074 ********************************************************************/
3076 BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3077 prs_struct *ps, int depth)
3079 if (q_e == NULL)
3080 return False;
3082 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3083 depth++;
3085 if(!prs_align(ps))
3086 return False;
3088 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3089 return False;
3091 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3092 return False;
3093 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3094 return False;
3096 return True;
3099 /*******************************************************************
3100 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3101 ********************************************************************/
3103 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3105 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3107 r_u->next_idx = next_idx;
3109 if (num_sam_entries != 0) {
3110 r_u->ptr_entries1 = 1;
3111 r_u->ptr_entries2 = 1;
3112 r_u->num_entries2 = num_sam_entries;
3113 r_u->num_entries3 = num_sam_entries;
3115 r_u->num_entries4 = num_sam_entries;
3116 } else {
3117 r_u->ptr_entries1 = 0;
3118 r_u->num_entries2 = num_sam_entries;
3119 r_u->ptr_entries2 = 1;
3123 /*******************************************************************
3124 reads or writes a structure.
3125 ********************************************************************/
3127 BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3128 prs_struct *ps, int depth)
3130 uint32 i;
3132 if (r_u == NULL)
3133 return False;
3135 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3136 depth++;
3138 if(!prs_align(ps))
3139 return False;
3141 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3142 return False;
3143 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3144 return False;
3146 if (r_u->ptr_entries1 != 0) {
3147 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3148 return False;
3149 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3150 return False;
3151 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3152 return False;
3154 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3155 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3156 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3159 if (r_u->num_entries2 != 0 &&
3160 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3161 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3162 r_u->num_entries4 = 0;
3163 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3164 return False;
3167 for (i = 0; i < r_u->num_entries2; i++) {
3168 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3169 return False;
3172 for (i = 0; i < r_u->num_entries2; i++) {
3173 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3174 r_u->sam[i].hdr_name.buffer, ps,
3175 depth))
3176 return False;
3180 if(!prs_align(ps))
3181 return False;
3182 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3183 return False;
3184 if(!prs_uint32("status", ps, depth, &r_u->status))
3185 return False;
3187 return True;
3190 /*******************************************************************
3191 inits a ALIAS_INFO3 structure.
3192 ********************************************************************/
3194 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3196 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3198 DEBUG(5, ("init_samr_alias_info3\n"));
3200 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3201 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3204 /*******************************************************************
3205 reads or writes a structure.
3206 ********************************************************************/
3208 BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
3209 prs_struct *ps, int depth)
3211 if (al3 == NULL)
3212 return False;
3214 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3215 depth++;
3217 if(!prs_align(ps))
3218 return False;
3220 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3221 return False;
3222 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3223 al3->hdr_acct_desc.buffer, ps, depth))
3224 return False;
3226 return True;
3229 /*******************************************************************
3230 reads or writes a structure.
3231 ********************************************************************/
3233 BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
3234 prs_struct *ps, int depth)
3236 if (ctr == NULL)
3237 return False;
3239 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3240 depth++;
3242 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3243 return False;
3244 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3245 return False;
3247 switch (ctr->switch_value1) {
3248 case 3:
3249 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3250 return False;
3251 break;
3252 default:
3253 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3254 break;
3257 return True;
3260 /*******************************************************************
3261 inits a SAMR_Q_QUERY_ALIASINFO structure.
3262 ********************************************************************/
3264 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3265 POLICY_HND *pol, uint16 switch_level)
3267 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3269 q_e->pol = *pol;
3270 q_e->switch_level = switch_level;
3273 /*******************************************************************
3274 reads or writes a structure.
3275 ********************************************************************/
3277 BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3278 prs_struct *ps, int depth)
3280 if (q_e == NULL)
3281 return False;
3283 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3284 depth++;
3286 if(!prs_align(ps))
3287 return False;
3289 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3290 return False;
3292 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3293 return False;
3295 return True;
3298 /*******************************************************************
3299 inits a SAMR_R_QUERY_ALIASINFO structure.
3300 ********************************************************************/
3302 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3303 ALIAS_INFO_CTR * ctr, uint32 status)
3305 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3307 r_u->ptr = (status == 0x0 && ctr != NULL) ? 1 : 0;
3308 r_u->ctr = *ctr;
3309 r_u->status = status;
3312 /*******************************************************************
3313 reads or writes a structure.
3314 ********************************************************************/
3316 BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3317 prs_struct *ps, int depth)
3319 if (r_u == NULL)
3320 return False;
3322 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3323 depth++;
3325 if(!prs_align(ps))
3326 return False;
3328 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3329 return False;
3331 if (r_u->ptr != 0) {
3332 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3333 return False;
3336 if(!prs_align(ps))
3337 return False;
3338 if(!prs_uint32("status", ps, depth, &r_u->status))
3339 return False;
3341 return True;
3344 /*******************************************************************
3345 inits a SAMR_Q_SET_ALIASINFO structure.
3346 ********************************************************************/
3348 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3349 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3351 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3353 q_u->alias_pol = *hnd;
3354 q_u->ctr = *ctr;
3357 /*******************************************************************
3358 reads or writes a structure.
3359 ********************************************************************/
3361 BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3362 prs_struct *ps, int depth)
3364 if (q_u == NULL)
3365 return False;
3367 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3368 depth++;
3370 if(!prs_align(ps))
3371 return False;
3373 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3374 return False;
3375 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3376 return False;
3378 return True;
3381 /*******************************************************************
3382 reads or writes a structure.
3383 ********************************************************************/
3385 BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
3386 prs_struct *ps, int depth)
3388 if (r_u == NULL)
3389 return False;
3391 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3392 depth++;
3394 if(!prs_align(ps))
3395 return False;
3396 if(!prs_uint32("status", ps, depth, &r_u->status))
3397 return False;
3399 return True;
3402 /*******************************************************************
3403 inits a SAMR_Q_QUERY_USERALIASES structure.
3404 ********************************************************************/
3406 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3407 POLICY_HND *hnd,
3408 uint32 num_sids,
3409 uint32 *ptr_sid, DOM_SID2 * sid)
3411 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3413 q_u->pol = *hnd;
3415 q_u->num_sids1 = num_sids;
3416 q_u->ptr = 1;
3417 q_u->num_sids2 = num_sids;
3419 q_u->ptr_sid = ptr_sid;
3420 q_u->sid = sid;
3423 /*******************************************************************
3424 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3425 ********************************************************************/
3427 BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3428 prs_struct *ps, int depth)
3430 fstring tmp;
3431 uint32 i;
3433 if (q_u == NULL)
3434 return False;
3436 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3437 depth++;
3439 if(!prs_align(ps))
3440 return False;
3442 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3443 return False;
3445 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3446 return False;
3447 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3448 return False;
3450 if (q_u->ptr==0)
3451 return True;
3453 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3454 return False;
3456 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3457 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3458 if (q_u->ptr_sid == NULL)
3459 return False;
3461 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3462 if (q_u->sid == NULL)
3463 return False;
3466 for (i = 0; i < q_u->num_sids2; i++) {
3467 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3468 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3469 return False;
3472 for (i = 0; i < q_u->num_sids2; i++) {
3473 if (q_u->ptr_sid[i] != 0) {
3474 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3475 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3476 return False;
3480 return True;
3483 /*******************************************************************
3484 inits a SAMR_R_QUERY_USERALIASES structure.
3485 ********************************************************************/
3487 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3488 uint32 num_rids, uint32 *rid,
3489 uint32 status)
3491 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3493 if (status == 0x0) {
3494 r_u->num_entries = num_rids;
3495 r_u->ptr = 1;
3496 r_u->num_entries2 = num_rids;
3498 r_u->rid = rid;
3499 } else {
3500 r_u->num_entries = 0;
3501 r_u->ptr = 0;
3502 r_u->num_entries2 = 0;
3505 r_u->status = status;
3508 /*******************************************************************
3509 reads or writes a structure.
3510 ********************************************************************/
3512 BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
3513 prs_struct *ps, int depth)
3515 fstring tmp;
3516 uint32 i;
3517 if (rid == NULL)
3518 return False;
3520 prs_debug(ps, depth, desc, "samr_io_rids");
3521 depth++;
3523 if(!prs_align(ps))
3524 return False;
3526 if(!prs_uint32("num_rids", ps, depth, num_rids))
3527 return False;
3529 if ((*num_rids) != 0) {
3530 if (UNMARSHALLING(ps)) {
3531 /* reading */
3532 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3534 if ((*rid) == NULL)
3535 return False;
3537 for (i = 0; i < (*num_rids); i++) {
3538 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3539 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3540 return False;
3544 return True;
3547 /*******************************************************************
3548 reads or writes a structure.
3549 ********************************************************************/
3551 BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3552 prs_struct *ps, int depth)
3554 if (r_u == NULL)
3555 return False;
3557 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3558 depth++;
3560 if(!prs_align(ps))
3561 return False;
3563 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3564 return False;
3565 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3566 return False;
3568 if (r_u->ptr != 0) {
3569 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3570 return False;
3573 if(!prs_align(ps))
3574 return False;
3575 if(!prs_uint32("status", ps, depth, &r_u->status))
3576 return False;
3578 return True;
3581 /*******************************************************************
3582 inits a SAMR_Q_OPEN_ALIAS structure.
3583 ********************************************************************/
3585 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3586 uint32 unknown_0, uint32 rid)
3588 DEBUG(5, ("init_samr_q_open_alias\n"));
3590 q_u->dom_pol = *pol;
3592 /* example values: 0x0000 0008 */
3593 q_u->unknown_0 = unknown_0;
3595 q_u->rid_alias = rid;
3598 /*******************************************************************
3599 reads or writes a structure.
3600 ********************************************************************/
3602 BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3603 prs_struct *ps, int depth)
3605 if (q_u == NULL)
3606 return False;
3608 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3609 depth++;
3611 if(!prs_align(ps))
3612 return False;
3614 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3615 return False;
3617 if(!prs_uint32("unknown_0", ps, depth, &q_u->unknown_0))
3618 return False;
3619 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3620 return False;
3622 return True;
3625 /*******************************************************************
3626 reads or writes a structure.
3627 ********************************************************************/
3629 BOOL samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS * r_u,
3630 prs_struct *ps, int depth)
3632 if (r_u == NULL)
3633 return False;
3635 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3636 depth++;
3638 if(!prs_align(ps))
3639 return False;
3641 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3642 return False;
3644 if(!prs_uint32("status", ps, depth, &r_u->status))
3645 return False;
3647 return True;
3650 /*******************************************************************
3651 inits a SAMR_Q_LOOKUP_RIDS structure.
3652 ********************************************************************/
3654 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3655 POLICY_HND *pol, uint32 flags,
3656 uint32 num_rids, uint32 *rid)
3658 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3660 q_u->pol = *pol;
3662 q_u->num_rids1 = num_rids;
3663 q_u->flags = flags;
3664 q_u->ptr = 0;
3665 q_u->num_rids2 = num_rids;
3666 q_u->rid = (uint32 *)talloc(ctx, num_rids * sizeof(q_u->rid[0]));
3667 if (q_u->rid == NULL) {
3668 q_u->num_rids1 = 0;
3669 q_u->num_rids2 = 0;
3673 /*******************************************************************
3674 reads or writes a structure.
3675 ********************************************************************/
3677 BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
3678 prs_struct *ps, int depth)
3680 uint32 i;
3681 fstring tmp;
3683 if (q_u == NULL)
3684 return False;
3686 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
3687 depth++;
3689 if (UNMARSHALLING(ps))
3690 ZERO_STRUCTP(q_u);
3692 if(!prs_align(ps))
3693 return False;
3695 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3696 return False;
3698 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
3699 return False;
3700 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
3701 return False;
3702 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3703 return False;
3704 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
3705 return False;
3707 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
3708 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
3709 if (q_u->rid == NULL)
3710 return False;
3713 for (i = 0; i < q_u->num_rids2; i++) {
3714 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
3715 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
3716 return False;
3719 return True;
3722 /*******************************************************************
3723 inits a SAMR_R_LOOKUP_RIDS structure.
3724 ********************************************************************/
3726 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
3727 uint32 num_names, UNIHDR * hdr_name,
3728 UNISTR2 *uni_name, uint32 *type)
3730 DEBUG(5, ("init_samr_r_lookup_rids\n"));
3732 r_u->hdr_name = NULL;
3733 r_u->uni_name = NULL;
3734 r_u->type = NULL;
3736 if (num_names != 0) {
3737 r_u->num_names1 = num_names;
3738 r_u->ptr_names = 1;
3739 r_u->num_names2 = num_names;
3741 r_u->num_types1 = num_names;
3742 r_u->ptr_types = 1;
3743 r_u->num_types2 = num_names;
3745 r_u->hdr_name = hdr_name;
3746 r_u->uni_name = uni_name;
3747 r_u->type = type;
3748 } else {
3749 r_u->num_names1 = num_names;
3750 r_u->ptr_names = 0;
3751 r_u->num_names2 = num_names;
3753 r_u->num_types1 = num_names;
3754 r_u->ptr_types = 0;
3755 r_u->num_types2 = num_names;
3759 /*******************************************************************
3760 reads or writes a structure.
3761 ********************************************************************/
3763 BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
3764 prs_struct *ps, int depth)
3766 uint32 i;
3767 fstring tmp;
3768 if (r_u == NULL)
3769 return False;
3771 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
3772 depth++;
3774 if(!prs_align(ps))
3775 return False;
3777 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
3778 return False;
3779 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
3780 return False;
3782 if (r_u->ptr_names != 0) {
3784 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
3785 return False;
3788 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
3789 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
3790 if (r_u->hdr_name == NULL)
3791 return False;
3793 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
3794 if (r_u->uni_name == NULL)
3795 return False;
3798 for (i = 0; i < r_u->num_names2; i++) {
3799 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
3800 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
3801 return False;
3803 for (i = 0; i < r_u->num_names2; i++) {
3804 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
3805 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
3806 return False;
3811 if(!prs_align(ps))
3812 return False;
3813 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
3814 return False;
3815 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
3816 return False;
3818 if (r_u->ptr_types != 0) {
3820 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
3821 return False;
3823 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
3824 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
3825 if (r_u->type == NULL)
3826 return False;
3829 for (i = 0; i < r_u->num_types2; i++) {
3830 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
3831 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
3832 return False;
3836 if(!prs_uint32("status", ps, depth, &r_u->status))
3837 return False;
3839 return True;
3842 /*******************************************************************
3843 inits a SAMR_Q_OPEN_ALIAS structure.
3844 ********************************************************************/
3846 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
3848 DEBUG(5, ("init_samr_q_delete_alias\n"));
3850 q_u->alias_pol = *hnd;
3853 /*******************************************************************
3854 reads or writes a structure.
3855 ********************************************************************/
3857 BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
3858 prs_struct *ps, int depth)
3860 if (q_u == NULL)
3861 return False;
3863 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
3864 depth++;
3866 if(!prs_align(ps))
3867 return False;
3869 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3870 return False;
3872 return True;
3875 /*******************************************************************
3876 reads or writes a structure.
3877 ********************************************************************/
3879 BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
3880 prs_struct *ps, int depth)
3882 if (r_u == NULL)
3883 return False;
3885 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
3886 depth++;
3888 if(!prs_align(ps))
3889 return False;
3891 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3892 return False;
3893 if(!prs_uint32("status", ps, depth, &r_u->status))
3894 return False;
3896 return True;
3899 /*******************************************************************
3900 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
3901 ********************************************************************/
3903 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
3904 POLICY_HND *hnd, char *acct_desc)
3906 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3908 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
3910 q_u->dom_pol = *hnd;
3912 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
3913 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
3915 q_u->access_mask = 0x001f000f;
3918 /*******************************************************************
3919 reads or writes a structure.
3920 ********************************************************************/
3922 BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
3923 prs_struct *ps, int depth)
3925 if (q_u == NULL)
3926 return False;
3928 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
3929 depth++;
3931 if(!prs_align(ps))
3932 return False;
3934 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
3935 return False;
3937 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
3938 return False;
3939 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
3940 q_u->hdr_acct_desc.buffer, ps, depth))
3941 return False;
3943 if(!prs_align(ps))
3944 return False;
3945 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3946 return False;
3948 return True;
3951 /*******************************************************************
3952 reads or writes a structure.
3953 ********************************************************************/
3955 BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
3956 prs_struct *ps, int depth)
3958 if (r_u == NULL)
3959 return False;
3961 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
3962 depth++;
3964 if(!prs_align(ps))
3965 return False;
3967 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
3968 return False;
3970 if(!prs_uint32("rid", ps, depth, &r_u->rid))
3971 return False;
3973 if(!prs_uint32("status", ps, depth, &r_u->status))
3974 return False;
3976 return True;
3979 /*******************************************************************
3980 inits a SAMR_Q_ADD_ALIASMEM structure.
3981 ********************************************************************/
3983 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
3984 DOM_SID *sid)
3986 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
3988 q_u->alias_pol = *hnd;
3989 init_dom_sid2(&q_u->sid, sid);
3992 /*******************************************************************
3993 reads or writes a structure.
3994 ********************************************************************/
3996 BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
3997 prs_struct *ps, int depth)
3999 if (q_u == NULL)
4000 return False;
4002 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4003 depth++;
4005 if(!prs_align(ps))
4006 return False;
4008 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4009 return False;
4010 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4011 return False;
4013 return True;
4016 /*******************************************************************
4017 reads or writes a structure.
4018 ********************************************************************/
4020 BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4021 prs_struct *ps, int depth)
4023 if (r_u == NULL)
4024 return False;
4026 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4027 depth++;
4029 if(!prs_align(ps))
4030 return False;
4032 if(!prs_uint32("status", ps, depth, &r_u->status))
4033 return False;
4035 return True;
4038 /*******************************************************************
4039 inits a SAMR_Q_DEL_ALIASMEM structure.
4040 ********************************************************************/
4042 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4043 DOM_SID *sid)
4045 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4047 q_u->alias_pol = *hnd;
4048 init_dom_sid2(&q_u->sid, sid);
4051 /*******************************************************************
4052 reads or writes a structure.
4053 ********************************************************************/
4055 BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4056 prs_struct *ps, int depth)
4058 if (q_u == NULL)
4059 return False;
4061 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4062 depth++;
4064 if(!prs_align(ps))
4065 return False;
4067 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4068 return False;
4069 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4070 return False;
4072 return True;
4075 /*******************************************************************
4076 reads or writes a structure.
4077 ********************************************************************/
4079 BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4080 prs_struct *ps, int depth)
4082 if (r_u == NULL)
4083 return False;
4085 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4086 depth++;
4088 if(!prs_align(ps))
4089 return False;
4091 if(!prs_uint32("status", ps, depth, &r_u->status))
4092 return False;
4094 return True;
4097 /*******************************************************************
4098 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4099 ********************************************************************/
4101 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4102 POLICY_HND *hnd)
4104 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4106 q_c->alias_pol = *hnd;
4109 /*******************************************************************
4110 reads or writes a structure.
4111 ********************************************************************/
4113 BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4114 prs_struct *ps, int depth)
4116 if (q_u == NULL)
4117 return False;
4119 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4120 depth++;
4122 if(!prs_align(ps))
4123 return False;
4125 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4126 return False;
4128 return True;
4131 /*******************************************************************
4132 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4133 ********************************************************************/
4135 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4136 uint32 status)
4138 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4140 r_u->status = status;
4143 /*******************************************************************
4144 reads or writes a structure.
4145 ********************************************************************/
4147 BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4148 prs_struct *ps, int depth)
4150 if (r_u == NULL)
4151 return False;
4153 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4154 depth++;
4156 if(!prs_align(ps))
4157 return False;
4159 if(!prs_uint32("status", ps, depth, &r_u->status))
4160 return False;
4162 return True;
4165 /*******************************************************************
4166 inits a SAMR_Q_QUERY_ALIASMEM structure.
4167 ********************************************************************/
4169 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4170 POLICY_HND *hnd)
4172 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4174 q_c->alias_pol = *hnd;
4177 /*******************************************************************
4178 reads or writes a structure.
4179 ********************************************************************/
4181 BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4182 prs_struct *ps, int depth)
4184 if (q_u == NULL)
4185 return False;
4187 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4188 depth++;
4190 if(!prs_align(ps))
4191 return False;
4193 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4194 return False;
4196 return True;
4199 /*******************************************************************
4200 inits a SAMR_R_QUERY_ALIASMEM structure.
4201 ********************************************************************/
4203 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4204 uint32 num_sids, DOM_SID2 * sid,
4205 uint32 status)
4207 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4209 if (status == 0) {
4210 r_u->num_sids = num_sids;
4211 r_u->ptr = (num_sids != 0) ? 1 : 0;
4212 r_u->num_sids1 = num_sids;
4214 r_u->sid = sid;
4215 } else {
4216 r_u->ptr = 0;
4217 r_u->num_sids = 0;
4220 r_u->status = status;
4223 /*******************************************************************
4224 reads or writes a structure.
4225 ********************************************************************/
4227 BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4228 prs_struct *ps, int depth)
4230 uint32 i;
4231 uint32 ptr_sid[MAX_LOOKUP_SIDS];
4233 if (r_u == NULL)
4234 return False;
4236 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4237 depth++;
4239 if(!prs_align(ps))
4240 return False;
4242 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4243 return False;
4244 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4245 return False;
4247 if (r_u->ptr != 0) {
4248 SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids);
4250 if (r_u->num_sids != 0) {
4251 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4252 return False;
4254 for (i = 0; i < r_u->num_sids1; i++) {
4255 ptr_sid[i] = 1;
4256 if(!prs_uint32("", ps, depth, &ptr_sid[i]))
4257 return False;
4260 for (i = 0; i < r_u->num_sids1; i++) {
4261 if (ptr_sid[i] != 0) {
4262 if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth))
4263 return False;
4269 if(!prs_align(ps))
4270 return False;
4271 if(!prs_uint32("status", ps, depth, &r_u->status))
4272 return False;
4274 return True;
4277 /*******************************************************************
4278 inits a SAMR_Q_LOOKUP_NAMES structure.
4279 ********************************************************************/
4281 void init_samr_q_lookup_names(SAMR_Q_LOOKUP_NAMES * q_u,
4282 POLICY_HND *pol, uint32 flags,
4283 uint32 num_names, char **name)
4285 uint32 i;
4287 DEBUG(5, ("init_samr_q_lookup_names\n"));
4289 q_u->pol = *pol;
4291 q_u->num_names1 = num_names;
4292 q_u->flags = flags;
4293 q_u->ptr = 0;
4294 q_u->num_names2 = num_names;
4296 for (i = 0; i < num_names; i++) {
4297 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4298 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4299 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4303 /*******************************************************************
4304 reads or writes a structure.
4305 ********************************************************************/
4307 BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4308 prs_struct *ps, int depth)
4310 uint32 i;
4312 if (q_u == NULL)
4313 return False;
4315 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4316 depth++;
4318 if (UNMARSHALLING(ps))
4319 ZERO_STRUCTP(q_u);
4321 if(!prs_align(ps))
4322 return False;
4324 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4325 return False;
4327 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4328 return False;
4329 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4330 return False;
4331 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4332 return False;
4333 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4334 return False;
4336 SMB_ASSERT_ARRAY(q_u->hdr_name, q_u->num_names2);
4338 for (i = 0; i < q_u->num_names2; i++) {
4339 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4340 return False;
4343 for (i = 0; i < q_u->num_names2; i++) {
4344 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4345 return False;
4348 return True;
4351 /*******************************************************************
4352 inits a SAMR_R_LOOKUP_NAMES structure.
4353 ********************************************************************/
4355 void init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4356 uint32 num_rids,
4357 uint32 *rid, uint32 *type,
4358 uint32 status)
4360 DEBUG(5, ("init_samr_r_lookup_names\n"));
4362 if ((status == 0) && (num_rids != 0)) {
4363 uint32 i;
4365 r_u->num_types1 = num_rids;
4366 r_u->ptr_types = 1;
4367 r_u->num_types2 = num_rids;
4369 r_u->num_rids1 = num_rids;
4370 r_u->ptr_rids = 1;
4371 r_u->num_rids2 = num_rids;
4373 r_u->rids = (uint32 *)talloc(ctx, sizeof(uint32)*num_rids);
4374 r_u->types = (uint32 *)talloc(ctx, sizeof(uint32)*num_rids);
4376 if (!r_u->rids || !r_u->types)
4377 goto empty;
4379 for (i = 0; i < num_rids; i++) {
4380 r_u->rids[i] = rid[i];
4381 r_u->types[i] = type[i];
4383 } else {
4385 empty:
4386 r_u->num_types1 = 0;
4387 r_u->ptr_types = 0;
4388 r_u->num_types2 = 0;
4390 r_u->num_rids1 = 0;
4391 r_u->ptr_rids = 0;
4392 r_u->num_rids2 = 0;
4394 r_u->rids = NULL;
4395 r_u->types = NULL;
4398 r_u->status = status;
4401 /*******************************************************************
4402 reads or writes a structure.
4403 ********************************************************************/
4405 BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4406 prs_struct *ps, int depth)
4408 uint32 i;
4409 fstring tmp;
4411 if (r_u == NULL)
4412 return False;
4414 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4415 depth++;
4417 if (UNMARSHALLING(ps))
4418 ZERO_STRUCTP(r_u);
4420 if(!prs_align(ps))
4421 return False;
4423 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4424 return False;
4425 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4426 return False;
4428 if (r_u->ptr_rids != 0) {
4429 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4430 return False;
4432 if (r_u->num_rids2 != r_u->num_rids1) {
4433 /* RPC fault */
4434 return False;
4437 if (UNMARSHALLING(ps))
4438 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4440 if (!r_u->rids) {
4441 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4442 return False;
4445 for (i = 0; i < r_u->num_rids2; i++) {
4446 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4447 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4448 return False;
4452 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4453 return False;
4454 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4455 return False;
4457 if (r_u->ptr_types != 0) {
4458 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4459 return False;
4461 if (r_u->num_types2 != r_u->num_types1) {
4462 /* RPC fault */
4463 return False;
4466 if (UNMARSHALLING(ps))
4467 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4469 if (!r_u->types) {
4470 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4471 return False;
4474 for (i = 0; i < r_u->num_types2; i++) {
4475 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4476 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4477 return False;
4481 if(!prs_uint32("status", ps, depth, &r_u->status))
4482 return False;
4484 return True;
4487 /*******************************************************************
4488 inits a SAMR_Q_DELETE_DOM_USER structure.
4489 ********************************************************************/
4491 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4492 POLICY_HND *hnd)
4494 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4496 q_c->user_pol = *hnd;
4499 /*******************************************************************
4500 reads or writes a structure.
4501 ********************************************************************/
4503 BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4504 prs_struct *ps, int depth)
4506 if (q_u == NULL)
4507 return False;
4509 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4510 depth++;
4512 if(!prs_align(ps))
4513 return False;
4515 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4516 return False;
4518 return True;
4521 /*******************************************************************
4522 reads or writes a structure.
4523 ********************************************************************/
4525 BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4526 prs_struct *ps, int depth)
4528 if (r_u == NULL)
4529 return False;
4531 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4532 depth++;
4534 if(!prs_align(ps))
4535 return False;
4537 if(!prs_uint32("status", ps, depth, &r_u->status))
4538 return False;
4540 return True;
4543 /*******************************************************************
4544 reads or writes a structure.
4545 ********************************************************************/
4547 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4548 POLICY_HND *pol,
4549 uint32 access_mask, uint32 rid)
4551 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4553 q_u->domain_pol = *pol;
4554 q_u->access_mask = access_mask;
4555 q_u->user_rid = rid;
4558 /*******************************************************************
4559 reads or writes a structure.
4560 ********************************************************************/
4562 BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
4563 prs_struct *ps, int depth)
4565 if (q_u == NULL)
4566 return False;
4568 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4569 depth++;
4571 if(!prs_align(ps))
4572 return False;
4574 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4575 return False;
4577 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4578 return False;
4579 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4580 return False;
4582 return True;
4585 /*******************************************************************
4586 reads or writes a structure.
4587 ********************************************************************/
4589 BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
4590 prs_struct *ps, int depth)
4592 if (r_u == NULL)
4593 return False;
4595 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4596 depth++;
4598 if(!prs_align(ps))
4599 return False;
4601 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4602 return False;
4604 if(!prs_uint32("status", ps, depth, &r_u->status))
4605 return False;
4607 return True;
4611 /*******************************************************************
4612 reads or writes a structure.
4613 ********************************************************************/
4615 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4616 POLICY_HND *pol,
4617 char *name,
4618 uint32 acb_info, uint32 access_mask)
4620 int len_name;
4621 len_name = strlen(name);
4623 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4625 q_u->domain_pol = *pol;
4627 init_uni_hdr(&q_u->hdr_name, len_name);
4628 init_unistr2(&q_u->uni_name, name, len_name);
4630 q_u->acb_info = acb_info;
4631 q_u->access_mask = access_mask;
4634 /*******************************************************************
4635 reads or writes a structure.
4636 ********************************************************************/
4638 BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
4639 prs_struct *ps, int depth)
4641 if (q_u == NULL)
4642 return False;
4644 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4645 depth++;
4647 if(!prs_align(ps))
4648 return False;
4650 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4651 return False;
4653 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
4654 return False;
4655 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
4656 return False;
4658 if(!prs_align(ps))
4659 return False;
4660 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
4661 return False;
4662 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4663 return False;
4665 return True;
4668 /*******************************************************************
4669 reads or writes a structure.
4670 ********************************************************************/
4672 BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
4673 prs_struct *ps, int depth)
4675 if (r_u == NULL)
4676 return False;
4678 prs_debug(ps, depth, desc, "samr_io_r_create_user");
4679 depth++;
4681 if(!prs_align(ps))
4682 return False;
4684 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4685 return False;
4687 if(!prs_uint32("unknown_0", ps, depth, &r_u->unknown_0))
4688 return False;
4689 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
4690 return False;
4691 if(!prs_uint32("status", ps, depth, &r_u->status))
4692 return False;
4694 return True;
4697 /*******************************************************************
4698 inits a SAMR_Q_QUERY_USERINFO structure.
4699 ********************************************************************/
4701 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
4702 POLICY_HND *hnd, uint16 switch_value)
4704 DEBUG(5, ("init_samr_q_query_userinfo\n"));
4706 q_u->pol = *hnd;
4707 q_u->switch_value = switch_value;
4710 /*******************************************************************
4711 reads or writes a structure.
4712 ********************************************************************/
4714 BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
4715 prs_struct *ps, int depth)
4717 if (q_u == NULL)
4718 return False;
4720 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
4721 depth++;
4723 if(!prs_align(ps))
4724 return False;
4726 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4727 return False;
4729 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
4730 return False;
4732 return True;
4735 /*******************************************************************
4736 reads or writes a LOGON_HRS structure.
4737 ********************************************************************/
4739 static BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs,
4740 prs_struct *ps, int depth)
4742 if (hrs == NULL)
4743 return False;
4745 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
4746 depth++;
4748 if(!prs_align(ps))
4749 return False;
4751 if(!prs_uint32("len ", ps, depth, &hrs->len))
4752 return False;
4754 if (hrs->len > sizeof(hrs->hours)) {
4755 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
4756 hrs->len = sizeof(hrs->hours);
4759 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
4760 return False;
4762 return True;
4765 /*******************************************************************
4766 inits a SAM_USER_INFO_12 structure.
4767 ********************************************************************/
4769 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
4770 uint8 lm_pwd[16], uint8 nt_pwd[16])
4772 DEBUG(5, ("init_sam_user_info12\n"));
4774 usr->lm_pwd_active =
4775 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
4776 usr->nt_pwd_active =
4777 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
4780 /*******************************************************************
4781 reads or writes a structure.
4782 ********************************************************************/
4784 static BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
4785 prs_struct *ps, int depth)
4787 if (u == NULL)
4788 return False;
4790 DEBUG(0, ("possible security breach!\n"));
4792 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
4793 depth++;
4795 if(!prs_align(ps))
4796 return False;
4798 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
4799 return False;
4800 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
4801 return False;
4803 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
4804 return False;
4805 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
4806 return False;
4808 return True;
4811 /*******************************************************************
4812 inits a SAM_USER_INFO_10 structure.
4813 ********************************************************************/
4815 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
4817 DEBUG(5, ("init_sam_user_info10\n"));
4819 usr->acb_info = acb_info;
4822 /*******************************************************************
4823 reads or writes a structure.
4824 ********************************************************************/
4826 static BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
4827 prs_struct *ps, int depth)
4829 if (usr == NULL)
4830 return False;
4832 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
4833 depth++;
4835 if(!prs_align(ps))
4836 return False;
4838 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
4839 return False;
4841 return True;
4844 /*******************************************************************
4845 inits a SAM_USER_INFO_11 structure.
4846 ********************************************************************/
4848 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
4849 NTTIME * expiry,
4850 char *mach_acct,
4851 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
4853 int len_mach_acct;
4855 DEBUG(5, ("init_sam_user_info11\n"));
4857 len_mach_acct = strlen(mach_acct);
4859 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
4860 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
4862 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
4863 usr->padding_2 = 0; /* 0 - padding 4 bytes */
4865 usr->ptr_1 = 1; /* pointer */
4866 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
4867 usr->padding_4 = 0; /* 0 - padding 4 bytes */
4869 usr->ptr_2 = 1; /* pointer */
4870 usr->padding_5 = 0; /* 0 - padding 4 bytes */
4872 usr->ptr_3 = 1; /* pointer */
4873 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
4875 usr->rid_user = rid_user;
4876 usr->rid_group = rid_group;
4878 usr->acct_ctrl = acct_ctrl;
4879 usr->unknown_3 = 0x0000;
4881 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
4882 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
4884 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
4885 usr->padding_8 = 0; /* 0 - padding 4 bytes */
4887 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
4890 /*******************************************************************
4891 reads or writes a structure.
4892 ********************************************************************/
4894 static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
4895 prs_struct *ps, int depth)
4897 if (usr == NULL)
4898 return False;
4900 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
4901 depth++;
4903 if(!prs_align(ps))
4904 return False;
4906 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
4907 return False;
4909 if(!smb_io_time("time", &usr->expiry, ps, depth))
4910 return False;
4912 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
4913 return False;
4915 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
4916 return False;
4918 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
4919 return False;
4921 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
4922 return False;
4923 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
4924 return False;
4926 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
4927 return False;
4929 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
4930 return False;
4931 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
4932 return False;
4934 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
4935 return False;
4936 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
4937 return False;
4939 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
4940 return False;
4941 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
4942 return False;
4943 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
4944 return False;
4945 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
4946 return False;
4947 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
4948 return False;
4949 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
4950 return False;
4952 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
4953 return False;
4955 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
4956 return False;
4958 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
4959 return False;
4961 if(!prs_align(ps))
4962 return False;
4964 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
4965 return False;
4967 return True;
4970 /*************************************************************************
4971 init_sam_user_infoa
4973 unknown_3 = 0x09f8 27fa
4974 unknown_5 = 0x0001 0000
4975 unknown_6 = 0x0000 04ec
4977 *************************************************************************/
4979 void init_sam_user_info24(SAM_USER_INFO_24 * usr,
4980 char newpass[516], uint16 passlen)
4982 DEBUG(10, ("init_sam_user_info24: passlen: %d\n", passlen));
4983 memcpy(usr->pass, newpass, sizeof(usr->pass));
4984 usr->unk_0 = passlen;
4987 /*******************************************************************
4988 reads or writes a structure.
4989 ********************************************************************/
4991 static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
4992 prs_struct *ps, int depth)
4994 if (usr == NULL)
4995 return False;
4997 prs_debug(ps, depth, desc, "sam_io_user_info24");
4998 depth++;
5000 if(!prs_align(ps))
5001 return False;
5003 if(!prs_uint8s(False, "password", ps, depth, usr->pass, sizeof(usr->pass)))
5004 return False;
5005 if(!prs_uint16("unk_0", ps, depth, &usr->unk_0)) /* unknown */
5006 return False;
5008 return True;
5011 /*************************************************************************
5012 init_sam_user_info23
5014 unknown_3 = 0x09f8 27fa
5015 unknown_5 = 0x0001 0000
5016 unknown_6 = 0x0000 04ec
5018 *************************************************************************/
5020 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5021 NTTIME * logoff_time, /* all zeros */
5022 NTTIME * kickoff_time, /* all zeros */
5023 NTTIME * pass_last_set_time, /* all zeros */
5024 NTTIME * pass_can_change_time, /* all zeros */
5025 NTTIME * pass_must_change_time, /* all zeros */
5026 UNISTR2 *user_name,
5027 UNISTR2 *full_name,
5028 UNISTR2 *home_dir,
5029 UNISTR2 *dir_drive,
5030 UNISTR2 *log_scr,
5031 UNISTR2 *prof_path,
5032 UNISTR2 *desc,
5033 UNISTR2 *wkstas,
5034 UNISTR2 *unk_str,
5035 UNISTR2 *mung_dial,
5036 uint32 user_rid, /* 0x0000 0000 */
5037 uint32 group_rid,
5038 uint32 acb_info,
5039 uint32 unknown_3,
5040 uint16 logon_divs,
5041 LOGON_HRS * hrs,
5042 uint32 unknown_5,
5043 char newpass[516], uint32 unknown_6)
5045 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5046 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5047 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5048 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5049 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5050 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5051 int len_description = desc != NULL ? desc->uni_str_len : 0;
5052 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5053 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5054 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5056 usr->logon_time = *logon_time; /* all zeros */
5057 usr->logoff_time = *logoff_time; /* all zeros */
5058 usr->kickoff_time = *kickoff_time; /* all zeros */
5059 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5060 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5061 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5063 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5064 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5065 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5066 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5067 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5068 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5069 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5070 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5071 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5072 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5074 ZERO_STRUCT(usr->nt_pwd);
5075 ZERO_STRUCT(usr->lm_pwd);
5077 usr->user_rid = user_rid; /* 0x0000 0000 */
5078 usr->group_rid = group_rid;
5079 usr->acb_info = acb_info;
5080 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5082 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5083 usr->ptr_logon_hrs = hrs ? 1 : 0;
5085 ZERO_STRUCT(usr->padding1);
5087 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5089 memcpy(usr->pass, newpass, sizeof(usr->pass));
5091 copy_unistr2(&usr->uni_user_name, user_name);
5092 copy_unistr2(&usr->uni_full_name, full_name);
5093 copy_unistr2(&usr->uni_home_dir, home_dir);
5094 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5095 copy_unistr2(&usr->uni_logon_script, log_scr);
5096 copy_unistr2(&usr->uni_profile_path, prof_path);
5097 copy_unistr2(&usr->uni_acct_desc, desc);
5098 copy_unistr2(&usr->uni_workstations, wkstas);
5099 copy_unistr2(&usr->uni_unknown_str, unk_str);
5100 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5102 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5103 usr->padding4 = 0;
5105 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5108 /*************************************************************************
5109 init_sam_user_info23
5111 unknown_3 = 0x09f8 27fa
5112 unknown_5 = 0x0001 0000
5113 unknown_6 = 0x0000 04ec
5115 *************************************************************************/
5117 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5118 NTTIME * logoff_time, /* all zeros */
5119 NTTIME * kickoff_time, /* all zeros */
5120 NTTIME * pass_last_set_time, /* all zeros */
5121 NTTIME * pass_can_change_time, /* all zeros */
5122 NTTIME * pass_must_change_time, /* all zeros */
5123 char *user_name, /* NULL */
5124 char *full_name,
5125 char *home_dir, char *dir_drive, char *log_scr,
5126 char *prof_path, char *desc, char *wkstas,
5127 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5128 uint32 group_rid, uint32 acb_info,
5129 uint32 unknown_3, uint16 logon_divs,
5130 LOGON_HRS * hrs, uint32 unknown_5,
5131 char newpass[516], uint32 unknown_6)
5133 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5134 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5135 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5136 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5137 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5138 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5139 int len_description = desc != NULL ? strlen(desc) : 0;
5140 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5141 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5142 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5144 usr->logon_time = *logon_time; /* all zeros */
5145 usr->logoff_time = *logoff_time; /* all zeros */
5146 usr->kickoff_time = *kickoff_time; /* all zeros */
5147 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5148 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5149 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5151 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5152 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5153 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5154 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5155 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5156 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5157 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5158 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5159 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5160 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5162 ZERO_STRUCT(usr->nt_pwd);
5163 ZERO_STRUCT(usr->lm_pwd);
5165 usr->user_rid = user_rid; /* 0x0000 0000 */
5166 usr->group_rid = group_rid;
5167 usr->acb_info = acb_info;
5168 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5170 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5171 usr->ptr_logon_hrs = hrs ? 1 : 0;
5173 ZERO_STRUCT(usr->padding1);
5175 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5177 memcpy(usr->pass, newpass, sizeof(usr->pass));
5179 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5180 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5181 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5182 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5183 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5184 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5185 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5186 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5187 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5188 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5190 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5191 usr->padding4 = 0;
5193 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5196 /*******************************************************************
5197 reads or writes a structure.
5198 ********************************************************************/
5200 static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
5201 prs_struct *ps, int depth)
5203 if (usr == NULL)
5204 return False;
5206 prs_debug(ps, depth, desc, "sam_io_user_info23");
5207 depth++;
5209 if(!prs_align(ps))
5210 return False;
5212 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5213 return False;
5214 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5215 return False;
5216 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5217 return False;
5218 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5219 return False;
5220 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5221 return False;
5222 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5223 return False;
5225 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5226 return False;
5227 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5228 return False;
5229 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5230 return False;
5231 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5232 return False;
5233 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5234 return False;
5235 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5236 return False;
5237 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5238 return False;
5239 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5240 return False;
5241 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5242 return False;
5243 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5244 return False;
5246 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5247 return False;
5248 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5249 return False;
5251 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5252 return False;
5253 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5254 return False;
5255 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5256 return False;
5258 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5259 return False;
5260 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5261 return False;
5262 if(!prs_align(ps))
5263 return False;
5264 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5265 return False;
5266 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5267 return False;
5268 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5269 return False;
5271 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5272 return False;
5274 /* here begins pointed-to data */
5276 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5277 return False;
5279 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5280 return False;
5282 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5283 return False;
5285 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5286 return False;
5288 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5289 return False;
5291 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5292 return False;
5294 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5295 return False;
5297 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5298 return False;
5300 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5301 return False;
5303 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5304 return False;
5306 /* ok, this is only guess-work (as usual) */
5307 if (usr->ptr_logon_hrs) {
5308 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5309 return False;
5310 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5311 return False;
5312 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5313 return False;
5314 } else if (UNMARSHALLING(ps)) {
5315 usr->unknown_6 = 0;
5316 usr->padding4 = 0;
5319 return True;
5323 /*************************************************************************
5324 init_sam_user_info21W
5326 unknown_3 = 0x00ff ffff
5327 unknown_5 = 0x0002 0000
5328 unknown_6 = 0x0000 04ec
5330 *************************************************************************/
5332 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5333 NTTIME * logon_time,
5334 NTTIME * logoff_time,
5335 NTTIME * kickoff_time,
5336 NTTIME * pass_last_set_time,
5337 NTTIME * pass_can_change_time,
5338 NTTIME * pass_must_change_time,
5339 UNISTR2 *user_name,
5340 UNISTR2 *full_name,
5341 UNISTR2 *home_dir,
5342 UNISTR2 *dir_drive,
5343 UNISTR2 *log_scr,
5344 UNISTR2 *prof_path,
5345 UNISTR2 *desc,
5346 UNISTR2 *wkstas,
5347 UNISTR2 *unk_str,
5348 UNISTR2 *mung_dial,
5349 uchar lm_pwd[16],
5350 uchar nt_pwd[16],
5351 uint32 user_rid,
5352 uint32 group_rid,
5353 uint32 acb_info,
5354 uint32 unknown_3,
5355 uint16 logon_divs,
5356 LOGON_HRS * hrs,
5357 uint32 unknown_5, uint32 unknown_6)
5359 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5360 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5361 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5362 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5363 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5364 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5365 int len_description = desc != NULL ? desc->uni_str_len : 0;
5366 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5367 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5368 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5370 usr->logon_time = *logon_time;
5371 usr->logoff_time = *logoff_time;
5372 usr->kickoff_time = *kickoff_time;
5373 usr->pass_last_set_time = *pass_last_set_time;
5374 usr->pass_can_change_time = *pass_can_change_time;
5375 usr->pass_must_change_time = *pass_must_change_time;
5377 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5378 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5379 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5380 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5381 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5382 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5383 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5384 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5385 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5386 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5388 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5389 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5391 usr->user_rid = user_rid;
5392 usr->group_rid = group_rid;
5393 usr->acb_info = acb_info;
5394 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5396 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5397 usr->ptr_logon_hrs = hrs ? 1 : 0;
5398 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5400 ZERO_STRUCT(usr->padding1);
5402 copy_unistr2(&usr->uni_user_name, user_name);
5403 copy_unistr2(&usr->uni_full_name, full_name);
5404 copy_unistr2(&usr->uni_home_dir, home_dir);
5405 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5406 copy_unistr2(&usr->uni_logon_script, log_scr);
5407 copy_unistr2(&usr->uni_profile_path, prof_path);
5408 copy_unistr2(&usr->uni_acct_desc, desc);
5409 copy_unistr2(&usr->uni_workstations, wkstas);
5410 copy_unistr2(&usr->uni_unknown_str, unk_str);
5411 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5413 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5414 usr->padding4 = 0;
5416 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5419 /*************************************************************************
5420 init_sam_user_info21
5422 unknown_3 = 0x00ff ffff
5423 unknown_5 = 0x0002 0000
5424 unknown_6 = 0x0000 04ec
5426 *************************************************************************/
5428 void init_sam_user_info21A(SAM_USER_INFO_21 * usr,
5429 NTTIME * logon_time,
5430 NTTIME * logoff_time,
5431 NTTIME * kickoff_time,
5432 NTTIME * pass_last_set_time,
5433 NTTIME * pass_can_change_time,
5434 NTTIME * pass_must_change_time,
5435 char *user_name,
5436 char *full_name,
5437 char *home_dir,
5438 char *dir_drive,
5439 char *log_scr,
5440 char *prof_path,
5441 char *desc,
5442 char *wkstas,
5443 char *unk_str,
5444 char *mung_dial,
5445 uint32 user_rid,
5446 uint32 group_rid,
5447 uint32 acb_info,
5448 uint32 unknown_3,
5449 uint16 logon_divs,
5450 LOGON_HRS * hrs,
5451 uint32 unknown_5, uint32 unknown_6)
5453 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5454 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5455 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5456 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5457 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5458 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5459 int len_description = desc != NULL ? strlen(desc) : 0;
5460 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5461 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5462 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5464 usr->logon_time = *logon_time;
5465 usr->logoff_time = *logoff_time;
5466 usr->kickoff_time = *kickoff_time;
5467 usr->pass_last_set_time = *pass_last_set_time;
5468 usr->pass_can_change_time = *pass_can_change_time;
5469 usr->pass_must_change_time = *pass_must_change_time;
5471 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5472 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5473 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5474 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5475 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5476 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5477 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5478 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5479 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5480 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5482 ZERO_STRUCT(usr->nt_pwd);
5483 ZERO_STRUCT(usr->lm_pwd);
5485 usr->user_rid = user_rid;
5486 usr->group_rid = group_rid;
5487 usr->acb_info = acb_info;
5488 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5490 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5491 usr->ptr_logon_hrs = hrs ? 1 : 0;
5492 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5494 ZERO_STRUCT(usr->padding1);
5496 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
5497 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5498 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5499 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5500 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5501 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5502 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5503 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5504 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5505 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5507 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5508 usr->padding4 = 0;
5510 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5513 /*******************************************************************
5514 reads or writes a structure.
5515 ********************************************************************/
5517 static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
5518 prs_struct *ps, int depth)
5520 if (usr == NULL)
5521 return False;
5523 prs_debug(ps, depth, desc, "sam_io_user_info21");
5524 depth++;
5526 if(!prs_align(ps))
5527 return False;
5529 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5530 return False;
5531 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5532 return False;
5533 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
5534 return False;
5535 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5536 return False;
5537 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
5538 return False;
5539 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5540 return False;
5542 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5543 return False;
5544 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5545 return False;
5546 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5547 return False;
5548 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5549 return False;
5550 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5551 return False;
5552 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5553 return False;
5554 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5555 return False;
5556 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5557 return False;
5558 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5559 return False;
5560 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5561 return False;
5563 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5564 return False;
5565 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5566 return False;
5568 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5569 return False;
5570 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5571 return False;
5572 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5573 return False;
5575 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5576 return False;
5577 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5578 return False;
5579 if(!prs_align(ps))
5580 return False;
5581 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5582 return False;
5583 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5584 return False;
5586 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5587 return False;
5589 /* here begins pointed-to data */
5591 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5592 return False;
5593 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5594 return False;
5595 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5596 return False;
5597 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5598 return False;
5599 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5600 return False;
5601 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5602 return False;
5603 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5604 return False;
5605 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5606 return False;
5607 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5608 return False;
5609 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
5610 return False;
5612 /* ok, this is only guess-work (as usual) */
5613 if (usr->ptr_logon_hrs) {
5614 if(!prs_align(ps))
5615 return False;
5616 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5617 return False;
5618 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5619 return False;
5620 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5621 return False;
5622 } else if (UNMARSHALLING(ps)) {
5623 usr->unknown_6 = 0;
5624 usr->padding4 = 0;
5627 return True;
5630 /*******************************************************************
5631 inits a SAM_USERINFO_CTR structure.
5632 ********************************************************************/
5634 uint32 make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
5635 uint16 switch_value,
5636 SAM_USER_INFO_21 * usr)
5638 DEBUG(5, ("init_samr_userinfo_ctr\n"));
5640 ctr->switch_value = switch_value;
5641 ctr->info.id = NULL;
5643 switch (switch_value) {
5644 case 0x10:
5645 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc(ctx,sizeof(SAM_USER_INFO_10));
5646 if (ctr->info.id10 == NULL)
5647 return NT_STATUS_NO_MEMORY;
5649 init_sam_user_info10(ctr->info.id10, usr->acb_info);
5650 break;
5651 #if 0
5652 /* whoops - got this wrong. i think. or don't understand what's happening. */
5653 case 0x11:
5655 NTTIME expire;
5656 info = (void *)&id11;
5658 expire.low = 0xffffffff;
5659 expire.high = 0x7fffffff;
5661 ctr->info.id = (SAM_USER_INFO_11 *) talloc(ctx,sizeof(*ctr->info.id11));
5662 init_sam_user_info11(ctr->info.id11, &expire,
5663 "BROOKFIELDS$", /* name */
5664 0x03ef, /* user rid */
5665 0x201, /* group rid */
5666 0x0080); /* acb info */
5668 break;
5670 #endif
5671 case 0x12:
5672 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc(ctx,sizeof(SAM_USER_INFO_12));
5673 if (ctr->info.id12 == NULL)
5674 return NT_STATUS_NO_MEMORY;
5676 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
5677 break;
5678 case 21:
5680 SAM_USER_INFO_21 *cusr;
5681 cusr = (SAM_USER_INFO_21 *)talloc(ctx,sizeof(SAM_USER_INFO_21));
5682 ctr->info.id21 = cusr;
5683 if (ctr->info.id21 == NULL)
5684 return NT_STATUS_NO_MEMORY;
5685 memcpy(cusr, usr, sizeof(*usr));
5686 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
5687 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
5688 break;
5690 default:
5691 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
5692 return NT_STATUS_INVALID_INFO_CLASS;
5695 return NT_STATUS_NOPROBLEMO;
5698 /*******************************************************************
5699 inits a SAM_USERINFO_CTR structure.
5700 ********************************************************************/
5702 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
5703 uint16 switch_value, void *info)
5705 DEBUG(5, ("init_samr_userinfo_ctr\n"));
5707 ctr->switch_value = switch_value;
5708 ctr->info.id = info;
5710 switch (switch_value) {
5711 case 0x18:
5712 SamOEMhash(ctr->info.id24->pass, sess_key, 1);
5713 dump_data(100, sess_key, 16);
5714 dump_data(100, ctr->info.id24->pass, 516);
5715 break;
5716 case 0x17:
5717 SamOEMhash(ctr->info.id23->pass, sess_key, 1);
5718 dump_data(100, sess_key, 16);
5719 dump_data(100, ctr->info.id23->pass, 516);
5720 break;
5721 default:
5722 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
5726 /*******************************************************************
5727 reads or writes a structure.
5728 ********************************************************************/
5730 static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR **ppctr,
5731 prs_struct *ps, int depth)
5733 BOOL ret;
5734 SAM_USERINFO_CTR *ctr;
5736 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
5737 depth++;
5739 if (UNMARSHALLING(ps)) {
5740 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
5741 if (ctr == NULL)
5742 return False;
5744 ZERO_STRUCTP(ctr);
5745 *ppctr = ctr;
5746 } else {
5747 ctr = *ppctr;
5750 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
5752 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
5753 return False;
5754 if(!prs_align(ps))
5755 return False;
5757 ret = False;
5759 switch (ctr->switch_value) {
5760 case 0x10:
5761 if (UNMARSHALLING(ps))
5762 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
5763 if (ctr->info.id10 == NULL) {
5764 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5765 return False;
5767 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
5768 break;
5769 case 0x11:
5770 if (UNMARSHALLING(ps))
5771 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
5773 if (ctr->info.id11 == NULL) {
5774 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5775 return False;
5777 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
5778 break;
5779 case 0x12:
5780 if (UNMARSHALLING(ps))
5781 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
5783 if (ctr->info.id12 == NULL) {
5784 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5785 return False;
5787 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
5788 break;
5789 case 21:
5790 if (UNMARSHALLING(ps))
5791 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
5793 if (ctr->info.id21 == NULL) {
5794 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5795 return False;
5797 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
5798 break;
5799 case 23:
5800 if (UNMARSHALLING(ps))
5801 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
5803 if (ctr->info.id23 == NULL) {
5804 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5805 return False;
5807 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
5808 break;
5809 case 24:
5810 if (UNMARSHALLING(ps))
5811 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
5813 if (ctr->info.id24 == NULL) {
5814 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5815 return False;
5817 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
5818 break;
5819 default:
5820 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
5821 ret = False;
5822 break;
5825 return ret;
5828 /*******************************************************************
5829 inits a SAMR_R_QUERY_USERINFO structure.
5830 ********************************************************************/
5832 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
5833 SAM_USERINFO_CTR * ctr, uint32 status)
5835 DEBUG(5, ("init_samr_r_query_userinfo\n"));
5837 r_u->ptr = 0;
5838 r_u->ctr = NULL;
5840 if (status == 0) {
5841 r_u->ptr = 1;
5842 r_u->ctr = ctr;
5845 r_u->status = status; /* return status */
5848 /*******************************************************************
5849 reads or writes a structure.
5850 ********************************************************************/
5852 BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
5853 prs_struct *ps, int depth)
5855 if (r_u == NULL)
5856 return False;
5858 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
5859 depth++;
5861 if(!prs_align(ps))
5862 return False;
5864 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
5865 return False;
5867 if (r_u->ptr != 0) {
5868 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
5869 return False;
5872 if(!prs_align(ps))
5873 return False;
5874 if(!prs_uint32("status", ps, depth, &r_u->status))
5875 return False;
5877 return True;
5880 /*******************************************************************
5881 inits a SAMR_Q_SET_USERINFO structure.
5882 ********************************************************************/
5884 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
5885 POLICY_HND *hnd, unsigned char sess_key[16],
5886 uint16 switch_value, void *info)
5888 DEBUG(5, ("init_samr_q_set_userinfo\n"));
5890 q_u->pol = *hnd;
5891 q_u->switch_value = switch_value;
5892 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
5895 /*******************************************************************
5896 reads or writes a structure.
5897 ********************************************************************/
5899 BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
5900 prs_struct *ps, int depth)
5902 if (q_u == NULL)
5903 return False;
5905 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
5906 depth++;
5908 if(!prs_align(ps))
5909 return False;
5911 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
5913 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
5914 return False;
5915 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
5916 return False;
5918 return True;
5921 /*******************************************************************
5922 inits a SAMR_R_SET_USERINFO structure.
5923 ********************************************************************/
5925 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, uint32 status)
5927 DEBUG(5, ("init_samr_r_set_userinfo\n"));
5929 r_u->status = status; /* return status */
5932 /*******************************************************************
5933 reads or writes a structure.
5934 ********************************************************************/
5936 BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
5937 prs_struct *ps, int depth)
5939 if (r_u == NULL)
5940 return False;
5942 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
5943 depth++;
5945 if(!prs_align(ps))
5946 return False;
5948 if(!prs_uint32("status", ps, depth, &r_u->status))
5949 return False;
5951 return True;
5954 /*******************************************************************
5955 inits a SAMR_Q_SET_USERINFO2 structure.
5956 ********************************************************************/
5958 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
5959 POLICY_HND *hnd, unsigned char sess_key[16],
5960 uint16 switch_value, SAM_USERINFO_CTR * ctr)
5962 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
5964 q_u->pol = *hnd;
5965 q_u->switch_value = switch_value;
5966 q_u->ctr = ctr;
5968 if (q_u->ctr != NULL)
5969 q_u->ctr->switch_value = switch_value;
5971 switch (switch_value) {
5972 case 0x12:
5973 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 0);
5974 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 0);
5975 dump_data(100, sess_key, 16);
5976 dump_data(100, ctr->info.id12->lm_pwd, 16);
5977 dump_data(100, ctr->info.id12->nt_pwd, 16);
5978 break;
5982 /*******************************************************************
5983 reads or writes a structure.
5984 ********************************************************************/
5986 BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
5987 prs_struct *ps, int depth)
5989 if (q_u == NULL)
5990 return False;
5992 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
5993 depth++;
5995 if(!prs_align(ps))
5996 return False;
5998 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5999 return False;
6001 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6002 return False;
6003 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6004 return False;
6006 return True;
6009 /*******************************************************************
6010 inits a SAMR_R_SET_USERINFO2 structure.
6011 ********************************************************************/
6013 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, uint32 status)
6015 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6017 r_u->status = status; /* return status */
6020 /*******************************************************************
6021 reads or writes a structure.
6022 ********************************************************************/
6024 BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
6025 prs_struct *ps, int depth)
6027 if (r_u == NULL)
6028 return False;
6030 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6031 depth++;
6033 if(!prs_align(ps))
6034 return False;
6036 if(!prs_uint32("status", ps, depth, &r_u->status))
6037 return False;
6039 return True;
6042 /*******************************************************************
6043 inits a SAMR_Q_CONNECT structure.
6044 ********************************************************************/
6046 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6047 char *srv_name, uint32 access_mask)
6049 int len_srv_name = strlen(srv_name);
6051 DEBUG(5, ("init_samr_q_connect\n"));
6053 /* make PDC server name \\server */
6054 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6055 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6057 /* example values: 0x0000 0002 */
6058 q_u->access_mask = access_mask;
6061 /*******************************************************************
6062 reads or writes a structure.
6063 ********************************************************************/
6065 BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
6066 prs_struct *ps, int depth)
6068 if (q_u == NULL)
6069 return False;
6071 prs_debug(ps, depth, desc, "samr_io_q_connect");
6072 depth++;
6074 if(!prs_align(ps))
6075 return False;
6077 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6078 return False;
6079 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6080 return False;
6082 if(!prs_align(ps))
6083 return False;
6084 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6085 return False;
6087 return True;
6090 /*******************************************************************
6091 reads or writes a structure.
6092 ********************************************************************/
6094 BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
6095 prs_struct *ps, int depth)
6097 if (r_u == NULL)
6098 return False;
6100 prs_debug(ps, depth, desc, "samr_io_r_connect");
6101 depth++;
6103 if(!prs_align(ps))
6104 return False;
6106 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6107 return False;
6109 if(!prs_uint32("status", ps, depth, &r_u->status))
6110 return False;
6112 return True;
6115 /*******************************************************************
6116 inits a SAMR_Q_CONNECT_ANON structure.
6117 ********************************************************************/
6119 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6121 DEBUG(5, ("init_samr_q_connect_anon\n"));
6123 q_u->ptr = 1;
6124 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6125 q_u->unknown_1 = 0x01;
6126 q_u->access_mask = 0x20;
6129 /*******************************************************************
6130 reads or writes a structure.
6131 ********************************************************************/
6133 BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
6134 prs_struct *ps, int depth)
6136 if (q_u == NULL)
6137 return False;
6139 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6140 depth++;
6142 if(!prs_align(ps))
6143 return False;
6145 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6146 return False;
6147 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6148 return False;
6149 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6150 return False;
6151 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6152 return False;
6154 return True;
6157 /*******************************************************************
6158 reads or writes a structure.
6159 ********************************************************************/
6161 BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
6162 prs_struct *ps, int depth)
6164 if (r_u == NULL)
6165 return False;
6167 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6168 depth++;
6170 if(!prs_align(ps))
6171 return False;
6173 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6174 return False;
6176 if(!prs_uint32("status", ps, depth, &r_u->status))
6177 return False;
6179 return True;
6182 /*******************************************************************
6183 inits a SAMR_Q_GET_DOM_PWINFO structure.
6184 ********************************************************************/
6186 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6187 char *srv_name)
6189 int len_srv_name = strlen(srv_name);
6191 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6193 q_u->ptr = 1;
6194 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6195 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6198 /*******************************************************************
6199 reads or writes a structure.
6200 ********************************************************************/
6202 BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6203 prs_struct *ps, int depth)
6205 if (q_u == NULL)
6206 return False;
6208 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6209 depth++;
6211 if(!prs_align(ps))
6212 return False;
6214 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6215 return False;
6216 if (q_u->ptr != 0) {
6217 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6218 return False;
6219 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6220 return False;
6223 return True;
6226 /*******************************************************************
6227 reads or writes a structure.
6228 ********************************************************************/
6230 BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6231 prs_struct *ps, int depth)
6233 if (r_u == NULL)
6234 return False;
6236 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6237 depth++;
6239 if(!prs_align(ps))
6240 return False;
6242 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
6243 return False;
6244 if(!prs_align(ps))
6245 return False;
6246 if(!prs_uint16("unk_1", ps, depth, &r_u->unk_1))
6247 return False;
6248 if(!prs_align(ps))
6249 return False;
6250 #if 0
6251 if(!prs_uint16("unk_2", ps, depth, &r_u->unk_2))
6252 return False;
6253 if(!prs_align(ps))
6254 return False;
6255 #endif
6256 if(!prs_uint32("status", ps, depth, &r_u->status))
6257 return False;
6259 return True;
6262 /*******************************************************************
6263 make a SAMR_ENC_PASSWD structure.
6264 ********************************************************************/
6266 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
6268 ZERO_STRUCTP(pwd);
6270 if (pass == NULL) {
6271 pwd->ptr = 0;
6272 } else {
6273 pwd->ptr = 1;
6274 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6278 /*******************************************************************
6279 reads or writes a SAMR_ENC_PASSWD structure.
6280 ********************************************************************/
6282 BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
6283 prs_struct *ps, int depth)
6285 if (pwd == NULL)
6286 return False;
6288 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6289 depth++;
6291 if(!prs_align(ps))
6292 return False;
6294 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
6295 return False;
6297 if (pwd->ptr != 0) {
6298 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
6299 return False;
6302 return True;
6305 /*******************************************************************
6306 inits a SAMR_ENC_HASH structure.
6307 ********************************************************************/
6309 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
6311 ZERO_STRUCTP(hsh);
6313 if (hash == NULL) {
6314 hsh->ptr = 0;
6315 } else {
6316 hsh->ptr = 1;
6317 memcpy(hsh->hash, hash, sizeof(hsh->hash));
6321 /*******************************************************************
6322 reads or writes a SAMR_ENC_HASH structure.
6323 ********************************************************************/
6325 BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
6326 prs_struct *ps, int depth)
6328 if (hsh == NULL)
6329 return False;
6331 prs_debug(ps, depth, desc, "samr_io_enc_hash");
6332 depth++;
6334 if(!prs_align(ps))
6335 return False;
6337 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
6338 return False;
6339 if (hsh->ptr != 0) {
6340 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
6341 return False;
6344 return True;
6347 /*******************************************************************
6348 inits a SAMR_R_GET_DOM_PWINFO structure.
6349 ********************************************************************/
6351 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
6352 char *dest_host, char *user_name,
6353 char nt_newpass[516],
6354 uchar nt_oldhash[16],
6355 char lm_newpass[516],
6356 uchar lm_oldhash[16])
6358 int len_dest_host = strlen(dest_host);
6359 int len_user_name = strlen(user_name);
6361 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
6363 q_u->ptr_0 = 1;
6364 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
6365 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
6366 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
6367 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
6369 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
6370 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
6372 q_u->unknown = 0x01;
6374 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
6375 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
6378 /*******************************************************************
6379 reads or writes a structure.
6380 ********************************************************************/
6382 BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
6383 prs_struct *ps, int depth)
6385 if (q_u == NULL)
6386 return False;
6388 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
6389 depth++;
6391 if(!prs_align(ps))
6392 return False;
6394 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
6395 return False;
6397 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
6398 return False;
6399 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
6400 return False;
6402 if(!prs_align(ps))
6403 return False;
6404 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
6405 return False;
6406 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
6407 return False;
6409 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
6410 return False;
6411 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
6412 return False;
6414 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
6415 return False;
6417 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
6418 return False;
6419 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
6420 return False;
6422 return True;
6425 /*******************************************************************
6426 inits a SAMR_R_CHGPASSWD_USER structure.
6427 ********************************************************************/
6429 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, uint32 status)
6431 DEBUG(5, ("init_r_chgpasswd_user\n"));
6433 r_u->status = status;
6436 /*******************************************************************
6437 reads or writes a structure.
6438 ********************************************************************/
6440 BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
6441 prs_struct *ps, int depth)
6443 if (r_u == NULL)
6444 return False;
6446 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
6447 depth++;
6449 if(!prs_align(ps))
6450 return False;
6452 if(!prs_uint32("status", ps, depth, &r_u->status))
6453 return False;
6455 return True;