Added Tim's fixes for dynamic samr calls. Raised max component limit to 256.
[Samba/ekacnet.git] / source / rpc_parse / parse_samr.c
blobefe4b6df0eb25723dcc4cdc190aa71428ddf74bc
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 "nterr.h"
31 extern int DEBUGLEVEL;
33 /*******************************************************************
34 inits a SAMR_Q_CLOSE_HND structure.
35 ********************************************************************/
37 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
39 DEBUG(5, ("init_samr_q_close_hnd\n"));
41 q_c->pol = *hnd;
44 /*******************************************************************
45 reads or writes a structure.
46 ********************************************************************/
48 BOOL samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND * q_u,
49 prs_struct *ps, int depth)
51 if (q_u == NULL)
52 return False;
54 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
55 depth++;
57 if(!prs_align(ps))
58 return False;
60 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
63 /*******************************************************************
64 reads or writes a structure.
65 ********************************************************************/
67 BOOL samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND * r_u,
68 prs_struct *ps, int depth)
70 if (r_u == NULL)
71 return False;
73 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
74 depth++;
76 if(!prs_align(ps))
77 return False;
79 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
80 return False;
82 if(!prs_uint32("status", ps, depth, &r_u->status))
83 return False;
85 return True;
88 /*******************************************************************
89 inits a SAMR_Q_LOOKUP_DOMAIN structure.
90 ********************************************************************/
92 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
93 POLICY_HND *pol, char *dom_name)
95 int len_name = strlen(dom_name);
97 DEBUG(5, ("init_samr_q_lookup_domain\n"));
99 q_u->connect_pol = *pol;
101 init_uni_hdr(&q_u->hdr_domain, len_name);
102 init_unistr2(&q_u->uni_domain, dom_name, len_name);
105 /*******************************************************************
106 reads or writes a structure.
107 ********************************************************************/
108 BOOL samr_io_q_lookup_domain(char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
109 prs_struct *ps, int depth)
111 if (q_u == NULL)
112 return False;
114 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
115 depth++;
117 if(!prs_align(ps))
118 return False;
120 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
121 return False;
123 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
124 return False;
126 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
127 return False;
129 return True;
132 /*******************************************************************
133 inits a SAMR_R_LOOKUP_DOMAIN structure.
134 ********************************************************************/
136 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
137 DOM_SID *dom_sid, uint32 status)
139 DEBUG(5, ("init_samr_r_lookup_domain\n"));
141 r_u->status = status;
142 r_u->ptr_sid = 0;
143 if (status == 0x0) {
144 r_u->ptr_sid = 1;
145 init_dom_sid2(&r_u->dom_sid, dom_sid);
149 /*******************************************************************
150 reads or writes a structure.
151 ********************************************************************/
153 BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
154 prs_struct *ps, int depth)
156 if (r_u == NULL)
157 return False;
159 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
160 depth++;
162 if(!prs_align(ps))
163 return False;
165 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
166 return False;
168 if (r_u->ptr_sid != 0) {
169 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
170 return False;
171 if(!prs_align(ps))
172 return False;
175 if(!prs_uint32("status", ps, depth, &r_u->status))
176 return False;
178 return True;
181 /*******************************************************************
182 reads or writes a structure.
183 ********************************************************************/
185 void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
187 DEBUG(5, ("samr_init_samr_q_unknown_2d\n"));
189 q_u->dom_pol = *dom_pol;
190 init_dom_sid2(&q_u->sid, sid);
193 /*******************************************************************
194 reads or writes a structure.
195 ********************************************************************/
197 BOOL samr_io_q_unknown_2d(char *desc, SAMR_Q_UNKNOWN_2D * q_u,
198 prs_struct *ps, int depth)
200 if (q_u == NULL)
201 return False;
203 prs_debug(ps, depth, desc, "samr_io_q_unknown_2d");
204 depth++;
206 if(!prs_align(ps))
207 return False;
209 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
210 return False;
212 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
213 return False;
215 if(!prs_align(ps))
216 return False;
218 return True;
221 /*******************************************************************
222 reads or writes a structure.
223 ********************************************************************/
225 BOOL samr_io_r_unknown_2d(char *desc, SAMR_R_UNKNOWN_2D * r_u,
226 prs_struct *ps, int depth)
228 if (r_u == NULL)
229 return False;
231 prs_debug(ps, depth, desc, "samr_io_r_unknown_2d");
232 depth++;
234 if(!prs_align(ps))
235 return False;
237 if(!prs_uint32("status", ps, depth, &r_u->status))
238 return False;
240 return True;
243 /*******************************************************************
244 reads or writes a structure.
245 ********************************************************************/
247 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
248 POLICY_HND *pol, uint32 flags,
249 DOM_SID *sid)
251 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
253 q_u->pol = *pol;
254 q_u->flags = flags;
255 init_dom_sid2(&q_u->dom_sid, sid);
258 /*******************************************************************
259 reads or writes a structure.
260 ********************************************************************/
262 BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
263 prs_struct *ps, int depth)
265 if (q_u == NULL)
266 return False;
268 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
269 depth++;
271 if(!prs_align(ps))
272 return False;
274 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
275 return False;
277 if(!prs_uint32("flags", ps, depth, &q_u->flags))
278 return False;
280 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
281 return False;
283 return True;
286 /*******************************************************************
287 reads or writes a structure.
288 ********************************************************************/
290 BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN * r_u,
291 prs_struct *ps, int depth)
293 if (r_u == NULL)
294 return False;
296 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
297 depth++;
299 if(!prs_align(ps))
300 return False;
302 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
303 return False;
305 if(!prs_uint32("status", ps, depth, &r_u->status))
306 return False;
308 return True;
311 /*******************************************************************
312 reads or writes a structure.
313 ********************************************************************/
315 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
316 POLICY_HND *user_pol)
318 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
320 q_u->user_pol = *user_pol;
323 /*******************************************************************
324 reads or writes a structure.
325 ********************************************************************/
327 BOOL samr_io_q_get_usrdom_pwinfo(char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
328 prs_struct *ps, int depth)
330 if (q_u == NULL)
331 return False;
333 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
334 depth++;
336 if(!prs_align(ps))
337 return False;
339 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
342 /*******************************************************************
343 Init.
344 ********************************************************************/
346 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, uint32 status)
348 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
350 r_u->unknown_0 = 0x0000;
351 r_u->unknown_1 = 0x0015;
352 r_u->unknown_2 = 0x00000000;
354 r_u->status = status;
357 /*******************************************************************
358 reads or writes a structure.
359 ********************************************************************/
361 BOOL samr_io_r_get_usrdom_pwinfo(char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
362 prs_struct *ps, int depth)
364 if (r_u == NULL)
365 return False;
367 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
368 depth++;
370 if(!prs_align(ps))
371 return False;
373 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
374 return False;
375 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
376 return False;
377 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
378 return False;
379 if(!prs_uint32("status ", ps, depth, &r_u->status))
380 return False;
382 return True;
385 /*******************************************************************
386 reads or writes a structure.
387 ********************************************************************/
389 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
390 POLICY_HND *user_pol, uint32 sec_info)
392 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
394 q_u->user_pol = *user_pol;
395 q_u->sec_info = sec_info;
399 /*******************************************************************
400 reads or writes a structure.
401 ********************************************************************/
403 BOOL samr_io_q_query_sec_obj(char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
404 prs_struct *ps, int depth)
406 if (q_u == NULL)
407 return False;
409 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
410 depth++;
412 if(!prs_align(ps))
413 return False;
415 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
416 return False;
418 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
419 return False;
421 return True;
424 /*******************************************************************
425 reads or writes a structure.
426 ********************************************************************/
428 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
429 POLICY_HND *domain_pol, uint16 switch_value)
431 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
433 q_u->domain_pol = *domain_pol;
434 q_u->switch_value = switch_value;
437 /*******************************************************************
438 reads or writes a structure.
439 ********************************************************************/
441 BOOL samr_io_q_query_dom_info(char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
442 prs_struct *ps, int depth)
444 if (q_u == NULL)
445 return False;
447 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
448 depth++;
450 if(!prs_align(ps))
451 return False;
453 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
454 return False;
456 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
457 return False;
459 return True;
463 /*******************************************************************
464 inits a structure.
465 ********************************************************************/
467 void init_unk_info3(SAM_UNK_INFO_3 * u_3)
469 u_3->unknown_0 = 0x00000000;
470 u_3->unknown_1 = 0x80000000;
473 /*******************************************************************
474 reads or writes a structure.
475 ********************************************************************/
477 static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 * u_3,
478 prs_struct *ps, int depth)
480 if (u_3 == NULL)
481 return False;
483 prs_debug(ps, depth, desc, "sam_io_unk_info3");
484 depth++;
486 if(!prs_uint32("unknown_0", ps, depth, &u_3->unknown_0)) /* 0x0000 0000 */
487 return False;
488 if(!prs_uint32("unknown_1", ps, depth, &u_3->unknown_1)) /* 0x8000 0000 */
489 return False;
491 return True;
494 /*******************************************************************
495 inits a structure.
496 ********************************************************************/
498 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
500 u_6->unknown_0 = 0x00000000;
501 u_6->ptr_0 = 1;
502 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
505 /*******************************************************************
506 reads or writes a structure.
507 ********************************************************************/
509 static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 * u_6,
510 prs_struct *ps, int depth)
512 if (u_6 == NULL)
513 return False;
515 prs_debug(ps, depth, desc, "sam_io_unk_info6");
516 depth++;
518 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
519 return False;
520 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
521 return False;
522 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
523 return False;
525 return True;
528 /*******************************************************************
529 inits a structure.
530 ********************************************************************/
532 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
534 u_7->unknown_0 = 0x0003;
537 /*******************************************************************
538 reads or writes a structure.
539 ********************************************************************/
541 static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 * u_7,
542 prs_struct *ps, int depth)
544 if (u_7 == NULL)
545 return False;
547 prs_debug(ps, depth, desc, "sam_io_unk_info7");
548 depth++;
550 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
551 return False;
553 return True;
556 /*******************************************************************
557 inits a structure.
558 ********************************************************************/
560 void init_unk_info12(SAM_UNK_INFO_12 * u_12)
562 u_12->unknown_0 = 0xcf1dcc00;
563 u_12->unknown_1 = 0xfffffffb;
564 u_12->unknown_2 = 0xcf1dcc00;
565 u_12->unknown_3 = 0xfffffffb;
567 u_12->unknown_4 = 0x8a880000;
570 /*******************************************************************
571 reads or writes a structure.
572 ********************************************************************/
574 static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
575 prs_struct *ps, int depth)
577 if (u_12 == NULL)
578 return False;
580 prs_debug(ps, depth, desc, "sam_io_unk_info12");
581 depth++;
583 if(!prs_uint32("unknown_0", ps, depth, &u_12->unknown_0))
584 return False;
585 if(!prs_uint32("unknown_1", ps, depth, &u_12->unknown_1))
586 return False;
587 if(!prs_uint32("unknown_2", ps, depth, &u_12->unknown_2))
588 return False;
589 if(!prs_uint32("unknown_3", ps, depth, &u_12->unknown_3))
590 return False;
591 if(!prs_uint32("unknown_4", ps, depth, &u_12->unknown_4))
592 return False;
594 return True;
597 /*******************************************************************
598 inits a structure.
599 ********************************************************************/
600 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
601 char *domain, char *server,
602 uint32 seq_num)
604 int len_domain = strlen(domain);
605 int len_server = strlen(server);
607 u_2->unknown_0 = 0x00000000;
608 u_2->unknown_1 = 0x80000000;
609 u_2->unknown_2 = 0x00000000;
611 u_2->ptr_0 = 1;
612 init_uni_hdr(&u_2->hdr_domain, len_domain);
613 init_uni_hdr(&u_2->hdr_server, len_server);
615 u_2->seq_num = seq_num;
616 u_2->unknown_3 = 0x00000000;
618 u_2->unknown_4 = 0x00000001;
619 u_2->unknown_5 = 0x00000003;
620 u_2->unknown_6 = 0x00000001;
621 u_2->num_domain_usrs = MAX_SAM_ENTRIES;
622 u_2->num_domain_grps = MAX_SAM_ENTRIES;
623 u_2->num_local_grps = MAX_SAM_ENTRIES;
625 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
627 init_unistr2(&u_2->uni_domain, domain, len_domain);
628 init_unistr2(&u_2->uni_server, server, len_server);
631 /*******************************************************************
632 reads or writes a structure.
633 ********************************************************************/
635 static BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 * u_2,
636 prs_struct *ps, int depth)
638 if (u_2 == NULL)
639 return False;
641 prs_debug(ps, depth, desc, "sam_io_unk_info2");
642 depth++;
644 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
645 return False;
646 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
647 return False;
648 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
649 return False;
651 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
652 return False;
653 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
654 return False;
655 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
656 return False;
658 /* put all the data in here, at the moment, including what the above
659 pointer is referring to
662 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
663 return False;
664 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
665 return False;
667 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
668 return False;
669 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
670 return False;
671 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
672 return False;
673 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
674 return False;
675 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
676 return False;
677 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
678 return False;
680 if(!prs_uint8s(False, "padding", ps, depth, u_2->padding,sizeof(u_2->padding)))
681 return False;
683 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
684 return False;
685 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
686 return False;
688 return True;
691 /*******************************************************************
692 inits a structure.
693 ********************************************************************/
695 void init_unk_info1(SAM_UNK_INFO_1 * u_1)
697 memset(u_1->padding, 0, sizeof(u_1->padding)); /* 12 bytes zeros */
698 u_1->unknown_1 = 0x80000000;
699 u_1->unknown_2 = 0x00000000;
702 /*******************************************************************
703 reads or writes a structure.
704 ********************************************************************/
706 static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 * u_1,
707 prs_struct *ps, int depth)
709 if (u_1 == NULL)
710 return False;
712 prs_debug(ps, depth, desc, "sam_io_unk_info1");
713 depth++;
715 if(!prs_uint8s(False, "padding", ps, depth, u_1->padding, sizeof(u_1->padding)))
716 return False;
718 if(!prs_uint32("unknown_1", ps, depth, &u_1->unknown_1)) /* 0x8000 0000 */
719 return False;
720 if(!prs_uint32("unknown_2", ps, depth, &u_1->unknown_2)) /* 0x0000 0000 */
721 return False;
723 return True;
726 /*******************************************************************
727 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
728 ********************************************************************/
730 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
731 uint16 switch_value, SAM_UNK_CTR * ctr,
732 uint32 status)
734 DEBUG(5, ("init_samr_r_query_dom_info\n"));
736 r_u->ptr_0 = 0;
737 r_u->switch_value = 0;
738 r_u->status = status; /* return status */
740 if (status == 0) {
741 r_u->switch_value = switch_value;
742 r_u->ptr_0 = 1;
743 r_u->ctr = ctr;
747 /*******************************************************************
748 reads or writes a structure.
749 ********************************************************************/
751 BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
752 prs_struct *ps, int depth)
754 if (r_u == NULL)
755 return False;
757 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
758 depth++;
760 if(!prs_align(ps))
761 return False;
763 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
764 return False;
766 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
767 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
768 return False;
769 if(!prs_align(ps))
770 return False;
772 switch (r_u->switch_value) {
773 case 0x0c:
774 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
775 return False;
776 break;
777 case 0x07:
778 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
779 return False;
780 break;
781 case 0x06:
782 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
783 return False;
784 break;
785 case 0x03:
786 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
787 return False;
788 break;
789 case 0x02:
790 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
791 return False;
792 break;
793 case 0x01:
794 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
795 return False;
796 break;
797 default:
798 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
799 r_u->switch_value));
800 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
801 return False;
805 if(!prs_align(ps))
806 return False;
808 if(!prs_uint32("status", ps, depth, &r_u->status))
809 return False;
811 return True;
814 /*******************************************************************
815 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
816 ********************************************************************/
818 BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
819 prs_struct *ps, int depth)
821 if (r_u == NULL)
822 return False;
824 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
825 depth++;
827 if(!prs_align(ps))
828 return False;
830 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
831 return False;
832 if (r_u->ptr != 0) {
833 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
834 return False;
837 if(!prs_uint32("status", ps, depth, &r_u->status))
838 return False;
840 return True;
843 /*******************************************************************
844 reads or writes a SAM_STR1 structure.
845 ********************************************************************/
847 static BOOL sam_io_sam_str1(char *desc, SAM_STR1 * sam, uint32 acct_buf,
848 uint32 name_buf, uint32 desc_buf,
849 prs_struct *ps, int depth)
851 if (sam == NULL)
852 return False;
854 prs_debug(ps, depth, desc, "sam_io_sam_str1");
855 depth++;
857 if(!prs_align(ps))
858 return False;
859 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
860 return False;
862 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
863 return False;
865 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
866 return False;
868 return True;
871 /*******************************************************************
872 inits a SAM_ENTRY1 structure.
873 ********************************************************************/
875 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
876 uint32 len_sam_name, uint32 len_sam_full,
877 uint32 len_sam_desc, uint32 rid_user,
878 uint16 acb_info)
880 DEBUG(5, ("init_sam_entry1\n"));
882 ZERO_STRUCTP(sam);
884 sam->user_idx = user_idx;
885 sam->rid_user = rid_user;
886 sam->acb_info = acb_info;
887 sam->pad = 0;
889 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
890 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
891 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
894 /*******************************************************************
895 reads or writes a SAM_ENTRY1 structure.
896 ********************************************************************/
898 static BOOL sam_io_sam_entry1(char *desc, SAM_ENTRY1 * sam,
899 prs_struct *ps, int depth)
901 if (sam == NULL)
902 return False;
904 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
905 depth++;
907 if(!prs_align(ps))
908 return False;
910 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
911 return False;
913 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
914 return False;
915 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
916 return False;
917 if(!prs_uint16("pad ", ps, depth, &sam->pad))
918 return False;
920 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
921 return False;
922 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
923 return False;
924 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
925 return False;
927 return True;
930 /*******************************************************************
931 reads or writes a SAM_STR2 structure.
932 ********************************************************************/
934 static BOOL sam_io_sam_str2(char *desc, SAM_STR2 * sam, uint32 acct_buf,
935 uint32 desc_buf, prs_struct *ps, int depth)
937 if (sam == NULL)
938 return False;
940 prs_debug(ps, depth, desc, "sam_io_sam_str2");
941 depth++;
943 if(!prs_align(ps))
944 return False;
946 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
947 return False;
948 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
949 return False;
951 return True;
954 /*******************************************************************
955 inits a SAM_ENTRY2 structure.
956 ********************************************************************/
957 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
958 uint32 len_sam_name, uint32 len_sam_desc,
959 uint32 rid_user, uint16 acb_info)
961 DEBUG(5, ("init_sam_entry2\n"));
963 sam->user_idx = user_idx;
964 sam->rid_user = rid_user;
965 sam->acb_info = acb_info;
966 sam->pad = 0;
968 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
969 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
972 /*******************************************************************
973 reads or writes a SAM_ENTRY2 structure.
974 ********************************************************************/
976 static BOOL sam_io_sam_entry2(char *desc, SAM_ENTRY2 * sam,
977 prs_struct *ps, int depth)
979 if (sam == NULL)
980 return False;
982 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
983 depth++;
985 if(!prs_align(ps))
986 return False;
988 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
989 return False;
991 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
992 return False;
993 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
994 return False;
995 if(!prs_uint16("pad ", ps, depth, &sam->pad))
996 return False;
998 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
999 return False;
1000 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1001 return False;
1003 return True;
1006 /*******************************************************************
1007 reads or writes a SAM_STR3 structure.
1008 ********************************************************************/
1010 static BOOL sam_io_sam_str3(char *desc, SAM_STR3 * sam, uint32 acct_buf,
1011 uint32 desc_buf, prs_struct *ps, int depth)
1013 if (sam == NULL)
1014 return False;
1016 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1017 depth++;
1019 if(!prs_align(ps))
1020 return False;
1022 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1023 return False;
1024 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1025 return False;
1027 return True;
1030 /*******************************************************************
1031 inits a SAM_ENTRY3 structure.
1032 ********************************************************************/
1034 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1035 uint32 len_grp_name, uint32 len_grp_desc,
1036 uint32 rid_grp)
1038 DEBUG(5, ("init_sam_entry3\n"));
1040 sam->grp_idx = grp_idx;
1041 sam->rid_grp = rid_grp;
1042 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1044 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1045 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1048 /*******************************************************************
1049 reads or writes a SAM_ENTRY3 structure.
1050 ********************************************************************/
1052 static BOOL sam_io_sam_entry3(char *desc, SAM_ENTRY3 * sam,
1053 prs_struct *ps, int depth)
1055 if (sam == NULL)
1056 return False;
1058 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1059 depth++;
1061 if(!prs_align(ps))
1062 return False;
1064 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1065 return False;
1067 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1068 return False;
1069 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1070 return False;
1072 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1073 return False;
1074 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1075 return False;
1077 return True;
1080 /*******************************************************************
1081 inits a SAM_ENTRY4 structure.
1082 ********************************************************************/
1084 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1085 uint32 len_acct_name)
1087 DEBUG(5, ("init_sam_entry4\n"));
1089 sam->user_idx = user_idx;
1090 init_str_hdr(&sam->hdr_acct_name, len_acct_name, len_acct_name,
1091 len_acct_name != 0);
1094 /*******************************************************************
1095 reads or writes a SAM_ENTRY4 structure.
1096 ********************************************************************/
1098 static BOOL sam_io_sam_entry4(char *desc, SAM_ENTRY4 * sam,
1099 prs_struct *ps, int depth)
1101 if (sam == NULL)
1102 return False;
1104 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1105 depth++;
1107 if(!prs_align(ps))
1108 return False;
1110 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1111 return False;
1112 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1113 return False;
1115 return True;
1118 /*******************************************************************
1119 inits a SAM_ENTRY5 structure.
1120 ********************************************************************/
1122 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1123 uint32 len_grp_name)
1125 DEBUG(5, ("init_sam_entry5\n"));
1127 sam->grp_idx = grp_idx;
1128 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1129 len_grp_name != 0);
1132 /*******************************************************************
1133 reads or writes a SAM_ENTRY5 structure.
1134 ********************************************************************/
1136 static BOOL sam_io_sam_entry5(char *desc, SAM_ENTRY5 * sam,
1137 prs_struct *ps, int depth)
1139 if (sam == NULL)
1140 return False;
1142 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1143 depth++;
1145 if(!prs_align(ps))
1146 return False;
1148 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1149 return False;
1150 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1151 return False;
1153 return True;
1156 /*******************************************************************
1157 inits a SAM_ENTRY structure.
1158 ********************************************************************/
1160 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1162 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1164 sam->rid = rid;
1165 init_uni_hdr(&sam->hdr_name, len_sam_name);
1168 /*******************************************************************
1169 reads or writes a SAM_ENTRY structure.
1170 ********************************************************************/
1172 static BOOL sam_io_sam_entry(char *desc, SAM_ENTRY * sam,
1173 prs_struct *ps, int depth)
1175 if (sam == NULL)
1176 return False;
1178 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1179 depth++;
1181 if(!prs_align(ps))
1182 return False;
1183 if(!prs_uint32("rid", ps, depth, &sam->rid))
1184 return False;
1185 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1186 return False;
1188 return True;
1191 /*******************************************************************
1192 inits a SAMR_Q_ENUM_DOM_USERS structure.
1193 ********************************************************************/
1195 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1196 uint32 start_idx,
1197 uint16 acb_mask, uint16 unk_1, uint32 size)
1199 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1201 q_e->pol = *pol;
1203 q_e->start_idx = start_idx; /* zero indicates lots */
1204 q_e->acb_mask = acb_mask;
1205 q_e->unknown_1 = unk_1;
1206 q_e->max_size = size;
1209 /*******************************************************************
1210 reads or writes a structure.
1211 ********************************************************************/
1213 BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1214 prs_struct *ps, int depth)
1216 if (q_e == NULL)
1217 return False;
1219 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1220 depth++;
1222 if(!prs_align(ps))
1223 return False;
1225 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1226 return False;
1228 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1229 return False;
1230 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1231 return False;
1232 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1233 return False;
1235 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1236 return False;
1238 return True;
1242 /*******************************************************************
1243 inits a SAMR_R_ENUM_DOM_USERS structure.
1244 ********************************************************************/
1246 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1247 uint32 next_idx, uint32 num_sam_entries)
1249 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1251 r_u->next_idx = next_idx;
1253 if (num_sam_entries != 0) {
1254 r_u->ptr_entries1 = 1;
1255 r_u->ptr_entries2 = 1;
1256 r_u->num_entries2 = num_sam_entries;
1257 r_u->num_entries3 = num_sam_entries;
1259 r_u->num_entries4 = num_sam_entries;
1260 } else {
1261 r_u->ptr_entries1 = 0;
1262 r_u->num_entries2 = num_sam_entries;
1263 r_u->ptr_entries2 = 1;
1267 /*******************************************************************
1268 reads or writes a structure.
1269 ********************************************************************/
1271 BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1272 prs_struct *ps, int depth)
1274 uint32 i;
1276 if (r_u == NULL)
1277 return False;
1279 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1280 depth++;
1282 if(!prs_align(ps))
1283 return False;
1285 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1286 return False;
1287 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1288 return False;
1290 if (r_u->ptr_entries1 != 0) {
1291 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1292 return False;
1293 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1294 return False;
1295 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1296 return False;
1298 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1299 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1300 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
1303 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1304 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1305 r_u->num_entries4 = 0;
1306 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1307 return False;
1310 for (i = 0; i < r_u->num_entries2; i++) {
1311 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1312 return False;
1315 for (i = 0; i < r_u->num_entries2; i++) {
1316 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1317 return False;
1322 if(!prs_align(ps))
1323 return False;
1325 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1326 return False;
1327 if(!prs_uint32("status", ps, depth, &r_u->status))
1328 return False;
1330 return True;
1333 /*******************************************************************
1334 inits a SAMR_Q_QUERY_DISPINFO structure.
1335 ********************************************************************/
1337 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1338 uint16 switch_level, uint32 start_idx,
1339 uint32 max_entries)
1341 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1343 q_e->domain_pol = *pol;
1345 q_e->switch_level = switch_level;
1347 q_e->start_idx = start_idx;
1348 q_e->max_entries = max_entries;
1349 q_e->max_size = 0xffff; /* Not especially useful */
1352 /*******************************************************************
1353 reads or writes a structure.
1354 ********************************************************************/
1356 BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1357 prs_struct *ps, int depth)
1359 if (q_e == NULL)
1360 return False;
1362 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1363 depth++;
1365 if(!prs_align(ps))
1366 return False;
1368 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1369 return False;
1371 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1372 return False;
1373 if(!prs_align(ps))
1374 return False;
1376 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1377 return False;
1378 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1379 return False;
1380 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1381 return False;
1383 return True;
1386 /*******************************************************************
1387 inits a SAM_DISPINFO_1 structure.
1388 ********************************************************************/
1390 void init_sam_dispinfo_1(SAM_DISPINFO_1 * sam, uint32 *num_entries,
1391 uint32 *data_size, uint32 start_idx,
1392 SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
1394 uint32 len_sam_name, len_sam_full, len_sam_desc;
1395 uint32 max_entries, max_data_size;
1396 uint32 dsize = 0;
1397 uint32 i;
1399 ZERO_STRUCTP(sam);
1401 max_entries = *num_entries;
1402 max_data_size = *data_size;
1404 DEBUG(5, ("init_sam_dispinfo_1: max_entries: %d max_dsize: 0x%x\n",
1405 max_entries, max_data_size));
1407 for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
1408 len_sam_name = pass[i].uni_user_name.uni_str_len;
1409 len_sam_full = pass[i].uni_full_name.uni_str_len;
1410 len_sam_desc = pass[i].uni_acct_desc.uni_str_len;
1412 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1413 len_sam_name, len_sam_full, len_sam_desc,
1414 pass[i].user_rid, pass[i].acb_info);
1416 copy_unistr2(&sam->str[i].uni_acct_name, &pass[i].uni_user_name);
1417 copy_unistr2(&sam->str[i].uni_full_name, &pass[i].uni_full_name);
1418 copy_unistr2(&sam->str[i].uni_acct_desc, &pass[i].uni_acct_desc);
1420 dsize += sizeof(SAM_ENTRY1);
1421 dsize += len_sam_name + len_sam_full + len_sam_desc;
1424 *num_entries = i;
1425 *data_size = dsize;
1428 /*******************************************************************
1429 reads or writes a structure.
1430 ********************************************************************/
1432 static BOOL sam_io_sam_dispinfo_1(char *desc, SAM_DISPINFO_1 * sam,
1433 uint32 num_entries,
1434 prs_struct *ps, int depth)
1436 uint32 i;
1438 if (sam == NULL)
1439 return False;
1441 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1442 depth++;
1444 if(!prs_align(ps))
1445 return False;
1447 SMB_ASSERT_ARRAY(sam->sam, num_entries);
1449 for (i = 0; i < num_entries; i++) {
1450 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1451 return False;
1454 for (i = 0; i < num_entries; i++) {
1455 if(!sam_io_sam_str1("", &sam->str[i],
1456 sam->sam[i].hdr_acct_name.buffer,
1457 sam->sam[i].hdr_user_name.buffer,
1458 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1459 return False;
1462 return True;
1465 /*******************************************************************
1466 inits a SAM_DISPINFO_2 structure.
1467 ********************************************************************/
1469 void init_sam_dispinfo_2(SAM_DISPINFO_2 * sam, uint32 *num_entries,
1470 uint32 *data_size, uint32 start_idx,
1471 SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
1473 uint32 len_sam_name, len_sam_desc;
1474 uint32 max_entries, max_data_size;
1475 uint32 dsize = 0;
1476 uint32 i;
1478 DEBUG(5, ("init_sam_dispinfo_2\n"));
1480 ZERO_STRUCTP(sam);
1482 max_entries = *num_entries;
1483 max_data_size = *data_size;
1485 for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
1486 len_sam_name = pass[i].uni_user_name.uni_str_len;
1487 len_sam_desc = pass[i].uni_acct_desc.uni_str_len;
1489 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1490 len_sam_name, len_sam_desc,
1491 pass[i].user_rid, pass[i].acb_info);
1493 copy_unistr2(&sam->str[i].uni_srv_name,
1494 &pass[i].uni_user_name);
1495 copy_unistr2(&sam->str[i].uni_srv_desc,
1496 &pass[i].uni_acct_desc);
1498 dsize += sizeof(SAM_ENTRY2);
1499 dsize += len_sam_name + len_sam_desc;
1502 *num_entries = i;
1503 *data_size = dsize;
1506 /*******************************************************************
1507 reads or writes a structure.
1508 ********************************************************************/
1510 static BOOL sam_io_sam_dispinfo_2(char *desc, SAM_DISPINFO_2 * sam,
1511 uint32 num_entries,
1512 prs_struct *ps, int depth)
1514 uint32 i;
1516 if (sam == NULL)
1517 return False;
1519 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1520 depth++;
1522 if(!prs_align(ps))
1523 return False;
1525 SMB_ASSERT_ARRAY(sam->sam, num_entries);
1527 for (i = 0; i < num_entries; i++) {
1528 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1529 return False;
1532 for (i = 0; i < num_entries; i++) {
1533 if(!sam_io_sam_str2("", &sam->str[i],
1534 sam->sam[i].hdr_srv_name.buffer,
1535 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1536 return False;
1539 return True;
1542 /*******************************************************************
1543 inits a SAM_DISPINFO_3 structure.
1544 ********************************************************************/
1546 void init_sam_dispinfo_3(SAM_DISPINFO_3 * sam, uint32 *num_entries,
1547 uint32 *data_size, uint32 start_idx,
1548 DOMAIN_GRP * grp)
1550 uint32 len_sam_name, len_sam_desc;
1551 uint32 max_entries, max_data_size;
1552 uint32 dsize = 0;
1553 uint32 i;
1555 DEBUG(5, ("init_sam_dispinfo_3\n"));
1557 ZERO_STRUCTP(sam);
1559 max_entries = *num_entries;
1560 max_data_size = *data_size;
1562 for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
1563 len_sam_name = strlen(grp[i].name);
1564 len_sam_desc = strlen(grp[i].comment);
1566 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp[i].rid);
1568 init_unistr2(&sam->str[i].uni_grp_name, grp[i].name, len_sam_name);
1569 init_unistr2(&sam->str[i].uni_grp_desc, grp[i].comment, len_sam_desc);
1571 dsize += sizeof(SAM_ENTRY3);
1572 dsize += (len_sam_name + len_sam_desc) * 2;
1573 dsize += 14;
1576 *num_entries = i;
1577 *data_size = dsize;
1580 /*******************************************************************
1581 reads or writes a structure.
1582 ********************************************************************/
1584 static BOOL sam_io_sam_dispinfo_3(char *desc, SAM_DISPINFO_3 * sam,
1585 uint32 num_entries,
1586 prs_struct *ps, int depth)
1588 uint32 i;
1590 if (sam == NULL)
1591 return False;
1593 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1594 depth++;
1596 if(!prs_align(ps))
1597 return False;
1599 SMB_ASSERT_ARRAY(sam->sam, num_entries);
1601 for (i = 0; i < num_entries; i++) {
1602 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1603 return False;
1606 for (i = 0; i < num_entries; i++) {
1607 if(!sam_io_sam_str3("", &sam->str[i],
1608 sam->sam[i].hdr_grp_name.buffer,
1609 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1610 return False;
1613 return True;
1616 /*******************************************************************
1617 inits a SAM_DISPINFO_4 structure.
1618 ********************************************************************/
1620 void init_sam_dispinfo_4(SAM_DISPINFO_4 * sam, uint32 *num_entries,
1621 uint32 *data_size, uint32 start_idx,
1622 SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
1624 fstring sam_name;
1625 uint32 len_sam_name;
1626 uint32 max_entries, max_data_size;
1627 uint32 dsize = 0;
1628 uint32 i;
1630 DEBUG(5, ("init_sam_dispinfo_4\n"));
1632 ZERO_STRUCTP(sam);
1634 max_entries = *num_entries;
1635 max_data_size = *data_size;
1637 for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
1638 len_sam_name = pass[i].uni_user_name.uni_str_len;
1640 init_sam_entry4(&sam->sam[i], start_idx + i + 1,
1641 len_sam_name);
1643 unistr2_to_ascii(sam_name, &pass[i].uni_user_name,
1644 sizeof(sam_name));
1645 init_string2(&sam->str[i].acct_name, sam_name,
1646 len_sam_name);
1648 dsize += sizeof(SAM_ENTRY4);
1649 dsize += len_sam_name;
1652 *num_entries = i;
1653 *data_size = dsize;
1656 /*******************************************************************
1657 reads or writes a structure.
1658 ********************************************************************/
1660 static BOOL sam_io_sam_dispinfo_4(char *desc, SAM_DISPINFO_4 * sam,
1661 uint32 num_entries,
1662 prs_struct *ps, int depth)
1664 uint32 i;
1666 if (sam == NULL)
1667 return False;
1669 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1670 depth++;
1672 if(!prs_align(ps))
1673 return False;
1675 SMB_ASSERT_ARRAY(sam->sam, num_entries);
1677 for (i = 0; i < num_entries; i++) {
1678 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1679 return False;
1682 for (i = 0; i < num_entries; i++) {
1683 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1684 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1685 return False;
1686 if(!prs_align(ps))
1687 return False;
1690 return True;
1693 /*******************************************************************
1694 inits a SAM_DISPINFO_5 structure.
1695 ********************************************************************/
1697 void init_sam_dispinfo_5(SAM_DISPINFO_5 * sam, uint32 *num_entries,
1698 uint32 *data_size, uint32 start_idx,
1699 DOMAIN_GRP * grp)
1701 uint32 len_sam_name;
1702 uint32 max_entries, max_data_size;
1703 uint32 dsize = 0;
1704 uint32 i;
1706 DEBUG(5, ("init_sam_dispinfo_5\n"));
1708 ZERO_STRUCTP(sam);
1710 max_entries = *num_entries;
1711 max_data_size = *data_size;
1713 for (i = 0; (i < max_entries) && (dsize < max_data_size); i++) {
1714 len_sam_name = strlen(grp[i].name);
1716 init_sam_entry5(&sam->sam[i], start_idx + i + 1,
1717 len_sam_name);
1719 init_string2(&sam->str[i].grp_name, grp[i].name,
1720 len_sam_name);
1722 dsize += sizeof(SAM_ENTRY5);
1723 dsize += len_sam_name;
1726 *num_entries = i;
1727 *data_size = dsize;
1730 /*******************************************************************
1731 reads or writes a structure.
1732 ********************************************************************/
1734 static BOOL sam_io_sam_dispinfo_5(char *desc, SAM_DISPINFO_5 * sam,
1735 uint32 num_entries,
1736 prs_struct *ps, int depth)
1738 uint32 i;
1740 if (sam == NULL)
1741 return False;
1743 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1744 depth++;
1746 if(!prs_align(ps))
1747 return False;
1749 SMB_ASSERT_ARRAY(sam->sam, num_entries);
1751 for (i = 0; i < num_entries; i++) {
1752 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1753 return False;
1756 for (i = 0; i < num_entries; i++) {
1757 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1758 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1759 return False;
1760 if(!prs_align(ps))
1761 return False;
1764 return True;
1767 /*******************************************************************
1768 inits a SAMR_R_QUERY_DISPINFO structure.
1769 ********************************************************************/
1771 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1772 uint32 num_entries, uint32 data_size,
1773 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1774 uint32 status)
1776 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1778 r_u->total_size = data_size; /* not calculated */
1779 r_u->data_size = data_size;
1781 r_u->switch_level = switch_level;
1782 r_u->num_entries = num_entries;
1784 if (num_entries==0)
1785 r_u->ptr_entries = 0;
1786 else
1787 r_u->ptr_entries = 1;
1789 r_u->num_entries2 = num_entries;
1790 r_u->ctr = ctr;
1792 r_u->status = status;
1795 /*******************************************************************
1796 reads or writes a structure.
1797 ********************************************************************/
1799 BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1800 prs_struct *ps, int depth)
1802 if (r_u == NULL)
1803 return False;
1805 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
1806 depth++;
1808 if(!prs_align(ps))
1809 return False;
1811 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
1812 return False;
1813 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
1814 return False;
1815 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
1816 return False;
1817 if(!prs_align(ps))
1818 return False;
1820 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
1821 return False;
1822 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
1823 return False;
1825 if (r_u->ptr_entries==0) {
1826 if(!prs_align(ps))
1827 return False;
1828 if(!prs_uint32("status", ps, depth, &r_u->status))
1829 return False;
1831 return True;
1834 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1835 return False;
1837 switch (r_u->switch_level) {
1838 case 0x1:
1839 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
1840 r_u->num_entries, ps, depth))
1841 return False;
1842 break;
1843 case 0x2:
1844 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
1845 r_u->num_entries, ps, depth))
1846 return False;
1847 break;
1848 case 0x3:
1849 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
1850 r_u->num_entries, ps, depth))
1851 return False;
1852 break;
1853 case 0x4:
1854 if(!sam_io_sam_dispinfo_4("user list",
1855 r_u->ctr->sam.info4,
1856 r_u->num_entries, ps, depth))
1857 return False;
1858 break;
1859 case 0x5:
1860 if(!sam_io_sam_dispinfo_5("group list",
1861 r_u->ctr->sam.info5,
1862 r_u->num_entries, ps, depth))
1863 return False;
1864 break;
1865 default:
1866 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
1867 break;
1870 if(!prs_align(ps))
1871 return False;
1872 if(!prs_uint32("status", ps, depth, &r_u->status))
1873 return False;
1875 return True;
1878 /*******************************************************************
1879 inits a SAMR_Q_OPEN_GROUP structure.
1880 ********************************************************************/
1882 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
1883 POLICY_HND *hnd,
1884 uint32 access_mask, uint32 rid)
1886 DEBUG(5, ("init_samr_q_open_group\n"));
1888 q_c->domain_pol = *hnd;
1889 q_c->access_mask = access_mask;
1890 q_c->rid_group = rid;
1893 /*******************************************************************
1894 reads or writes a structure.
1895 ********************************************************************/
1897 BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
1898 prs_struct *ps, int depth)
1900 if (q_u == NULL)
1901 return False;
1903 prs_debug(ps, depth, desc, "samr_io_q_open_group");
1904 depth++;
1906 if(!prs_align(ps))
1907 return False;
1909 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
1910 return False;
1912 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
1913 return False;
1914 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
1915 return False;
1917 return True;
1920 /*******************************************************************
1921 reads or writes a structure.
1922 ********************************************************************/
1924 BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
1925 prs_struct *ps, int depth)
1927 if (r_u == NULL)
1928 return False;
1930 prs_debug(ps, depth, desc, "samr_io_r_open_group");
1931 depth++;
1933 if(!prs_align(ps))
1934 return False;
1936 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
1937 return False;
1939 if(!prs_uint32("status", ps, depth, &r_u->status))
1940 return False;
1942 return True;
1945 /*******************************************************************
1946 inits a GROUP_INFO1 structure.
1947 ********************************************************************/
1949 void init_samr_group_info1(GROUP_INFO1 * gr1,
1950 char *acct_name, char *acct_desc,
1951 uint32 num_members)
1953 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
1954 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
1956 DEBUG(5, ("init_samr_group_info1\n"));
1958 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
1960 gr1->unknown_1 = 0x3;
1961 gr1->num_members = num_members;
1963 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
1965 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
1966 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
1969 /*******************************************************************
1970 reads or writes a structure.
1971 ********************************************************************/
1973 BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
1974 prs_struct *ps, int depth)
1976 if (gr1 == NULL)
1977 return False;
1979 prs_debug(ps, depth, desc, "samr_io_group_info1");
1980 depth++;
1982 if(!prs_align(ps))
1983 return False;
1985 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
1986 return False;
1988 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
1989 return False;
1990 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
1991 return False;
1993 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
1994 return False;
1996 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
1997 gr1->hdr_acct_name.buffer, ps, depth))
1998 return False;
2000 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2001 gr1->hdr_acct_desc.buffer, ps, depth))
2002 return False;
2004 return True;
2007 /*******************************************************************
2008 inits a GROUP_INFO4 structure.
2009 ********************************************************************/
2011 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2013 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2015 DEBUG(5, ("init_samr_group_info4\n"));
2017 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2018 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2021 /*******************************************************************
2022 reads or writes a structure.
2023 ********************************************************************/
2025 BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
2026 prs_struct *ps, int depth)
2028 if (gr4 == NULL)
2029 return False;
2031 prs_debug(ps, depth, desc, "samr_io_group_info4");
2032 depth++;
2034 if(!prs_align(ps))
2035 return False;
2037 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2038 return False;
2039 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2040 gr4->hdr_acct_desc.buffer, ps, depth))
2041 return False;
2043 return True;
2046 /*******************************************************************
2047 reads or writes a structure.
2048 ********************************************************************/
2050 static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR **ctr,
2051 prs_struct *ps, int depth)
2053 if (UNMARSHALLING(ps))
2054 *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
2056 if (*ctr == NULL)
2057 return False;
2059 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2060 depth++;
2062 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2063 return False;
2064 if(!prs_uint16("switch_value2", ps, depth, &(*ctr)->switch_value2))
2065 return False;
2067 switch ((*ctr)->switch_value1) {
2068 case 1:
2069 if(!samr_io_group_info1("group_info1",
2070 &(*ctr)->group.info1, ps, depth))
2071 return False;
2072 break;
2073 case 4:
2074 if(!samr_io_group_info4("group_info4",
2075 &(*ctr)->group.info4, ps, depth))
2076 return False;
2077 break;
2078 default:
2079 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2080 break;
2083 return True;
2086 /*******************************************************************
2087 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2088 ********************************************************************/
2090 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2091 POLICY_HND *pol, char *acct_desc,
2092 uint32 access_mask)
2094 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2096 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2098 q_e->pol = *pol;
2100 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2101 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2103 q_e->access_mask = access_mask;
2106 /*******************************************************************
2107 reads or writes a structure.
2108 ********************************************************************/
2110 BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2111 prs_struct *ps, int depth)
2113 if (q_e == NULL)
2114 return False;
2116 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2117 depth++;
2119 if(!prs_align(ps))
2120 return False;
2122 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2123 return False;
2125 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2126 return False;
2127 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2128 q_e->hdr_acct_desc.buffer, ps, depth))
2129 return False;
2131 if(!prs_align(ps))
2132 return False;
2133 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2134 return False;
2136 return True;
2139 /*******************************************************************
2140 reads or writes a structure.
2141 ********************************************************************/
2143 BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2144 prs_struct *ps, int depth)
2146 if (r_u == NULL)
2147 return False;
2149 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2150 depth++;
2152 if(!prs_align(ps))
2153 return False;
2155 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2156 return False;
2158 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2159 return False;
2160 if(!prs_uint32("status", ps, depth, &r_u->status))
2161 return False;
2163 return True;
2166 /*******************************************************************
2167 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2168 ********************************************************************/
2170 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2171 POLICY_HND *hnd)
2173 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2175 q_c->group_pol = *hnd;
2178 /*******************************************************************
2179 reads or writes a structure.
2180 ********************************************************************/
2182 BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2183 prs_struct *ps, int depth)
2185 if (q_u == NULL)
2186 return False;
2188 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2189 depth++;
2191 if(!prs_align(ps))
2192 return False;
2194 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2195 return False;
2197 return True;
2200 /*******************************************************************
2201 reads or writes a structure.
2202 ********************************************************************/
2204 BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2205 prs_struct *ps, int depth)
2207 if (r_u == NULL)
2208 return False;
2210 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2211 depth++;
2213 if(!prs_align(ps))
2214 return False;
2216 if(!prs_uint32("status", ps, depth, &r_u->status))
2217 return False;
2219 return True;
2222 /*******************************************************************
2223 inits a SAMR_Q_DEL_GROUPMEM structure.
2224 ********************************************************************/
2226 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2227 POLICY_HND *pol, uint32 rid)
2229 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2231 q_e->pol = *pol;
2232 q_e->rid = rid;
2235 /*******************************************************************
2236 reads or writes a structure.
2237 ********************************************************************/
2239 BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2240 prs_struct *ps, int depth)
2242 if (q_e == NULL)
2243 return False;
2245 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2246 depth++;
2248 if(!prs_align(ps))
2249 return False;
2251 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2252 return False;
2254 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2255 return False;
2257 return True;
2260 /*******************************************************************
2261 inits a SAMR_R_DEL_GROUPMEM structure.
2262 ********************************************************************/
2264 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2265 uint32 status)
2267 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2269 r_u->status = status;
2272 /*******************************************************************
2273 reads or writes a structure.
2274 ********************************************************************/
2276 BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2277 prs_struct *ps, int depth)
2279 if (r_u == NULL)
2280 return False;
2282 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2283 depth++;
2285 if(!prs_align(ps))
2286 return False;
2288 if(!prs_uint32("status", ps, depth, &r_u->status))
2289 return False;
2291 return True;
2294 /*******************************************************************
2295 inits a SAMR_Q_ADD_GROUPMEM structure.
2296 ********************************************************************/
2298 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2299 POLICY_HND *pol, uint32 rid)
2301 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2303 q_e->pol = *pol;
2304 q_e->rid = rid;
2305 q_e->unknown = 0x0005;
2308 /*******************************************************************
2309 reads or writes a structure.
2310 ********************************************************************/
2312 BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2313 prs_struct *ps, int depth)
2315 if (q_e == NULL)
2316 return False;
2318 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2319 depth++;
2321 if(!prs_align(ps))
2322 return False;
2324 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2325 return False;
2327 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2328 return False;
2329 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2330 return False;
2332 return True;
2335 /*******************************************************************
2336 inits a SAMR_R_ADD_GROUPMEM structure.
2337 ********************************************************************/
2339 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2340 uint32 status)
2342 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2344 r_u->status = status;
2347 /*******************************************************************
2348 reads or writes a structure.
2349 ********************************************************************/
2351 BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2352 prs_struct *ps, int depth)
2354 if (r_u == NULL)
2355 return False;
2357 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2358 depth++;
2360 if(!prs_align(ps))
2361 return False;
2363 if(!prs_uint32("status", ps, depth, &r_u->status))
2364 return False;
2366 return True;
2369 /*******************************************************************
2370 inits a SAMR_Q_SET_GROUPINFO structure.
2371 ********************************************************************/
2373 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2374 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2376 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2378 q_e->pol = *pol;
2379 q_e->ctr = ctr;
2382 /*******************************************************************
2383 reads or writes a structure.
2384 ********************************************************************/
2386 BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2387 prs_struct *ps, int depth)
2389 if (q_e == NULL)
2390 return False;
2392 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2393 depth++;
2395 if(!prs_align(ps))
2396 return False;
2398 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2399 return False;
2401 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2402 return False;
2404 return True;
2407 /*******************************************************************
2408 inits a SAMR_R_SET_GROUPINFO structure.
2409 ********************************************************************/
2411 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, uint32 status)
2413 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2415 r_u->status = status;
2418 /*******************************************************************
2419 reads or writes a structure.
2420 ********************************************************************/
2422 BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
2423 prs_struct *ps, int depth)
2425 if (r_u == NULL)
2426 return False;
2428 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2429 depth++;
2431 if(!prs_align(ps))
2432 return False;
2434 if(!prs_uint32("status", ps, depth, &r_u->status))
2435 return False;
2437 return True;
2440 /*******************************************************************
2441 inits a SAMR_Q_QUERY_GROUPINFO structure.
2442 ********************************************************************/
2444 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2445 POLICY_HND *pol, uint16 switch_level)
2447 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2449 q_e->pol = *pol;
2451 q_e->switch_level = switch_level;
2454 /*******************************************************************
2455 reads or writes a structure.
2456 ********************************************************************/
2458 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2459 prs_struct *ps, int depth)
2461 if (q_e == NULL)
2462 return False;
2464 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2465 depth++;
2467 if(!prs_align(ps))
2468 return False;
2470 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2471 return False;
2473 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2474 return False;
2476 return True;
2479 /*******************************************************************
2480 inits a SAMR_R_QUERY_GROUPINFO structure.
2481 ********************************************************************/
2483 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2484 GROUP_INFO_CTR * ctr, uint32 status)
2486 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2488 r_u->ptr = (status == 0x0 && ctr != NULL) ? 1 : 0;
2489 r_u->ctr = ctr;
2490 r_u->status = status;
2493 /*******************************************************************
2494 reads or writes a structure.
2495 ********************************************************************/
2497 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2498 prs_struct *ps, int depth)
2500 if (r_u == NULL)
2501 return False;
2503 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2504 depth++;
2506 if(!prs_align(ps))
2507 return False;
2509 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2510 return False;
2512 if (r_u->ptr != 0) {
2513 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2514 return False;
2517 if(!prs_align(ps))
2518 return False;
2519 if(!prs_uint32("status", ps, depth, &r_u->status))
2520 return False;
2522 return True;
2525 /*******************************************************************
2526 inits a SAMR_Q_QUERY_GROUPMEM structure.
2527 ********************************************************************/
2529 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2531 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2533 q_c->group_pol = *hnd;
2536 /*******************************************************************
2537 reads or writes a structure.
2538 ********************************************************************/
2540 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2541 prs_struct *ps, int depth)
2543 if (q_u == NULL)
2544 return False;
2546 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2547 depth++;
2549 if(!prs_align(ps))
2550 return False;
2552 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2553 return False;
2555 return True;
2558 /*******************************************************************
2559 inits a SAMR_R_QUERY_GROUPMEM structure.
2560 ********************************************************************/
2562 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2563 uint32 num_entries, uint32 *rid,
2564 uint32 *attr, uint32 status)
2566 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2568 if (status == 0x0) {
2569 r_u->ptr = 1;
2570 r_u->num_entries = num_entries;
2572 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2573 r_u->ptr_rids = rid != NULL ? 1 : 0;
2575 r_u->num_rids = num_entries;
2576 r_u->rid = rid;
2578 r_u->num_attrs = num_entries;
2579 r_u->attr = attr;
2580 } else {
2581 r_u->ptr = 0;
2582 r_u->num_entries = 0;
2585 r_u->status = status;
2588 /*******************************************************************
2589 reads or writes a structure.
2590 ********************************************************************/
2592 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2593 prs_struct *ps, int depth)
2595 uint32 i;
2597 if (r_u == NULL)
2598 return False;
2600 if (UNMARSHALLING(ps))
2601 ZERO_STRUCTP(r_u);
2603 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2604 depth++;
2606 if(!prs_align(ps))
2607 return False;
2609 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2610 return False;
2611 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2612 return False;
2614 if (r_u->ptr != 0) {
2615 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2616 return False;
2617 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2618 return False;
2620 if (r_u->ptr_rids != 0) {
2621 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2622 return False;
2623 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2624 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2625 if (r_u->rid == NULL)
2626 return False;
2629 for (i = 0; i < r_u->num_rids; i++) {
2630 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2631 return False;
2635 if (r_u->ptr_attrs != 0) {
2636 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2637 return False;
2639 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2640 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2641 if (r_u->attr == NULL)
2642 return False;
2645 for (i = 0; i < r_u->num_attrs; i++) {
2646 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2647 return False;
2652 if(!prs_uint32("status", ps, depth, &r_u->status))
2653 return False;
2655 return True;
2658 /*******************************************************************
2659 inits a SAMR_Q_QUERY_USERGROUPS structure.
2660 ********************************************************************/
2662 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2663 POLICY_HND *hnd)
2665 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2667 q_u->pol = *hnd;
2670 /*******************************************************************
2671 reads or writes a structure.
2672 ********************************************************************/
2674 BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2675 prs_struct *ps, int depth)
2677 if (q_u == NULL)
2678 return False;
2680 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2681 depth++;
2683 if(!prs_align(ps))
2684 return False;
2686 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2687 return False;
2689 return True;
2692 /*******************************************************************
2693 inits a SAMR_R_QUERY_USERGROUPS structure.
2694 ********************************************************************/
2696 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2697 uint32 num_gids, DOM_GID * gid,
2698 uint32 status)
2700 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2702 if (status == 0) {
2703 r_u->ptr_0 = 1;
2704 r_u->num_entries = num_gids;
2705 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2706 r_u->num_entries2 = num_gids;
2708 r_u->gid = gid;
2709 } else {
2710 r_u->ptr_0 = 0;
2711 r_u->num_entries = 0;
2712 r_u->ptr_1 = 0;
2713 r_u->gid = NULL;
2716 r_u->status = status;
2719 /*******************************************************************
2720 reads or writes a structure.
2721 ********************************************************************/
2723 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
2724 prs_struct *ps, int depth)
2726 uint32 i;
2727 if (gid == NULL)
2728 return False;
2730 prs_debug(ps, depth, desc, "samr_io_gids");
2731 depth++;
2733 if(!prs_align(ps))
2734 return False;
2736 if(!prs_uint32("num_gids", ps, depth, num_gids))
2737 return False;
2739 if ((*num_gids) != 0) {
2740 if (UNMARSHALLING(ps)) {
2741 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
2744 if ((*gid) == NULL) {
2745 return False;
2748 for (i = 0; i < (*num_gids); i++) {
2749 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
2750 return False;
2754 return True;
2757 /*******************************************************************
2758 reads or writes a structure.
2759 ********************************************************************/
2761 BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
2762 prs_struct *ps, int depth)
2764 if (r_u == NULL)
2765 return False;
2767 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
2768 depth++;
2770 if(!prs_align(ps))
2771 return False;
2773 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
2774 return False;
2776 if (r_u->ptr_0 != 0) {
2777 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2778 return False;
2779 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
2780 return False;
2782 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
2783 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
2784 return False;
2788 if(!prs_align(ps))
2789 return False;
2790 if(!prs_uint32("status", ps, depth, &r_u->status))
2791 return False;
2793 return True;
2796 /*******************************************************************
2797 inits a SAMR_Q_ENUM_DOMAINS structure.
2798 ********************************************************************/
2800 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
2801 POLICY_HND *pol,
2802 uint32 start_idx, uint32 size)
2804 DEBUG(5, ("init_samr_q_enum_domains\n"));
2806 q_e->pol = *pol;
2808 q_e->start_idx = start_idx;
2809 q_e->max_size = size;
2812 /*******************************************************************
2813 reads or writes a structure.
2814 ********************************************************************/
2816 BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
2817 prs_struct *ps, int depth)
2819 if (q_e == NULL)
2820 return False;
2822 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
2823 depth++;
2825 if(!prs_align(ps))
2826 return False;
2828 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2829 return False;
2831 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
2832 return False;
2833 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
2834 return False;
2836 return True;
2839 /*******************************************************************
2840 inits a SAMR_R_ENUM_DOMAINS structure.
2841 ********************************************************************/
2843 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
2844 uint32 next_idx, uint32 num_sam_entries)
2846 DEBUG(5, ("init_samr_r_enum_domains\n"));
2848 r_u->next_idx = next_idx;
2850 if (num_sam_entries != 0) {
2851 r_u->ptr_entries1 = 1;
2852 r_u->ptr_entries2 = 1;
2853 r_u->num_entries2 = num_sam_entries;
2854 r_u->num_entries3 = num_sam_entries;
2856 r_u->num_entries4 = num_sam_entries;
2857 } else {
2858 r_u->ptr_entries1 = 0;
2859 r_u->num_entries2 = num_sam_entries;
2860 r_u->ptr_entries2 = 1;
2864 /*******************************************************************
2865 reads or writes a structure.
2866 ********************************************************************/
2868 BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
2869 prs_struct *ps, int depth)
2871 uint32 i;
2873 if (r_u == NULL)
2874 return False;
2876 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
2877 depth++;
2879 if(!prs_align(ps))
2880 return False;
2882 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
2883 return False;
2884 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
2885 return False;
2887 if (r_u->ptr_entries1 != 0) {
2888 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2889 return False;
2890 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
2891 return False;
2892 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
2893 return False;
2895 if (UNMARSHALLING(ps)) {
2896 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
2897 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
2900 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
2901 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
2902 r_u->num_entries4 = 0;
2903 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
2904 return False;
2907 for (i = 0; i < r_u->num_entries2; i++) {
2908 fstring tmp;
2909 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
2910 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
2911 return False;
2914 for (i = 0; i < r_u->num_entries2; i++) {
2915 fstring tmp;
2916 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
2917 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
2918 r_u->sam[i].hdr_name.buffer, ps,
2919 depth))
2920 return False;
2925 if(!prs_align(ps))
2926 return False;
2927 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
2928 return False;
2929 if(!prs_uint32("status", ps, depth, &r_u->status))
2930 return False;
2932 return True;
2935 /*******************************************************************
2936 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
2937 ********************************************************************/
2939 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
2940 POLICY_HND *pol,
2941 uint32 start_idx, uint32 size)
2943 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
2945 q_e->pol = *pol;
2947 q_e->start_idx = start_idx;
2948 q_e->max_size = size;
2951 /*******************************************************************
2952 reads or writes a structure.
2953 ********************************************************************/
2955 BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
2956 prs_struct *ps, int depth)
2958 if (q_e == NULL)
2959 return False;
2961 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
2962 depth++;
2964 if(!prs_align(ps))
2965 return False;
2967 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
2968 return False;
2970 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
2971 return False;
2972 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
2973 return False;
2975 return True;
2978 /*******************************************************************
2979 inits a SAMR_R_ENUM_DOM_GROUPS structure.
2980 ********************************************************************/
2982 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
2983 uint32 next_idx, uint32 num_sam_entries)
2985 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
2987 r_u->next_idx = next_idx;
2989 if (num_sam_entries != 0) {
2990 r_u->ptr_entries1 = 1;
2991 r_u->ptr_entries2 = 1;
2992 r_u->num_entries2 = num_sam_entries;
2993 r_u->num_entries3 = num_sam_entries;
2995 r_u->num_entries4 = num_sam_entries;
2996 } else {
2997 r_u->ptr_entries1 = 0;
2998 r_u->num_entries2 = num_sam_entries;
2999 r_u->ptr_entries2 = 1;
3003 /*******************************************************************
3004 reads or writes a structure.
3005 ********************************************************************/
3007 BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3008 prs_struct *ps, int depth)
3010 uint32 i;
3012 if (r_u == NULL)
3013 return False;
3015 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3016 depth++;
3018 if(!prs_align(ps))
3019 return False;
3021 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3022 return False;
3023 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3024 return False;
3026 if (r_u->ptr_entries1 != 0) {
3027 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3028 return False;
3029 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3030 return False;
3031 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3032 return False;
3034 if (UNMARSHALLING(ps)) {
3035 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3036 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3039 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3040 DEBUG(0,
3041 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3042 r_u->num_entries4 = 0;
3043 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3044 return False;
3047 for (i = 0; i < r_u->num_entries2; i++) {
3048 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3049 return False;
3052 for (i = 0; i < r_u->num_entries2; i++) {
3053 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3054 r_u->sam[i].hdr_name.buffer, ps, depth))
3055 return False;
3059 if(!prs_align(ps))
3060 return False;
3061 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3062 return False;
3063 if(!prs_uint32("status", ps, depth, &r_u->status))
3064 return False;
3066 return True;
3069 /*******************************************************************
3070 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3071 ********************************************************************/
3073 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3074 POLICY_HND *pol, uint32 start_idx,
3075 uint32 size)
3077 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3079 q_e->pol = *pol;
3081 q_e->start_idx = start_idx;
3082 q_e->max_size = size;
3086 /*******************************************************************
3087 reads or writes a structure.
3088 ********************************************************************/
3090 BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3091 prs_struct *ps, int depth)
3093 if (q_e == NULL)
3094 return False;
3096 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3097 depth++;
3099 if(!prs_align(ps))
3100 return False;
3102 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3103 return False;
3105 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3106 return False;
3107 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3108 return False;
3110 return True;
3113 /*******************************************************************
3114 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3115 ********************************************************************/
3117 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3119 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3121 r_u->next_idx = next_idx;
3123 if (num_sam_entries != 0) {
3124 r_u->ptr_entries1 = 1;
3125 r_u->ptr_entries2 = 1;
3126 r_u->num_entries2 = num_sam_entries;
3127 r_u->num_entries3 = num_sam_entries;
3129 r_u->num_entries4 = num_sam_entries;
3130 } else {
3131 r_u->ptr_entries1 = 0;
3132 r_u->num_entries2 = num_sam_entries;
3133 r_u->ptr_entries2 = 1;
3137 /*******************************************************************
3138 reads or writes a structure.
3139 ********************************************************************/
3141 BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3142 prs_struct *ps, int depth)
3144 uint32 i;
3146 if (r_u == NULL)
3147 return False;
3149 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3150 depth++;
3152 if(!prs_align(ps))
3153 return False;
3155 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3156 return False;
3157 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3158 return False;
3160 if (r_u->ptr_entries1 != 0) {
3161 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3162 return False;
3163 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3164 return False;
3165 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3166 return False;
3168 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3169 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3170 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3173 if (r_u->num_entries2 != 0 &&
3174 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3175 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3176 r_u->num_entries4 = 0;
3177 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3178 return False;
3181 for (i = 0; i < r_u->num_entries2; i++) {
3182 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3183 return False;
3186 for (i = 0; i < r_u->num_entries2; i++) {
3187 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3188 r_u->sam[i].hdr_name.buffer, ps,
3189 depth))
3190 return False;
3194 if(!prs_align(ps))
3195 return False;
3196 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3197 return False;
3198 if(!prs_uint32("status", ps, depth, &r_u->status))
3199 return False;
3201 return True;
3204 /*******************************************************************
3205 inits a ALIAS_INFO3 structure.
3206 ********************************************************************/
3208 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3210 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3212 DEBUG(5, ("init_samr_alias_info3\n"));
3214 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3215 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3218 /*******************************************************************
3219 reads or writes a structure.
3220 ********************************************************************/
3222 BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
3223 prs_struct *ps, int depth)
3225 if (al3 == NULL)
3226 return False;
3228 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3229 depth++;
3231 if(!prs_align(ps))
3232 return False;
3234 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3235 return False;
3236 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3237 al3->hdr_acct_desc.buffer, ps, depth))
3238 return False;
3240 return True;
3243 /*******************************************************************
3244 reads or writes a structure.
3245 ********************************************************************/
3247 BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
3248 prs_struct *ps, int depth)
3250 if (ctr == NULL)
3251 return False;
3253 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3254 depth++;
3256 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3257 return False;
3258 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3259 return False;
3261 switch (ctr->switch_value1) {
3262 case 3:
3263 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3264 return False;
3265 break;
3266 default:
3267 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3268 break;
3271 return True;
3274 /*******************************************************************
3275 inits a SAMR_Q_QUERY_ALIASINFO structure.
3276 ********************************************************************/
3278 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3279 POLICY_HND *pol, uint16 switch_level)
3281 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3283 q_e->pol = *pol;
3284 q_e->switch_level = switch_level;
3287 /*******************************************************************
3288 reads or writes a structure.
3289 ********************************************************************/
3291 BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3292 prs_struct *ps, int depth)
3294 if (q_e == NULL)
3295 return False;
3297 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3298 depth++;
3300 if(!prs_align(ps))
3301 return False;
3303 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3304 return False;
3306 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3307 return False;
3309 return True;
3312 /*******************************************************************
3313 inits a SAMR_R_QUERY_ALIASINFO structure.
3314 ********************************************************************/
3316 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3317 ALIAS_INFO_CTR * ctr, uint32 status)
3319 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3321 r_u->ptr = (status == 0x0 && ctr != NULL) ? 1 : 0;
3322 r_u->ctr = *ctr;
3323 r_u->status = status;
3326 /*******************************************************************
3327 reads or writes a structure.
3328 ********************************************************************/
3330 BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3331 prs_struct *ps, int depth)
3333 if (r_u == NULL)
3334 return False;
3336 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3337 depth++;
3339 if(!prs_align(ps))
3340 return False;
3342 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3343 return False;
3345 if (r_u->ptr != 0) {
3346 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3347 return False;
3350 if(!prs_align(ps))
3351 return False;
3352 if(!prs_uint32("status", ps, depth, &r_u->status))
3353 return False;
3355 return True;
3358 /*******************************************************************
3359 inits a SAMR_Q_SET_ALIASINFO structure.
3360 ********************************************************************/
3362 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3363 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3365 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3367 q_u->alias_pol = *hnd;
3368 q_u->ctr = *ctr;
3371 /*******************************************************************
3372 reads or writes a structure.
3373 ********************************************************************/
3375 BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3376 prs_struct *ps, int depth)
3378 if (q_u == NULL)
3379 return False;
3381 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3382 depth++;
3384 if(!prs_align(ps))
3385 return False;
3387 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3388 return False;
3389 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3390 return False;
3392 return True;
3395 /*******************************************************************
3396 reads or writes a structure.
3397 ********************************************************************/
3399 BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
3400 prs_struct *ps, int depth)
3402 if (r_u == NULL)
3403 return False;
3405 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3406 depth++;
3408 if(!prs_align(ps))
3409 return False;
3410 if(!prs_uint32("status", ps, depth, &r_u->status))
3411 return False;
3413 return True;
3416 /*******************************************************************
3417 inits a SAMR_Q_QUERY_USERALIASES structure.
3418 ********************************************************************/
3420 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3421 POLICY_HND *hnd,
3422 uint32 num_sids,
3423 uint32 *ptr_sid, DOM_SID2 * sid)
3425 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3427 q_u->pol = *hnd;
3429 q_u->num_sids1 = num_sids;
3430 q_u->ptr = 1;
3431 q_u->num_sids2 = num_sids;
3433 q_u->ptr_sid = ptr_sid;
3434 q_u->sid = sid;
3437 /*******************************************************************
3438 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3439 ********************************************************************/
3441 BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3442 prs_struct *ps, int depth)
3444 fstring tmp;
3445 uint32 i;
3447 if (q_u == NULL)
3448 return False;
3450 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3451 depth++;
3453 if(!prs_align(ps))
3454 return False;
3456 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3457 return False;
3459 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3460 return False;
3461 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3462 return False;
3464 if (q_u->ptr==0)
3465 return True;
3467 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3468 return False;
3470 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3471 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3472 if (q_u->ptr_sid == NULL)
3473 return False;
3475 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3476 if (q_u->sid == NULL)
3477 return False;
3480 for (i = 0; i < q_u->num_sids2; i++) {
3481 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3482 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3483 return False;
3486 for (i = 0; i < q_u->num_sids2; i++) {
3487 if (q_u->ptr_sid[i] != 0) {
3488 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3489 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3490 return False;
3494 return True;
3497 /*******************************************************************
3498 inits a SAMR_R_QUERY_USERALIASES structure.
3499 ********************************************************************/
3501 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3502 uint32 num_rids, uint32 *rid,
3503 uint32 status)
3505 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3507 if (status == 0x0) {
3508 r_u->num_entries = num_rids;
3509 r_u->ptr = 1;
3510 r_u->num_entries2 = num_rids;
3512 r_u->rid = rid;
3513 } else {
3514 r_u->num_entries = 0;
3515 r_u->ptr = 0;
3516 r_u->num_entries2 = 0;
3519 r_u->status = status;
3522 /*******************************************************************
3523 reads or writes a structure.
3524 ********************************************************************/
3526 BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
3527 prs_struct *ps, int depth)
3529 fstring tmp;
3530 uint32 i;
3531 if (rid == NULL)
3532 return False;
3534 prs_debug(ps, depth, desc, "samr_io_rids");
3535 depth++;
3537 if(!prs_align(ps))
3538 return False;
3540 if(!prs_uint32("num_rids", ps, depth, num_rids))
3541 return False;
3543 if ((*num_rids) != 0) {
3544 if (UNMARSHALLING(ps)) {
3545 /* reading */
3546 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3548 if ((*rid) == NULL)
3549 return False;
3551 for (i = 0; i < (*num_rids); i++) {
3552 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3553 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3554 return False;
3558 return True;
3561 /*******************************************************************
3562 reads or writes a structure.
3563 ********************************************************************/
3565 BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3566 prs_struct *ps, int depth)
3568 if (r_u == NULL)
3569 return False;
3571 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3572 depth++;
3574 if(!prs_align(ps))
3575 return False;
3577 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3578 return False;
3579 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3580 return False;
3582 if (r_u->ptr != 0) {
3583 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3584 return False;
3587 if(!prs_align(ps))
3588 return False;
3589 if(!prs_uint32("status", ps, depth, &r_u->status))
3590 return False;
3592 return True;
3595 /*******************************************************************
3596 inits a SAMR_Q_OPEN_ALIAS structure.
3597 ********************************************************************/
3599 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3600 uint32 access_mask, uint32 rid)
3602 DEBUG(5, ("init_samr_q_open_alias\n"));
3604 q_u->dom_pol = *pol;
3605 q_u->access_mask = access_mask;
3606 q_u->rid_alias = rid;
3609 /*******************************************************************
3610 reads or writes a structure.
3611 ********************************************************************/
3613 BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3614 prs_struct *ps, int depth)
3616 if (q_u == NULL)
3617 return False;
3619 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3620 depth++;
3622 if(!prs_align(ps))
3623 return False;
3625 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3626 return False;
3628 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3629 return False;
3630 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3631 return False;
3633 return True;
3636 /*******************************************************************
3637 reads or writes a structure.
3638 ********************************************************************/
3640 BOOL samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS * r_u,
3641 prs_struct *ps, int depth)
3643 if (r_u == NULL)
3644 return False;
3646 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3647 depth++;
3649 if(!prs_align(ps))
3650 return False;
3652 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3653 return False;
3655 if(!prs_uint32("status", ps, depth, &r_u->status))
3656 return False;
3658 return True;
3661 /*******************************************************************
3662 inits a SAMR_Q_LOOKUP_RIDS structure.
3663 ********************************************************************/
3665 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3666 POLICY_HND *pol, uint32 flags,
3667 uint32 num_rids, uint32 *rid)
3669 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3671 q_u->pol = *pol;
3673 q_u->num_rids1 = num_rids;
3674 q_u->flags = flags;
3675 q_u->ptr = 0;
3676 q_u->num_rids2 = num_rids;
3677 q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0]));
3678 if (q_u->rid == NULL) {
3679 q_u->num_rids1 = 0;
3680 q_u->num_rids2 = 0;
3681 } else {
3682 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
3686 /*******************************************************************
3687 reads or writes a structure.
3688 ********************************************************************/
3690 BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
3691 prs_struct *ps, int depth)
3693 uint32 i;
3694 fstring tmp;
3696 if (q_u == NULL)
3697 return False;
3699 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
3700 depth++;
3702 if (UNMARSHALLING(ps))
3703 ZERO_STRUCTP(q_u);
3705 if(!prs_align(ps))
3706 return False;
3708 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3709 return False;
3711 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
3712 return False;
3713 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
3714 return False;
3715 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3716 return False;
3717 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
3718 return False;
3720 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
3721 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
3722 if (q_u->rid == NULL)
3723 return False;
3726 for (i = 0; i < q_u->num_rids2; i++) {
3727 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
3728 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
3729 return False;
3732 return True;
3735 /*******************************************************************
3736 inits a SAMR_R_LOOKUP_RIDS structure.
3737 ********************************************************************/
3739 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
3740 uint32 num_names, UNIHDR * hdr_name,
3741 UNISTR2 *uni_name, uint32 *type)
3743 DEBUG(5, ("init_samr_r_lookup_rids\n"));
3745 r_u->hdr_name = NULL;
3746 r_u->uni_name = NULL;
3747 r_u->type = NULL;
3749 if (num_names != 0) {
3750 r_u->num_names1 = num_names;
3751 r_u->ptr_names = 1;
3752 r_u->num_names2 = num_names;
3754 r_u->num_types1 = num_names;
3755 r_u->ptr_types = 1;
3756 r_u->num_types2 = num_names;
3758 r_u->hdr_name = hdr_name;
3759 r_u->uni_name = uni_name;
3760 r_u->type = type;
3761 } else {
3762 r_u->num_names1 = num_names;
3763 r_u->ptr_names = 0;
3764 r_u->num_names2 = num_names;
3766 r_u->num_types1 = num_names;
3767 r_u->ptr_types = 0;
3768 r_u->num_types2 = num_names;
3772 /*******************************************************************
3773 reads or writes a structure.
3774 ********************************************************************/
3776 BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
3777 prs_struct *ps, int depth)
3779 uint32 i;
3780 fstring tmp;
3781 if (r_u == NULL)
3782 return False;
3784 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
3785 depth++;
3787 if(!prs_align(ps))
3788 return False;
3790 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
3791 return False;
3792 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
3793 return False;
3795 if (r_u->ptr_names != 0) {
3797 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
3798 return False;
3801 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
3802 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
3803 if (r_u->hdr_name == NULL)
3804 return False;
3806 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
3807 if (r_u->uni_name == NULL)
3808 return False;
3811 for (i = 0; i < r_u->num_names2; i++) {
3812 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
3813 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
3814 return False;
3816 for (i = 0; i < r_u->num_names2; i++) {
3817 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
3818 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
3819 return False;
3824 if(!prs_align(ps))
3825 return False;
3826 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
3827 return False;
3828 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
3829 return False;
3831 if (r_u->ptr_types != 0) {
3833 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
3834 return False;
3836 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
3837 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
3838 if (r_u->type == NULL)
3839 return False;
3842 for (i = 0; i < r_u->num_types2; i++) {
3843 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
3844 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
3845 return False;
3849 if(!prs_uint32("status", ps, depth, &r_u->status))
3850 return False;
3852 return True;
3855 /*******************************************************************
3856 inits a SAMR_Q_OPEN_ALIAS structure.
3857 ********************************************************************/
3859 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
3861 DEBUG(5, ("init_samr_q_delete_alias\n"));
3863 q_u->alias_pol = *hnd;
3866 /*******************************************************************
3867 reads or writes a structure.
3868 ********************************************************************/
3870 BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
3871 prs_struct *ps, int depth)
3873 if (q_u == NULL)
3874 return False;
3876 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
3877 depth++;
3879 if(!prs_align(ps))
3880 return False;
3882 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3883 return False;
3885 return True;
3888 /*******************************************************************
3889 reads or writes a structure.
3890 ********************************************************************/
3892 BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
3893 prs_struct *ps, int depth)
3895 if (r_u == NULL)
3896 return False;
3898 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
3899 depth++;
3901 if(!prs_align(ps))
3902 return False;
3904 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3905 return False;
3906 if(!prs_uint32("status", ps, depth, &r_u->status))
3907 return False;
3909 return True;
3912 /*******************************************************************
3913 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
3914 ********************************************************************/
3916 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
3917 POLICY_HND *hnd, char *acct_desc)
3919 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3921 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
3923 q_u->dom_pol = *hnd;
3925 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
3926 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
3928 q_u->access_mask = 0x001f000f;
3931 /*******************************************************************
3932 reads or writes a structure.
3933 ********************************************************************/
3935 BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
3936 prs_struct *ps, int depth)
3938 if (q_u == NULL)
3939 return False;
3941 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
3942 depth++;
3944 if(!prs_align(ps))
3945 return False;
3947 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
3948 return False;
3950 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
3951 return False;
3952 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
3953 q_u->hdr_acct_desc.buffer, ps, depth))
3954 return False;
3956 if(!prs_align(ps))
3957 return False;
3958 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3959 return False;
3961 return True;
3964 /*******************************************************************
3965 reads or writes a structure.
3966 ********************************************************************/
3968 BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
3969 prs_struct *ps, int depth)
3971 if (r_u == NULL)
3972 return False;
3974 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
3975 depth++;
3977 if(!prs_align(ps))
3978 return False;
3980 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
3981 return False;
3983 if(!prs_uint32("rid", ps, depth, &r_u->rid))
3984 return False;
3986 if(!prs_uint32("status", ps, depth, &r_u->status))
3987 return False;
3989 return True;
3992 /*******************************************************************
3993 inits a SAMR_Q_ADD_ALIASMEM structure.
3994 ********************************************************************/
3996 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
3997 DOM_SID *sid)
3999 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4001 q_u->alias_pol = *hnd;
4002 init_dom_sid2(&q_u->sid, sid);
4005 /*******************************************************************
4006 reads or writes a structure.
4007 ********************************************************************/
4009 BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4010 prs_struct *ps, int depth)
4012 if (q_u == NULL)
4013 return False;
4015 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4016 depth++;
4018 if(!prs_align(ps))
4019 return False;
4021 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4022 return False;
4023 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4024 return False;
4026 return True;
4029 /*******************************************************************
4030 reads or writes a structure.
4031 ********************************************************************/
4033 BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4034 prs_struct *ps, int depth)
4036 if (r_u == NULL)
4037 return False;
4039 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4040 depth++;
4042 if(!prs_align(ps))
4043 return False;
4045 if(!prs_uint32("status", ps, depth, &r_u->status))
4046 return False;
4048 return True;
4051 /*******************************************************************
4052 inits a SAMR_Q_DEL_ALIASMEM structure.
4053 ********************************************************************/
4055 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4056 DOM_SID *sid)
4058 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4060 q_u->alias_pol = *hnd;
4061 init_dom_sid2(&q_u->sid, sid);
4064 /*******************************************************************
4065 reads or writes a structure.
4066 ********************************************************************/
4068 BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4069 prs_struct *ps, int depth)
4071 if (q_u == NULL)
4072 return False;
4074 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4075 depth++;
4077 if(!prs_align(ps))
4078 return False;
4080 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4081 return False;
4082 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4083 return False;
4085 return True;
4088 /*******************************************************************
4089 reads or writes a structure.
4090 ********************************************************************/
4092 BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4093 prs_struct *ps, int depth)
4095 if (r_u == NULL)
4096 return False;
4098 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4099 depth++;
4101 if(!prs_align(ps))
4102 return False;
4104 if(!prs_uint32("status", ps, depth, &r_u->status))
4105 return False;
4107 return True;
4110 /*******************************************************************
4111 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4112 ********************************************************************/
4114 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4115 POLICY_HND *hnd)
4117 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4119 q_c->alias_pol = *hnd;
4122 /*******************************************************************
4123 reads or writes a structure.
4124 ********************************************************************/
4126 BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4127 prs_struct *ps, int depth)
4129 if (q_u == NULL)
4130 return False;
4132 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4133 depth++;
4135 if(!prs_align(ps))
4136 return False;
4138 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4139 return False;
4141 return True;
4144 /*******************************************************************
4145 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4146 ********************************************************************/
4148 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4149 uint32 status)
4151 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4153 r_u->status = status;
4156 /*******************************************************************
4157 reads or writes a structure.
4158 ********************************************************************/
4160 BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4161 prs_struct *ps, int depth)
4163 if (r_u == NULL)
4164 return False;
4166 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4167 depth++;
4169 if(!prs_align(ps))
4170 return False;
4172 if(!prs_uint32("status", ps, depth, &r_u->status))
4173 return False;
4175 return True;
4178 /*******************************************************************
4179 inits a SAMR_Q_QUERY_ALIASMEM structure.
4180 ********************************************************************/
4182 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4183 POLICY_HND *hnd)
4185 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4187 q_c->alias_pol = *hnd;
4190 /*******************************************************************
4191 reads or writes a structure.
4192 ********************************************************************/
4194 BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4195 prs_struct *ps, int depth)
4197 if (q_u == NULL)
4198 return False;
4200 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4201 depth++;
4203 if(!prs_align(ps))
4204 return False;
4206 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4207 return False;
4209 return True;
4212 /*******************************************************************
4213 inits a SAMR_R_QUERY_ALIASMEM structure.
4214 ********************************************************************/
4216 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4217 uint32 num_sids, DOM_SID2 * sid,
4218 uint32 status)
4220 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4222 if (status == 0) {
4223 r_u->num_sids = num_sids;
4224 r_u->ptr = (num_sids != 0) ? 1 : 0;
4225 r_u->num_sids1 = num_sids;
4227 r_u->sid = sid;
4228 } else {
4229 r_u->ptr = 0;
4230 r_u->num_sids = 0;
4233 r_u->status = status;
4236 /*******************************************************************
4237 reads or writes a structure.
4238 ********************************************************************/
4240 BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4241 prs_struct *ps, int depth)
4243 uint32 i;
4244 uint32 ptr_sid[MAX_LOOKUP_SIDS];
4246 if (r_u == NULL)
4247 return False;
4249 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4250 depth++;
4252 if(!prs_align(ps))
4253 return False;
4255 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4256 return False;
4257 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4258 return False;
4260 if (r_u->ptr != 0) {
4261 SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids);
4263 if (r_u->num_sids != 0) {
4264 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4265 return False;
4267 for (i = 0; i < r_u->num_sids1; i++) {
4268 ptr_sid[i] = 1;
4269 if(!prs_uint32("", ps, depth, &ptr_sid[i]))
4270 return False;
4273 for (i = 0; i < r_u->num_sids1; i++) {
4274 if (ptr_sid[i] != 0) {
4275 if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth))
4276 return False;
4282 if(!prs_align(ps))
4283 return False;
4284 if(!prs_uint32("status", ps, depth, &r_u->status))
4285 return False;
4287 return True;
4290 /*******************************************************************
4291 inits a SAMR_Q_LOOKUP_NAMES structure.
4292 ********************************************************************/
4294 void init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4295 POLICY_HND *pol, uint32 flags,
4296 uint32 num_names, char **name)
4298 uint32 i;
4300 DEBUG(5, ("init_samr_q_lookup_names\n"));
4302 q_u->pol = *pol;
4304 q_u->num_names1 = num_names;
4305 q_u->flags = flags;
4306 q_u->ptr = 0;
4307 q_u->num_names2 = num_names;
4309 q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR));
4310 q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2));
4312 for (i = 0; i < num_names; i++) {
4313 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4314 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4315 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4319 /*******************************************************************
4320 reads or writes a structure.
4321 ********************************************************************/
4323 BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4324 prs_struct *ps, int depth)
4326 uint32 i;
4328 if (q_u == NULL)
4329 return False;
4331 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4332 depth++;
4334 if (UNMARSHALLING(ps))
4335 ZERO_STRUCTP(q_u);
4337 if(!prs_align(ps))
4338 return False;
4340 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4341 return False;
4343 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4344 return False;
4345 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4346 return False;
4347 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4348 return False;
4349 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4350 return False;
4352 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4353 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4354 q_u->num_names2);
4355 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4356 q_u->num_names2);
4357 if (!q_u->hdr_name || q_u->uni_name)
4358 return False;
4361 for (i = 0; i < q_u->num_names2; i++) {
4362 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4363 return False;
4366 for (i = 0; i < q_u->num_names2; i++) {
4367 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4368 return False;
4371 return True;
4374 /*******************************************************************
4375 inits a SAMR_R_LOOKUP_NAMES structure.
4376 ********************************************************************/
4378 void init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4379 uint32 num_rids,
4380 uint32 *rid, uint32 *type,
4381 uint32 status)
4383 DEBUG(5, ("init_samr_r_lookup_names\n"));
4385 if ((status == 0) && (num_rids != 0)) {
4386 uint32 i;
4388 r_u->num_types1 = num_rids;
4389 r_u->ptr_types = 1;
4390 r_u->num_types2 = num_rids;
4392 r_u->num_rids1 = num_rids;
4393 r_u->ptr_rids = 1;
4394 r_u->num_rids2 = num_rids;
4396 r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids);
4397 r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids);
4399 if (!r_u->rids || !r_u->types)
4400 goto empty;
4402 for (i = 0; i < num_rids; i++) {
4403 r_u->rids[i] = rid[i];
4404 r_u->types[i] = type[i];
4406 } else {
4408 empty:
4409 r_u->num_types1 = 0;
4410 r_u->ptr_types = 0;
4411 r_u->num_types2 = 0;
4413 r_u->num_rids1 = 0;
4414 r_u->ptr_rids = 0;
4415 r_u->num_rids2 = 0;
4417 r_u->rids = NULL;
4418 r_u->types = NULL;
4421 r_u->status = status;
4424 /*******************************************************************
4425 reads or writes a structure.
4426 ********************************************************************/
4428 BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4429 prs_struct *ps, int depth)
4431 uint32 i;
4432 fstring tmp;
4434 if (r_u == NULL)
4435 return False;
4437 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4438 depth++;
4440 if (UNMARSHALLING(ps))
4441 ZERO_STRUCTP(r_u);
4443 if(!prs_align(ps))
4444 return False;
4446 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4447 return False;
4448 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4449 return False;
4451 if (r_u->ptr_rids != 0) {
4452 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4453 return False;
4455 if (r_u->num_rids2 != r_u->num_rids1) {
4456 /* RPC fault */
4457 return False;
4460 if (UNMARSHALLING(ps))
4461 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4463 if (!r_u->rids) {
4464 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4465 return False;
4468 for (i = 0; i < r_u->num_rids2; i++) {
4469 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4470 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4471 return False;
4475 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4476 return False;
4477 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4478 return False;
4480 if (r_u->ptr_types != 0) {
4481 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4482 return False;
4484 if (r_u->num_types2 != r_u->num_types1) {
4485 /* RPC fault */
4486 return False;
4489 if (UNMARSHALLING(ps))
4490 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4492 if (!r_u->types) {
4493 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4494 return False;
4497 for (i = 0; i < r_u->num_types2; i++) {
4498 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4499 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4500 return False;
4504 if(!prs_uint32("status", ps, depth, &r_u->status))
4505 return False;
4507 return True;
4510 /*******************************************************************
4511 inits a SAMR_Q_DELETE_DOM_USER structure.
4512 ********************************************************************/
4514 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4515 POLICY_HND *hnd)
4517 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4519 q_c->user_pol = *hnd;
4522 /*******************************************************************
4523 reads or writes a structure.
4524 ********************************************************************/
4526 BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4527 prs_struct *ps, int depth)
4529 if (q_u == NULL)
4530 return False;
4532 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4533 depth++;
4535 if(!prs_align(ps))
4536 return False;
4538 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4539 return False;
4541 return True;
4544 /*******************************************************************
4545 reads or writes a structure.
4546 ********************************************************************/
4548 BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4549 prs_struct *ps, int depth)
4551 if (r_u == NULL)
4552 return False;
4554 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4555 depth++;
4557 if(!prs_align(ps))
4558 return False;
4560 if(!prs_uint32("status", ps, depth, &r_u->status))
4561 return False;
4563 return True;
4566 /*******************************************************************
4567 reads or writes a structure.
4568 ********************************************************************/
4570 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4571 POLICY_HND *pol,
4572 uint32 access_mask, uint32 rid)
4574 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4576 q_u->domain_pol = *pol;
4577 q_u->access_mask = access_mask;
4578 q_u->user_rid = rid;
4581 /*******************************************************************
4582 reads or writes a structure.
4583 ********************************************************************/
4585 BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
4586 prs_struct *ps, int depth)
4588 if (q_u == NULL)
4589 return False;
4591 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4592 depth++;
4594 if(!prs_align(ps))
4595 return False;
4597 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4598 return False;
4600 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4601 return False;
4602 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4603 return False;
4605 return True;
4608 /*******************************************************************
4609 reads or writes a structure.
4610 ********************************************************************/
4612 BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
4613 prs_struct *ps, int depth)
4615 if (r_u == NULL)
4616 return False;
4618 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4619 depth++;
4621 if(!prs_align(ps))
4622 return False;
4624 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4625 return False;
4627 if(!prs_uint32("status", ps, depth, &r_u->status))
4628 return False;
4630 return True;
4634 /*******************************************************************
4635 reads or writes a structure.
4636 ********************************************************************/
4638 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4639 POLICY_HND *pol,
4640 char *name,
4641 uint32 acb_info, uint32 access_mask)
4643 int len_name;
4644 len_name = strlen(name);
4646 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4648 q_u->domain_pol = *pol;
4650 init_uni_hdr(&q_u->hdr_name, len_name);
4651 init_unistr2(&q_u->uni_name, name, len_name);
4653 q_u->acb_info = acb_info;
4654 q_u->access_mask = access_mask;
4657 /*******************************************************************
4658 reads or writes a structure.
4659 ********************************************************************/
4661 BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
4662 prs_struct *ps, int depth)
4664 if (q_u == NULL)
4665 return False;
4667 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4668 depth++;
4670 if(!prs_align(ps))
4671 return False;
4673 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4674 return False;
4676 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
4677 return False;
4678 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
4679 return False;
4681 if(!prs_align(ps))
4682 return False;
4683 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
4684 return False;
4685 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4686 return False;
4688 return True;
4691 /*******************************************************************
4692 reads or writes a structure.
4693 ********************************************************************/
4695 BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
4696 prs_struct *ps, int depth)
4698 if (r_u == NULL)
4699 return False;
4701 prs_debug(ps, depth, desc, "samr_io_r_create_user");
4702 depth++;
4704 if(!prs_align(ps))
4705 return False;
4707 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4708 return False;
4710 if(!prs_uint32("unknown_0", ps, depth, &r_u->unknown_0))
4711 return False;
4712 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
4713 return False;
4714 if(!prs_uint32("status", ps, depth, &r_u->status))
4715 return False;
4717 return True;
4720 /*******************************************************************
4721 inits a SAMR_Q_QUERY_USERINFO structure.
4722 ********************************************************************/
4724 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
4725 POLICY_HND *hnd, uint16 switch_value)
4727 DEBUG(5, ("init_samr_q_query_userinfo\n"));
4729 q_u->pol = *hnd;
4730 q_u->switch_value = switch_value;
4733 /*******************************************************************
4734 reads or writes a structure.
4735 ********************************************************************/
4737 BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
4738 prs_struct *ps, int depth)
4740 if (q_u == NULL)
4741 return False;
4743 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
4744 depth++;
4746 if(!prs_align(ps))
4747 return False;
4749 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4750 return False;
4752 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
4753 return False;
4755 return True;
4758 /*******************************************************************
4759 reads or writes a LOGON_HRS structure.
4760 ********************************************************************/
4762 static BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs,
4763 prs_struct *ps, int depth)
4765 if (hrs == NULL)
4766 return False;
4768 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
4769 depth++;
4771 if(!prs_align(ps))
4772 return False;
4774 if(!prs_uint32("len ", ps, depth, &hrs->len))
4775 return False;
4777 if (hrs->len > sizeof(hrs->hours)) {
4778 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
4779 hrs->len = sizeof(hrs->hours);
4782 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
4783 return False;
4785 return True;
4788 /*******************************************************************
4789 inits a SAM_USER_INFO_12 structure.
4790 ********************************************************************/
4792 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
4793 uint8 lm_pwd[16], uint8 nt_pwd[16])
4795 DEBUG(5, ("init_sam_user_info12\n"));
4797 usr->lm_pwd_active =
4798 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
4799 usr->nt_pwd_active =
4800 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
4803 /*******************************************************************
4804 reads or writes a structure.
4805 ********************************************************************/
4807 static BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
4808 prs_struct *ps, int depth)
4810 if (u == NULL)
4811 return False;
4813 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
4814 depth++;
4816 if(!prs_align(ps))
4817 return False;
4819 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
4820 return False;
4821 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
4822 return False;
4824 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
4825 return False;
4826 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
4827 return False;
4829 return True;
4832 /*******************************************************************
4833 inits a SAM_USER_INFO_10 structure.
4834 ********************************************************************/
4836 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
4838 DEBUG(5, ("init_sam_user_info10\n"));
4840 usr->acb_info = acb_info;
4843 /*******************************************************************
4844 reads or writes a structure.
4845 ********************************************************************/
4847 static BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
4848 prs_struct *ps, int depth)
4850 if (usr == NULL)
4851 return False;
4853 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
4854 depth++;
4856 if(!prs_align(ps))
4857 return False;
4859 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
4860 return False;
4862 return True;
4865 /*******************************************************************
4866 inits a SAM_USER_INFO_11 structure.
4867 ********************************************************************/
4869 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
4870 NTTIME * expiry,
4871 char *mach_acct,
4872 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
4874 int len_mach_acct;
4876 DEBUG(5, ("init_sam_user_info11\n"));
4878 len_mach_acct = strlen(mach_acct);
4880 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
4881 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
4883 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
4884 usr->padding_2 = 0; /* 0 - padding 4 bytes */
4886 usr->ptr_1 = 1; /* pointer */
4887 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
4888 usr->padding_4 = 0; /* 0 - padding 4 bytes */
4890 usr->ptr_2 = 1; /* pointer */
4891 usr->padding_5 = 0; /* 0 - padding 4 bytes */
4893 usr->ptr_3 = 1; /* pointer */
4894 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
4896 usr->rid_user = rid_user;
4897 usr->rid_group = rid_group;
4899 usr->acct_ctrl = acct_ctrl;
4900 usr->unknown_3 = 0x0000;
4902 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
4903 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
4905 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
4906 usr->padding_8 = 0; /* 0 - padding 4 bytes */
4908 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
4911 /*******************************************************************
4912 reads or writes a structure.
4913 ********************************************************************/
4915 static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
4916 prs_struct *ps, int depth)
4918 if (usr == NULL)
4919 return False;
4921 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
4922 depth++;
4924 if(!prs_align(ps))
4925 return False;
4927 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
4928 return False;
4930 if(!smb_io_time("time", &usr->expiry, ps, depth))
4931 return False;
4933 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
4934 return False;
4936 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
4937 return False;
4939 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
4940 return False;
4942 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
4943 return False;
4944 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
4945 return False;
4947 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
4948 return False;
4950 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
4951 return False;
4952 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
4953 return False;
4955 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
4956 return False;
4957 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
4958 return False;
4960 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
4961 return False;
4962 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
4963 return False;
4964 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
4965 return False;
4966 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
4967 return False;
4968 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
4969 return False;
4970 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
4971 return False;
4973 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
4974 return False;
4976 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
4977 return False;
4979 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
4980 return False;
4982 if(!prs_align(ps))
4983 return False;
4985 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
4986 return False;
4988 return True;
4991 /*************************************************************************
4992 init_sam_user_infoa
4994 unknown_3 = 0x09f8 27fa
4995 unknown_5 = 0x0001 0000
4996 unknown_6 = 0x0000 04ec
4998 *************************************************************************/
5000 void init_sam_user_info24(SAM_USER_INFO_24 * usr,
5001 char newpass[516], uint16 passlen)
5003 DEBUG(10, ("init_sam_user_info24: passlen: %d\n", passlen));
5004 memcpy(usr->pass, newpass, sizeof(usr->pass));
5007 /*******************************************************************
5008 reads or writes a structure.
5009 ********************************************************************/
5011 static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
5012 prs_struct *ps, int depth)
5014 if (usr == NULL)
5015 return False;
5017 prs_debug(ps, depth, desc, "sam_io_user_info24");
5018 depth++;
5020 if(!prs_align(ps))
5021 return False;
5023 if(!prs_uint8s(False, "password", ps, depth, usr->pass, sizeof(usr->pass)))
5024 return False;
5026 return True;
5029 /*************************************************************************
5030 init_sam_user_info23
5032 unknown_3 = 0x09f8 27fa
5033 unknown_5 = 0x0001 0000
5034 unknown_6 = 0x0000 04ec
5036 *************************************************************************/
5038 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5039 NTTIME * logoff_time, /* all zeros */
5040 NTTIME * kickoff_time, /* all zeros */
5041 NTTIME * pass_last_set_time, /* all zeros */
5042 NTTIME * pass_can_change_time, /* all zeros */
5043 NTTIME * pass_must_change_time, /* all zeros */
5044 UNISTR2 *user_name,
5045 UNISTR2 *full_name,
5046 UNISTR2 *home_dir,
5047 UNISTR2 *dir_drive,
5048 UNISTR2 *log_scr,
5049 UNISTR2 *prof_path,
5050 UNISTR2 *desc,
5051 UNISTR2 *wkstas,
5052 UNISTR2 *unk_str,
5053 UNISTR2 *mung_dial,
5054 uint32 user_rid, /* 0x0000 0000 */
5055 uint32 group_rid,
5056 uint32 acb_info,
5057 uint32 unknown_3,
5058 uint16 logon_divs,
5059 LOGON_HRS * hrs,
5060 uint32 unknown_5,
5061 char newpass[516], uint32 unknown_6)
5063 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5064 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5065 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5066 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5067 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5068 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5069 int len_description = desc != NULL ? desc->uni_str_len : 0;
5070 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5071 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5072 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5074 usr->logon_time = *logon_time; /* all zeros */
5075 usr->logoff_time = *logoff_time; /* all zeros */
5076 usr->kickoff_time = *kickoff_time; /* all zeros */
5077 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5078 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5079 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5081 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5082 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5083 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5084 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5085 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5086 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5087 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5088 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5089 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5090 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5092 ZERO_STRUCT(usr->nt_pwd);
5093 ZERO_STRUCT(usr->lm_pwd);
5095 usr->user_rid = user_rid; /* 0x0000 0000 */
5096 usr->group_rid = group_rid;
5097 usr->acb_info = acb_info;
5098 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5100 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5101 usr->ptr_logon_hrs = hrs ? 1 : 0;
5103 ZERO_STRUCT(usr->padding1);
5105 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5107 memcpy(usr->pass, newpass, sizeof(usr->pass));
5109 copy_unistr2(&usr->uni_user_name, user_name);
5110 copy_unistr2(&usr->uni_full_name, full_name);
5111 copy_unistr2(&usr->uni_home_dir, home_dir);
5112 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5113 copy_unistr2(&usr->uni_logon_script, log_scr);
5114 copy_unistr2(&usr->uni_profile_path, prof_path);
5115 copy_unistr2(&usr->uni_acct_desc, desc);
5116 copy_unistr2(&usr->uni_workstations, wkstas);
5117 copy_unistr2(&usr->uni_unknown_str, unk_str);
5118 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5120 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5121 usr->padding4 = 0;
5123 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5126 /*************************************************************************
5127 init_sam_user_info23
5129 unknown_3 = 0x09f8 27fa
5130 unknown_5 = 0x0001 0000
5131 unknown_6 = 0x0000 04ec
5133 *************************************************************************/
5135 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5136 NTTIME * logoff_time, /* all zeros */
5137 NTTIME * kickoff_time, /* all zeros */
5138 NTTIME * pass_last_set_time, /* all zeros */
5139 NTTIME * pass_can_change_time, /* all zeros */
5140 NTTIME * pass_must_change_time, /* all zeros */
5141 char *user_name, /* NULL */
5142 char *full_name,
5143 char *home_dir, char *dir_drive, char *log_scr,
5144 char *prof_path, char *desc, char *wkstas,
5145 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5146 uint32 group_rid, uint32 acb_info,
5147 uint32 unknown_3, uint16 logon_divs,
5148 LOGON_HRS * hrs, uint32 unknown_5,
5149 char newpass[516], uint32 unknown_6)
5151 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5152 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5153 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5154 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5155 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5156 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5157 int len_description = desc != NULL ? strlen(desc) : 0;
5158 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5159 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5160 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5162 usr->logon_time = *logon_time; /* all zeros */
5163 usr->logoff_time = *logoff_time; /* all zeros */
5164 usr->kickoff_time = *kickoff_time; /* all zeros */
5165 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5166 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5167 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5169 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5170 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5171 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5172 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5173 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5174 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5175 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5176 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5177 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5178 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5180 ZERO_STRUCT(usr->nt_pwd);
5181 ZERO_STRUCT(usr->lm_pwd);
5183 usr->user_rid = user_rid; /* 0x0000 0000 */
5184 usr->group_rid = group_rid;
5185 usr->acb_info = acb_info;
5186 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5188 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5189 usr->ptr_logon_hrs = hrs ? 1 : 0;
5191 ZERO_STRUCT(usr->padding1);
5193 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5195 memcpy(usr->pass, newpass, sizeof(usr->pass));
5197 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5198 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5199 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5200 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5201 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5202 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5203 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5204 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5205 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5206 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5208 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5209 usr->padding4 = 0;
5211 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5214 /*******************************************************************
5215 reads or writes a structure.
5216 ********************************************************************/
5218 static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
5219 prs_struct *ps, int depth)
5221 if (usr == NULL)
5222 return False;
5224 prs_debug(ps, depth, desc, "sam_io_user_info23");
5225 depth++;
5227 if(!prs_align(ps))
5228 return False;
5230 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5231 return False;
5232 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5233 return False;
5234 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5235 return False;
5236 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5237 return False;
5238 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5239 return False;
5240 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5241 return False;
5243 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5244 return False;
5245 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5246 return False;
5247 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5248 return False;
5249 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5250 return False;
5251 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5252 return False;
5253 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5254 return False;
5255 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5256 return False;
5257 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5258 return False;
5259 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5260 return False;
5261 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5262 return False;
5264 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5265 return False;
5266 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5267 return False;
5269 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5270 return False;
5271 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5272 return False;
5273 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5274 return False;
5276 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5277 return False;
5278 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5279 return False;
5280 if(!prs_align(ps))
5281 return False;
5282 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5283 return False;
5284 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5285 return False;
5286 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5287 return False;
5289 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5290 return False;
5292 /* here begins pointed-to data */
5294 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5295 return False;
5297 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5298 return False;
5300 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5301 return False;
5303 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5304 return False;
5306 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5307 return False;
5309 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5310 return False;
5312 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5313 return False;
5315 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5316 return False;
5318 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5319 return False;
5321 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5322 return False;
5324 /* ok, this is only guess-work (as usual) */
5325 if (usr->ptr_logon_hrs) {
5326 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5327 return False;
5328 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5329 return False;
5330 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5331 return False;
5332 } else if (UNMARSHALLING(ps)) {
5333 usr->unknown_6 = 0;
5334 usr->padding4 = 0;
5337 return True;
5341 /*************************************************************************
5342 init_sam_user_info21W
5344 unknown_3 = 0x00ff ffff
5345 unknown_5 = 0x0002 0000
5346 unknown_6 = 0x0000 04ec
5348 *************************************************************************/
5350 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5351 NTTIME * logon_time,
5352 NTTIME * logoff_time,
5353 NTTIME * kickoff_time,
5354 NTTIME * pass_last_set_time,
5355 NTTIME * pass_can_change_time,
5356 NTTIME * pass_must_change_time,
5357 UNISTR2 *user_name,
5358 UNISTR2 *full_name,
5359 UNISTR2 *home_dir,
5360 UNISTR2 *dir_drive,
5361 UNISTR2 *log_scr,
5362 UNISTR2 *prof_path,
5363 UNISTR2 *desc,
5364 UNISTR2 *wkstas,
5365 UNISTR2 *unk_str,
5366 UNISTR2 *mung_dial,
5367 uchar lm_pwd[16],
5368 uchar nt_pwd[16],
5369 uint32 user_rid,
5370 uint32 group_rid,
5371 uint32 acb_info,
5372 uint32 unknown_3,
5373 uint16 logon_divs,
5374 LOGON_HRS * hrs,
5375 uint32 unknown_5, uint32 unknown_6)
5377 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5378 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5379 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5380 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5381 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5382 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5383 int len_description = desc != NULL ? desc->uni_str_len : 0;
5384 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5385 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5386 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5388 usr->logon_time = *logon_time;
5389 usr->logoff_time = *logoff_time;
5390 usr->kickoff_time = *kickoff_time;
5391 usr->pass_last_set_time = *pass_last_set_time;
5392 usr->pass_can_change_time = *pass_can_change_time;
5393 usr->pass_must_change_time = *pass_must_change_time;
5395 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5396 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5397 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5398 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5399 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5400 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5401 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5402 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5403 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5404 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5406 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5407 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5409 usr->user_rid = user_rid;
5410 usr->group_rid = group_rid;
5411 usr->acb_info = acb_info;
5412 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5414 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5415 usr->ptr_logon_hrs = hrs ? 1 : 0;
5416 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5418 ZERO_STRUCT(usr->padding1);
5420 copy_unistr2(&usr->uni_user_name, user_name);
5421 copy_unistr2(&usr->uni_full_name, full_name);
5422 copy_unistr2(&usr->uni_home_dir, home_dir);
5423 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5424 copy_unistr2(&usr->uni_logon_script, log_scr);
5425 copy_unistr2(&usr->uni_profile_path, prof_path);
5426 copy_unistr2(&usr->uni_acct_desc, desc);
5427 copy_unistr2(&usr->uni_workstations, wkstas);
5428 copy_unistr2(&usr->uni_unknown_str, unk_str);
5429 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5431 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5432 usr->padding4 = 0;
5434 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5437 /*************************************************************************
5438 init_sam_user_info21
5440 unknown_3 = 0x00ff ffff
5441 unknown_5 = 0x0002 0000
5442 unknown_6 = 0x0000 04ec
5444 *************************************************************************/
5446 void init_sam_user_info21A(SAM_USER_INFO_21 * usr,
5447 NTTIME * logon_time,
5448 NTTIME * logoff_time,
5449 NTTIME * kickoff_time,
5450 NTTIME * pass_last_set_time,
5451 NTTIME * pass_can_change_time,
5452 NTTIME * pass_must_change_time,
5453 char *user_name,
5454 char *full_name,
5455 char *home_dir,
5456 char *dir_drive,
5457 char *log_scr,
5458 char *prof_path,
5459 char *desc,
5460 char *wkstas,
5461 char *unk_str,
5462 char *mung_dial,
5463 uint32 user_rid,
5464 uint32 group_rid,
5465 uint32 acb_info,
5466 uint32 unknown_3,
5467 uint16 logon_divs,
5468 LOGON_HRS * hrs,
5469 uint32 unknown_5, uint32 unknown_6)
5471 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5472 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5473 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5474 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5475 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5476 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5477 int len_description = desc != NULL ? strlen(desc) : 0;
5478 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5479 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5480 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5482 usr->logon_time = *logon_time;
5483 usr->logoff_time = *logoff_time;
5484 usr->kickoff_time = *kickoff_time;
5485 usr->pass_last_set_time = *pass_last_set_time;
5486 usr->pass_can_change_time = *pass_can_change_time;
5487 usr->pass_must_change_time = *pass_must_change_time;
5489 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5490 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5491 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5492 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5493 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5494 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5495 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5496 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5497 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5498 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5500 ZERO_STRUCT(usr->nt_pwd);
5501 ZERO_STRUCT(usr->lm_pwd);
5503 usr->user_rid = user_rid;
5504 usr->group_rid = group_rid;
5505 usr->acb_info = acb_info;
5506 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5508 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5509 usr->ptr_logon_hrs = hrs ? 1 : 0;
5510 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5512 ZERO_STRUCT(usr->padding1);
5514 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
5515 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5516 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5517 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5518 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5519 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5520 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5521 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5522 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5523 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5525 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5526 usr->padding4 = 0;
5528 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5531 /*******************************************************************
5532 reads or writes a structure.
5533 ********************************************************************/
5535 static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
5536 prs_struct *ps, int depth)
5538 if (usr == NULL)
5539 return False;
5541 prs_debug(ps, depth, desc, "sam_io_user_info21");
5542 depth++;
5544 if(!prs_align(ps))
5545 return False;
5547 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5548 return False;
5549 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5550 return False;
5551 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
5552 return False;
5553 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5554 return False;
5555 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
5556 return False;
5557 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5558 return False;
5560 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5561 return False;
5562 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5563 return False;
5564 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5565 return False;
5566 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5567 return False;
5568 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5569 return False;
5570 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5571 return False;
5572 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5573 return False;
5574 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5575 return False;
5576 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5577 return False;
5578 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5579 return False;
5581 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5582 return False;
5583 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5584 return False;
5586 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5587 return False;
5588 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5589 return False;
5590 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5591 return False;
5593 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5594 return False;
5595 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5596 return False;
5597 if(!prs_align(ps))
5598 return False;
5599 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5600 return False;
5601 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5602 return False;
5604 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5605 return False;
5607 /* here begins pointed-to data */
5609 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5610 return False;
5611 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5612 return False;
5613 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5614 return False;
5615 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5616 return False;
5617 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5618 return False;
5619 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5620 return False;
5621 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5622 return False;
5623 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5624 return False;
5625 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5626 return False;
5627 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
5628 return False;
5630 /* ok, this is only guess-work (as usual) */
5631 if (usr->ptr_logon_hrs) {
5632 if(!prs_align(ps))
5633 return False;
5634 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5635 return False;
5636 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5637 return False;
5638 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5639 return False;
5640 } else if (UNMARSHALLING(ps)) {
5641 usr->unknown_6 = 0;
5642 usr->padding4 = 0;
5645 return True;
5648 /*******************************************************************
5649 inits a SAM_USERINFO_CTR structure.
5650 ********************************************************************/
5652 uint32 make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
5653 uint16 switch_value,
5654 SAM_USER_INFO_21 * usr)
5656 DEBUG(5, ("init_samr_userinfo_ctr\n"));
5658 ctr->switch_value = switch_value;
5659 ctr->info.id = NULL;
5661 switch (switch_value) {
5662 case 0x10:
5663 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
5664 if (ctr->info.id10 == NULL)
5665 return NT_STATUS_NO_MEMORY;
5667 init_sam_user_info10(ctr->info.id10, usr->acb_info);
5668 break;
5669 #if 0
5670 /* whoops - got this wrong. i think. or don't understand what's happening. */
5671 case 0x11:
5673 NTTIME expire;
5674 info = (void *)&id11;
5676 expire.low = 0xffffffff;
5677 expire.high = 0x7fffffff;
5679 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
5680 init_sam_user_info11(ctr->info.id11, &expire,
5681 "BROOKFIELDS$", /* name */
5682 0x03ef, /* user rid */
5683 0x201, /* group rid */
5684 0x0080); /* acb info */
5686 break;
5688 #endif
5689 case 0x12:
5690 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
5691 if (ctr->info.id12 == NULL)
5692 return NT_STATUS_NO_MEMORY;
5694 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
5695 break;
5696 case 21:
5698 SAM_USER_INFO_21 *cusr;
5699 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
5700 ctr->info.id21 = cusr;
5701 if (ctr->info.id21 == NULL)
5702 return NT_STATUS_NO_MEMORY;
5703 memcpy(cusr, usr, sizeof(*usr));
5704 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
5705 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
5706 break;
5708 default:
5709 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
5710 return NT_STATUS_INVALID_INFO_CLASS;
5713 return NT_STATUS_NOPROBLEMO;
5716 /*******************************************************************
5717 inits a SAM_USERINFO_CTR structure.
5718 ********************************************************************/
5720 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
5721 uint16 switch_value, void *info)
5723 DEBUG(5, ("init_samr_userinfo_ctr\n"));
5725 ctr->switch_value = switch_value;
5726 ctr->info.id = info;
5728 switch (switch_value) {
5729 case 0x18:
5730 SamOEMhash(ctr->info.id24->pass, sess_key, 1);
5731 dump_data(100, (char *)sess_key, 16);
5732 dump_data(100, (char *)ctr->info.id24->pass, 516);
5733 break;
5734 case 0x17:
5735 SamOEMhash(ctr->info.id23->pass, sess_key, 1);
5736 dump_data(100, (char *)sess_key, 16);
5737 dump_data(100, (char *)ctr->info.id23->pass, 516);
5738 break;
5739 default:
5740 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
5744 /*******************************************************************
5745 reads or writes a structure.
5746 ********************************************************************/
5748 static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR **ppctr,
5749 prs_struct *ps, int depth)
5751 BOOL ret;
5752 SAM_USERINFO_CTR *ctr;
5754 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
5755 depth++;
5757 if (UNMARSHALLING(ps)) {
5758 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
5759 if (ctr == NULL)
5760 return False;
5761 *ppctr = ctr;
5762 } else {
5763 ctr = *ppctr;
5766 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
5768 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
5769 return False;
5770 if(!prs_align(ps))
5771 return False;
5773 ret = False;
5775 switch (ctr->switch_value) {
5776 case 0x10:
5777 if (UNMARSHALLING(ps))
5778 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
5779 if (ctr->info.id10 == NULL) {
5780 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5781 return False;
5783 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
5784 break;
5785 case 0x11:
5786 if (UNMARSHALLING(ps))
5787 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
5789 if (ctr->info.id11 == NULL) {
5790 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5791 return False;
5793 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
5794 break;
5795 case 0x12:
5796 if (UNMARSHALLING(ps))
5797 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
5799 if (ctr->info.id12 == NULL) {
5800 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5801 return False;
5803 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
5804 break;
5805 case 21:
5806 if (UNMARSHALLING(ps))
5807 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
5809 if (ctr->info.id21 == NULL) {
5810 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5811 return False;
5813 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
5814 break;
5815 case 23:
5816 if (UNMARSHALLING(ps))
5817 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
5819 if (ctr->info.id23 == NULL) {
5820 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5821 return False;
5823 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
5824 break;
5825 case 24:
5826 if (UNMARSHALLING(ps))
5827 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
5829 if (ctr->info.id24 == NULL) {
5830 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5831 return False;
5833 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
5834 break;
5835 default:
5836 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
5837 ret = False;
5838 break;
5841 return ret;
5844 /*******************************************************************
5845 inits a SAMR_R_QUERY_USERINFO structure.
5846 ********************************************************************/
5848 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
5849 SAM_USERINFO_CTR * ctr, uint32 status)
5851 DEBUG(5, ("init_samr_r_query_userinfo\n"));
5853 r_u->ptr = 0;
5854 r_u->ctr = NULL;
5856 if (status == 0) {
5857 r_u->ptr = 1;
5858 r_u->ctr = ctr;
5861 r_u->status = status; /* return status */
5864 /*******************************************************************
5865 reads or writes a structure.
5866 ********************************************************************/
5868 BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
5869 prs_struct *ps, int depth)
5871 if (r_u == NULL)
5872 return False;
5874 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
5875 depth++;
5877 if(!prs_align(ps))
5878 return False;
5880 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
5881 return False;
5883 if (r_u->ptr != 0) {
5884 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
5885 return False;
5888 if(!prs_align(ps))
5889 return False;
5890 if(!prs_uint32("status", ps, depth, &r_u->status))
5891 return False;
5893 return True;
5896 /*******************************************************************
5897 inits a SAMR_Q_SET_USERINFO structure.
5898 ********************************************************************/
5900 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
5901 POLICY_HND *hnd, unsigned char sess_key[16],
5902 uint16 switch_value, void *info)
5904 DEBUG(5, ("init_samr_q_set_userinfo\n"));
5906 q_u->pol = *hnd;
5907 q_u->switch_value = switch_value;
5908 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
5911 /*******************************************************************
5912 reads or writes a structure.
5913 ********************************************************************/
5915 BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
5916 prs_struct *ps, int depth)
5918 if (q_u == NULL)
5919 return False;
5921 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
5922 depth++;
5924 if(!prs_align(ps))
5925 return False;
5927 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
5929 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
5930 return False;
5931 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
5932 return False;
5934 return True;
5937 /*******************************************************************
5938 inits a SAMR_R_SET_USERINFO structure.
5939 ********************************************************************/
5941 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, uint32 status)
5943 DEBUG(5, ("init_samr_r_set_userinfo\n"));
5945 r_u->status = status; /* return status */
5948 /*******************************************************************
5949 reads or writes a structure.
5950 ********************************************************************/
5952 BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
5953 prs_struct *ps, int depth)
5955 if (r_u == NULL)
5956 return False;
5958 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
5959 depth++;
5961 if(!prs_align(ps))
5962 return False;
5964 if(!prs_uint32("status", ps, depth, &r_u->status))
5965 return False;
5967 return True;
5970 /*******************************************************************
5971 inits a SAMR_Q_SET_USERINFO2 structure.
5972 ********************************************************************/
5974 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
5975 POLICY_HND *hnd, unsigned char sess_key[16],
5976 uint16 switch_value, SAM_USERINFO_CTR * ctr)
5978 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
5980 q_u->pol = *hnd;
5981 q_u->switch_value = switch_value;
5982 q_u->ctr = ctr;
5984 if (q_u->ctr != NULL)
5985 q_u->ctr->switch_value = switch_value;
5987 switch (switch_value) {
5988 case 0x12:
5989 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 0);
5990 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 0);
5991 dump_data(100, (char *)sess_key, 16);
5992 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
5993 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
5994 break;
5998 /*******************************************************************
5999 reads or writes a structure.
6000 ********************************************************************/
6002 BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6003 prs_struct *ps, int depth)
6005 if (q_u == NULL)
6006 return False;
6008 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6009 depth++;
6011 if(!prs_align(ps))
6012 return False;
6014 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6015 return False;
6017 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6018 return False;
6019 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6020 return False;
6022 return True;
6025 /*******************************************************************
6026 inits a SAMR_R_SET_USERINFO2 structure.
6027 ********************************************************************/
6029 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, uint32 status)
6031 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6033 r_u->status = status; /* return status */
6036 /*******************************************************************
6037 reads or writes a structure.
6038 ********************************************************************/
6040 BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
6041 prs_struct *ps, int depth)
6043 if (r_u == NULL)
6044 return False;
6046 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6047 depth++;
6049 if(!prs_align(ps))
6050 return False;
6052 if(!prs_uint32("status", ps, depth, &r_u->status))
6053 return False;
6055 return True;
6058 /*******************************************************************
6059 inits a SAMR_Q_CONNECT structure.
6060 ********************************************************************/
6062 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6063 char *srv_name, uint32 access_mask)
6065 int len_srv_name = strlen(srv_name);
6067 DEBUG(5, ("init_samr_q_connect\n"));
6069 /* make PDC server name \\server */
6070 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6071 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6073 /* example values: 0x0000 0002 */
6074 q_u->access_mask = access_mask;
6077 /*******************************************************************
6078 reads or writes a structure.
6079 ********************************************************************/
6081 BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
6082 prs_struct *ps, int depth)
6084 if (q_u == NULL)
6085 return False;
6087 prs_debug(ps, depth, desc, "samr_io_q_connect");
6088 depth++;
6090 if(!prs_align(ps))
6091 return False;
6093 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6094 return False;
6095 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6096 return False;
6098 if(!prs_align(ps))
6099 return False;
6100 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6101 return False;
6103 return True;
6106 /*******************************************************************
6107 reads or writes a structure.
6108 ********************************************************************/
6110 BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
6111 prs_struct *ps, int depth)
6113 if (r_u == NULL)
6114 return False;
6116 prs_debug(ps, depth, desc, "samr_io_r_connect");
6117 depth++;
6119 if(!prs_align(ps))
6120 return False;
6122 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6123 return False;
6125 if(!prs_uint32("status", ps, depth, &r_u->status))
6126 return False;
6128 return True;
6131 /*******************************************************************
6132 inits a SAMR_Q_CONNECT_ANON structure.
6133 ********************************************************************/
6135 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6137 DEBUG(5, ("init_samr_q_connect_anon\n"));
6139 q_u->ptr = 1;
6140 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6141 q_u->unknown_1 = 0x01;
6142 q_u->access_mask = 0x20;
6145 /*******************************************************************
6146 reads or writes a structure.
6147 ********************************************************************/
6149 BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
6150 prs_struct *ps, int depth)
6152 if (q_u == NULL)
6153 return False;
6155 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6156 depth++;
6158 if(!prs_align(ps))
6159 return False;
6161 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6162 return False;
6163 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6164 return False;
6165 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6166 return False;
6167 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6168 return False;
6170 return True;
6173 /*******************************************************************
6174 reads or writes a structure.
6175 ********************************************************************/
6177 BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
6178 prs_struct *ps, int depth)
6180 if (r_u == NULL)
6181 return False;
6183 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6184 depth++;
6186 if(!prs_align(ps))
6187 return False;
6189 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6190 return False;
6192 if(!prs_uint32("status", ps, depth, &r_u->status))
6193 return False;
6195 return True;
6198 /*******************************************************************
6199 inits a SAMR_Q_GET_DOM_PWINFO structure.
6200 ********************************************************************/
6202 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6203 char *srv_name)
6205 int len_srv_name = strlen(srv_name);
6207 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6209 q_u->ptr = 1;
6210 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6211 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6214 /*******************************************************************
6215 reads or writes a structure.
6216 ********************************************************************/
6218 BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6219 prs_struct *ps, int depth)
6221 if (q_u == NULL)
6222 return False;
6224 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6225 depth++;
6227 if(!prs_align(ps))
6228 return False;
6230 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6231 return False;
6232 if (q_u->ptr != 0) {
6233 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6234 return False;
6235 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6236 return False;
6239 return True;
6242 /*******************************************************************
6243 reads or writes a structure.
6244 ********************************************************************/
6246 BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6247 prs_struct *ps, int depth)
6249 if (r_u == NULL)
6250 return False;
6252 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6253 depth++;
6255 if(!prs_align(ps))
6256 return False;
6258 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
6259 return False;
6260 if(!prs_align(ps))
6261 return False;
6262 if(!prs_uint16("unk_1", ps, depth, &r_u->unk_1))
6263 return False;
6264 if(!prs_align(ps))
6265 return False;
6266 if(!prs_uint16("unk_2", ps, depth, &r_u->unk_2))
6267 return False;
6268 if(!prs_align(ps))
6269 return False;
6271 if(!prs_uint32("status", ps, depth, &r_u->status))
6272 return False;
6274 return True;
6277 /*******************************************************************
6278 make a SAMR_ENC_PASSWD structure.
6279 ********************************************************************/
6281 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
6283 ZERO_STRUCTP(pwd);
6285 if (pass == NULL) {
6286 pwd->ptr = 0;
6287 } else {
6288 pwd->ptr = 1;
6289 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6293 /*******************************************************************
6294 reads or writes a SAMR_ENC_PASSWD structure.
6295 ********************************************************************/
6297 BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
6298 prs_struct *ps, int depth)
6300 if (pwd == NULL)
6301 return False;
6303 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6304 depth++;
6306 if(!prs_align(ps))
6307 return False;
6309 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
6310 return False;
6312 if (pwd->ptr != 0) {
6313 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
6314 return False;
6317 return True;
6320 /*******************************************************************
6321 inits a SAMR_ENC_HASH structure.
6322 ********************************************************************/
6324 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
6326 ZERO_STRUCTP(hsh);
6328 if (hash == NULL) {
6329 hsh->ptr = 0;
6330 } else {
6331 hsh->ptr = 1;
6332 memcpy(hsh->hash, hash, sizeof(hsh->hash));
6336 /*******************************************************************
6337 reads or writes a SAMR_ENC_HASH structure.
6338 ********************************************************************/
6340 BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
6341 prs_struct *ps, int depth)
6343 if (hsh == NULL)
6344 return False;
6346 prs_debug(ps, depth, desc, "samr_io_enc_hash");
6347 depth++;
6349 if(!prs_align(ps))
6350 return False;
6352 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
6353 return False;
6354 if (hsh->ptr != 0) {
6355 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
6356 return False;
6359 return True;
6362 /*******************************************************************
6363 inits a SAMR_R_GET_DOM_PWINFO structure.
6364 ********************************************************************/
6366 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
6367 char *dest_host, char *user_name,
6368 char nt_newpass[516],
6369 uchar nt_oldhash[16],
6370 char lm_newpass[516],
6371 uchar lm_oldhash[16])
6373 int len_dest_host = strlen(dest_host);
6374 int len_user_name = strlen(user_name);
6376 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
6378 q_u->ptr_0 = 1;
6379 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
6380 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
6381 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
6382 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
6384 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
6385 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
6387 q_u->unknown = 0x01;
6389 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
6390 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
6393 /*******************************************************************
6394 reads or writes a structure.
6395 ********************************************************************/
6397 BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
6398 prs_struct *ps, int depth)
6400 if (q_u == NULL)
6401 return False;
6403 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
6404 depth++;
6406 if(!prs_align(ps))
6407 return False;
6409 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
6410 return False;
6412 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
6413 return False;
6414 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
6415 return False;
6417 if(!prs_align(ps))
6418 return False;
6419 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
6420 return False;
6421 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
6422 return False;
6424 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
6425 return False;
6426 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
6427 return False;
6429 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
6430 return False;
6432 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
6433 return False;
6434 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
6435 return False;
6437 return True;
6440 /*******************************************************************
6441 inits a SAMR_R_CHGPASSWD_USER structure.
6442 ********************************************************************/
6444 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, uint32 status)
6446 DEBUG(5, ("init_r_chgpasswd_user\n"));
6448 r_u->status = status;
6451 /*******************************************************************
6452 reads or writes a structure.
6453 ********************************************************************/
6455 BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
6456 prs_struct *ps, int depth)
6458 if (r_u == NULL)
6459 return False;
6461 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
6462 depth++;
6464 if(!prs_align(ps))
6465 return False;
6467 if(!prs_uint32("status", ps, depth, &r_u->status))
6468 return False;
6470 return True;