few cleanups to bring in line with 2.2
[Samba/gbeck.git] / source / rpc_parse / parse_samr.c
blob7d023d54fc9c14c7c9a2da0c8cf8fa7772f0cc91
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 (ctr == NULL)
2054 return False;
2056 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2057 depth++;
2059 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
2060 return False;
2061 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
2062 return False;
2064 switch (ctr->switch_value1) {
2065 case 1:
2066 if(!samr_io_group_info1("group_info1",
2067 &ctr->group.info1, ps, depth))
2068 return False;
2069 break;
2070 case 4:
2071 if(!samr_io_group_info4("group_info4",
2072 &ctr->group.info4, ps, depth))
2073 return False;
2074 break;
2075 default:
2076 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2077 break;
2080 return True;
2083 /*******************************************************************
2084 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2085 ********************************************************************/
2087 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2088 POLICY_HND *pol, char *acct_desc,
2089 uint32 access_mask)
2091 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2093 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2095 q_e->pol = *pol;
2097 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2098 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2100 q_e->access_mask = access_mask;
2103 /*******************************************************************
2104 reads or writes a structure.
2105 ********************************************************************/
2107 BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2108 prs_struct *ps, int depth)
2110 if (q_e == NULL)
2111 return False;
2113 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2114 depth++;
2116 if(!prs_align(ps))
2117 return False;
2119 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2120 return False;
2122 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2123 return False;
2124 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2125 q_e->hdr_acct_desc.buffer, ps, depth))
2126 return False;
2128 if(!prs_align(ps))
2129 return False;
2130 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2131 return False;
2133 return True;
2136 /*******************************************************************
2137 reads or writes a structure.
2138 ********************************************************************/
2140 BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2141 prs_struct *ps, int depth)
2143 if (r_u == NULL)
2144 return False;
2146 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2147 depth++;
2149 if(!prs_align(ps))
2150 return False;
2152 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2153 return False;
2155 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2156 return False;
2157 if(!prs_uint32("status", ps, depth, &r_u->status))
2158 return False;
2160 return True;
2163 /*******************************************************************
2164 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2165 ********************************************************************/
2167 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2168 POLICY_HND *hnd)
2170 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2172 q_c->group_pol = *hnd;
2175 /*******************************************************************
2176 reads or writes a structure.
2177 ********************************************************************/
2179 BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2180 prs_struct *ps, int depth)
2182 if (q_u == NULL)
2183 return False;
2185 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2186 depth++;
2188 if(!prs_align(ps))
2189 return False;
2191 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2192 return False;
2194 return True;
2197 /*******************************************************************
2198 reads or writes a structure.
2199 ********************************************************************/
2201 BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2202 prs_struct *ps, int depth)
2204 if (r_u == NULL)
2205 return False;
2207 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2208 depth++;
2210 if(!prs_align(ps))
2211 return False;
2213 if(!prs_uint32("status", ps, depth, &r_u->status))
2214 return False;
2216 return True;
2219 /*******************************************************************
2220 inits a SAMR_Q_DEL_GROUPMEM structure.
2221 ********************************************************************/
2223 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2224 POLICY_HND *pol, uint32 rid)
2226 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2228 q_e->pol = *pol;
2229 q_e->rid = rid;
2232 /*******************************************************************
2233 reads or writes a structure.
2234 ********************************************************************/
2236 BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2237 prs_struct *ps, int depth)
2239 if (q_e == NULL)
2240 return False;
2242 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2243 depth++;
2245 if(!prs_align(ps))
2246 return False;
2248 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2249 return False;
2251 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2252 return False;
2254 return True;
2257 /*******************************************************************
2258 inits a SAMR_R_DEL_GROUPMEM structure.
2259 ********************************************************************/
2261 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2262 uint32 status)
2264 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2266 r_u->status = status;
2269 /*******************************************************************
2270 reads or writes a structure.
2271 ********************************************************************/
2273 BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2274 prs_struct *ps, int depth)
2276 if (r_u == NULL)
2277 return False;
2279 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2280 depth++;
2282 if(!prs_align(ps))
2283 return False;
2285 if(!prs_uint32("status", ps, depth, &r_u->status))
2286 return False;
2288 return True;
2291 /*******************************************************************
2292 inits a SAMR_Q_ADD_GROUPMEM structure.
2293 ********************************************************************/
2295 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2296 POLICY_HND *pol, uint32 rid)
2298 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2300 q_e->pol = *pol;
2301 q_e->rid = rid;
2302 q_e->unknown = 0x0005;
2305 /*******************************************************************
2306 reads or writes a structure.
2307 ********************************************************************/
2309 BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2310 prs_struct *ps, int depth)
2312 if (q_e == NULL)
2313 return False;
2315 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2316 depth++;
2318 if(!prs_align(ps))
2319 return False;
2321 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2322 return False;
2324 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2325 return False;
2326 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2327 return False;
2329 return True;
2332 /*******************************************************************
2333 inits a SAMR_R_ADD_GROUPMEM structure.
2334 ********************************************************************/
2336 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2337 uint32 status)
2339 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2341 r_u->status = status;
2344 /*******************************************************************
2345 reads or writes a structure.
2346 ********************************************************************/
2348 BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2349 prs_struct *ps, int depth)
2351 if (r_u == NULL)
2352 return False;
2354 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2355 depth++;
2357 if(!prs_align(ps))
2358 return False;
2360 if(!prs_uint32("status", ps, depth, &r_u->status))
2361 return False;
2363 return True;
2366 /*******************************************************************
2367 inits a SAMR_Q_SET_GROUPINFO structure.
2368 ********************************************************************/
2370 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2371 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2373 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2375 q_e->pol = *pol;
2376 q_e->ctr = ctr;
2379 /*******************************************************************
2380 reads or writes a structure.
2381 ********************************************************************/
2383 BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2384 prs_struct *ps, int depth)
2386 if (q_e == NULL)
2387 return False;
2389 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2390 depth++;
2392 if(!prs_align(ps))
2393 return False;
2395 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2396 return False;
2398 if(!samr_group_info_ctr("ctr", q_e->ctr, ps, depth))
2399 return False;
2401 return True;
2404 /*******************************************************************
2405 inits a SAMR_R_SET_GROUPINFO structure.
2406 ********************************************************************/
2408 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, uint32 status)
2410 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2412 r_u->status = status;
2415 /*******************************************************************
2416 reads or writes a structure.
2417 ********************************************************************/
2419 BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
2420 prs_struct *ps, int depth)
2422 if (r_u == NULL)
2423 return False;
2425 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2426 depth++;
2428 if(!prs_align(ps))
2429 return False;
2431 if(!prs_uint32("status", ps, depth, &r_u->status))
2432 return False;
2434 return True;
2437 /*******************************************************************
2438 inits a SAMR_Q_QUERY_GROUPINFO structure.
2439 ********************************************************************/
2441 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2442 POLICY_HND *pol, uint16 switch_level)
2444 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2446 q_e->pol = *pol;
2448 q_e->switch_level = switch_level;
2451 /*******************************************************************
2452 reads or writes a structure.
2453 ********************************************************************/
2455 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2456 prs_struct *ps, int depth)
2458 if (q_e == NULL)
2459 return False;
2461 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2462 depth++;
2464 if(!prs_align(ps))
2465 return False;
2467 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2468 return False;
2470 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2471 return False;
2473 return True;
2476 /*******************************************************************
2477 inits a SAMR_R_QUERY_GROUPINFO structure.
2478 ********************************************************************/
2480 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2481 GROUP_INFO_CTR * ctr, uint32 status)
2483 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2485 r_u->ptr = (status == 0x0 && ctr != NULL) ? 1 : 0;
2486 r_u->ctr = ctr;
2487 r_u->status = status;
2490 /*******************************************************************
2491 reads or writes a structure.
2492 ********************************************************************/
2494 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2495 prs_struct *ps, int depth)
2497 if (r_u == NULL)
2498 return False;
2500 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2501 depth++;
2503 if(!prs_align(ps))
2504 return False;
2506 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2507 return False;
2509 if (r_u->ptr != 0) {
2510 if(!samr_group_info_ctr("ctr", r_u->ctr, ps, depth))
2511 return False;
2514 if(!prs_align(ps))
2515 return False;
2516 if(!prs_uint32("status", ps, depth, &r_u->status))
2517 return False;
2519 return True;
2522 /*******************************************************************
2523 inits a SAMR_Q_QUERY_GROUPMEM structure.
2524 ********************************************************************/
2526 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2528 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2530 q_c->group_pol = *hnd;
2533 /*******************************************************************
2534 reads or writes a structure.
2535 ********************************************************************/
2537 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2538 prs_struct *ps, int depth)
2540 if (q_u == NULL)
2541 return False;
2543 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2544 depth++;
2546 if(!prs_align(ps))
2547 return False;
2549 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2550 return False;
2552 return True;
2555 /*******************************************************************
2556 inits a SAMR_R_QUERY_GROUPMEM structure.
2557 ********************************************************************/
2559 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2560 uint32 num_entries, uint32 *rid,
2561 uint32 *attr, uint32 status)
2563 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2565 if (status == 0x0) {
2566 r_u->ptr = 1;
2567 r_u->num_entries = num_entries;
2569 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2570 r_u->ptr_rids = rid != NULL ? 1 : 0;
2572 r_u->num_rids = num_entries;
2573 r_u->rid = rid;
2575 r_u->num_attrs = num_entries;
2576 r_u->attr = attr;
2577 } else {
2578 r_u->ptr = 0;
2579 r_u->num_entries = 0;
2582 r_u->status = status;
2585 /*******************************************************************
2586 reads or writes a structure.
2587 ********************************************************************/
2589 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2590 prs_struct *ps, int depth)
2592 uint32 i;
2594 if (r_u == NULL)
2595 return False;
2597 if (UNMARSHALLING(ps))
2598 ZERO_STRUCTP(r_u);
2600 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2601 depth++;
2603 if(!prs_align(ps))
2604 return False;
2606 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2607 return False;
2608 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2609 return False;
2611 if (r_u->ptr != 0) {
2612 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2613 return False;
2614 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2615 return False;
2617 if (r_u->ptr_rids != 0) {
2618 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2619 return False;
2620 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2621 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2622 if (r_u->rid == NULL)
2623 return False;
2626 for (i = 0; i < r_u->num_rids; i++) {
2627 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2628 return False;
2632 if (r_u->ptr_attrs != 0) {
2633 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2634 return False;
2636 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2637 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2638 if (r_u->attr == NULL)
2639 return False;
2642 for (i = 0; i < r_u->num_attrs; i++) {
2643 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2644 return False;
2649 if(!prs_uint32("status", ps, depth, &r_u->status))
2650 return False;
2652 return True;
2655 /*******************************************************************
2656 inits a SAMR_Q_QUERY_USERGROUPS structure.
2657 ********************************************************************/
2659 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2660 POLICY_HND *hnd)
2662 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2664 q_u->pol = *hnd;
2667 /*******************************************************************
2668 reads or writes a structure.
2669 ********************************************************************/
2671 BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2672 prs_struct *ps, int depth)
2674 if (q_u == NULL)
2675 return False;
2677 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2678 depth++;
2680 if(!prs_align(ps))
2681 return False;
2683 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2684 return False;
2686 return True;
2689 /*******************************************************************
2690 inits a SAMR_R_QUERY_USERGROUPS structure.
2691 ********************************************************************/
2693 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2694 uint32 num_gids, DOM_GID * gid,
2695 uint32 status)
2697 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2699 if (status == 0) {
2700 r_u->ptr_0 = 1;
2701 r_u->num_entries = num_gids;
2702 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2703 r_u->num_entries2 = num_gids;
2705 r_u->gid = gid;
2706 } else {
2707 r_u->ptr_0 = 0;
2708 r_u->num_entries = 0;
2709 r_u->ptr_1 = 0;
2710 r_u->gid = NULL;
2713 r_u->status = status;
2716 /*******************************************************************
2717 reads or writes a structure.
2718 ********************************************************************/
2720 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
2721 prs_struct *ps, int depth)
2723 uint32 i;
2724 if (gid == NULL)
2725 return False;
2727 prs_debug(ps, depth, desc, "samr_io_gids");
2728 depth++;
2730 if(!prs_align(ps))
2731 return False;
2733 if(!prs_uint32("num_gids", ps, depth, num_gids))
2734 return False;
2736 if ((*num_gids) != 0) {
2737 if (UNMARSHALLING(ps)) {
2738 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
2741 if ((*gid) == NULL) {
2742 return False;
2745 for (i = 0; i < (*num_gids); i++) {
2746 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
2747 return False;
2751 return True;
2754 /*******************************************************************
2755 reads or writes a structure.
2756 ********************************************************************/
2758 BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
2759 prs_struct *ps, int depth)
2761 if (r_u == NULL)
2762 return False;
2764 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
2765 depth++;
2767 if(!prs_align(ps))
2768 return False;
2770 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
2771 return False;
2773 if (r_u->ptr_0 != 0) {
2774 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2775 return False;
2776 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
2777 return False;
2779 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
2780 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
2781 return False;
2785 if(!prs_align(ps))
2786 return False;
2787 if(!prs_uint32("status", ps, depth, &r_u->status))
2788 return False;
2790 return True;
2793 /*******************************************************************
2794 inits a SAMR_Q_ENUM_DOMAINS structure.
2795 ********************************************************************/
2797 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
2798 POLICY_HND *pol,
2799 uint32 start_idx, uint32 size)
2801 DEBUG(5, ("init_samr_q_enum_domains\n"));
2803 q_e->pol = *pol;
2805 q_e->start_idx = start_idx;
2806 q_e->max_size = size;
2809 /*******************************************************************
2810 reads or writes a structure.
2811 ********************************************************************/
2813 BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
2814 prs_struct *ps, int depth)
2816 if (q_e == NULL)
2817 return False;
2819 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
2820 depth++;
2822 if(!prs_align(ps))
2823 return False;
2825 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2826 return False;
2828 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
2829 return False;
2830 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
2831 return False;
2833 return True;
2836 /*******************************************************************
2837 inits a SAMR_R_ENUM_DOMAINS structure.
2838 ********************************************************************/
2840 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
2841 uint32 next_idx, uint32 num_sam_entries)
2843 DEBUG(5, ("init_samr_r_enum_domains\n"));
2845 r_u->next_idx = next_idx;
2847 if (num_sam_entries != 0) {
2848 r_u->ptr_entries1 = 1;
2849 r_u->ptr_entries2 = 1;
2850 r_u->num_entries2 = num_sam_entries;
2851 r_u->num_entries3 = num_sam_entries;
2853 r_u->num_entries4 = num_sam_entries;
2854 } else {
2855 r_u->ptr_entries1 = 0;
2856 r_u->num_entries2 = num_sam_entries;
2857 r_u->ptr_entries2 = 1;
2861 /*******************************************************************
2862 reads or writes a structure.
2863 ********************************************************************/
2865 BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
2866 prs_struct *ps, int depth)
2868 uint32 i;
2870 if (r_u == NULL)
2871 return False;
2873 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
2874 depth++;
2876 if(!prs_align(ps))
2877 return False;
2879 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
2880 return False;
2881 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
2882 return False;
2884 if (r_u->ptr_entries1 != 0) {
2885 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2886 return False;
2887 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
2888 return False;
2889 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
2890 return False;
2892 if (UNMARSHALLING(ps)) {
2893 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
2894 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
2897 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
2898 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
2899 r_u->num_entries4 = 0;
2900 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
2901 return False;
2904 for (i = 0; i < r_u->num_entries2; i++) {
2905 fstring tmp;
2906 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
2907 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
2908 return False;
2911 for (i = 0; i < r_u->num_entries2; i++) {
2912 fstring tmp;
2913 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
2914 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
2915 r_u->sam[i].hdr_name.buffer, ps,
2916 depth))
2917 return False;
2922 if(!prs_align(ps))
2923 return False;
2924 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
2925 return False;
2926 if(!prs_uint32("status", ps, depth, &r_u->status))
2927 return False;
2929 return True;
2932 /*******************************************************************
2933 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
2934 ********************************************************************/
2936 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
2937 POLICY_HND *pol,
2938 uint32 start_idx, uint32 size)
2940 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
2942 q_e->pol = *pol;
2944 q_e->start_idx = start_idx;
2945 q_e->max_size = size;
2948 /*******************************************************************
2949 reads or writes a structure.
2950 ********************************************************************/
2952 BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
2953 prs_struct *ps, int depth)
2955 if (q_e == NULL)
2956 return False;
2958 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
2959 depth++;
2961 if(!prs_align(ps))
2962 return False;
2964 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
2965 return False;
2967 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
2968 return False;
2969 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
2970 return False;
2972 return True;
2975 /*******************************************************************
2976 inits a SAMR_R_ENUM_DOM_GROUPS structure.
2977 ********************************************************************/
2979 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
2980 uint32 next_idx, uint32 num_sam_entries)
2982 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
2984 r_u->next_idx = next_idx;
2986 if (num_sam_entries != 0) {
2987 r_u->ptr_entries1 = 1;
2988 r_u->ptr_entries2 = 1;
2989 r_u->num_entries2 = num_sam_entries;
2990 r_u->num_entries3 = num_sam_entries;
2992 r_u->num_entries4 = num_sam_entries;
2993 } else {
2994 r_u->ptr_entries1 = 0;
2995 r_u->num_entries2 = num_sam_entries;
2996 r_u->ptr_entries2 = 1;
3000 /*******************************************************************
3001 reads or writes a structure.
3002 ********************************************************************/
3004 BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3005 prs_struct *ps, int depth)
3007 uint32 i;
3009 if (r_u == NULL)
3010 return False;
3012 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3013 depth++;
3015 if(!prs_align(ps))
3016 return False;
3018 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3019 return False;
3020 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3021 return False;
3023 if (r_u->ptr_entries1 != 0) {
3024 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3025 return False;
3026 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3027 return False;
3028 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3029 return False;
3031 if (UNMARSHALLING(ps)) {
3032 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3033 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3036 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3037 DEBUG(0,
3038 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3039 r_u->num_entries4 = 0;
3040 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3041 return False;
3044 for (i = 0; i < r_u->num_entries2; i++) {
3045 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3046 return False;
3049 for (i = 0; i < r_u->num_entries2; i++) {
3050 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3051 r_u->sam[i].hdr_name.buffer, ps, depth))
3052 return False;
3056 if(!prs_align(ps))
3057 return False;
3058 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3059 return False;
3060 if(!prs_uint32("status", ps, depth, &r_u->status))
3061 return False;
3063 return True;
3066 /*******************************************************************
3067 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3068 ********************************************************************/
3070 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3071 POLICY_HND *pol, uint32 start_idx,
3072 uint32 size)
3074 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3076 q_e->pol = *pol;
3078 q_e->start_idx = start_idx;
3079 q_e->max_size = size;
3083 /*******************************************************************
3084 reads or writes a structure.
3085 ********************************************************************/
3087 BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3088 prs_struct *ps, int depth)
3090 if (q_e == NULL)
3091 return False;
3093 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3094 depth++;
3096 if(!prs_align(ps))
3097 return False;
3099 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3100 return False;
3102 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3103 return False;
3104 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3105 return False;
3107 return True;
3110 /*******************************************************************
3111 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3112 ********************************************************************/
3114 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3116 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3118 r_u->next_idx = next_idx;
3120 if (num_sam_entries != 0) {
3121 r_u->ptr_entries1 = 1;
3122 r_u->ptr_entries2 = 1;
3123 r_u->num_entries2 = num_sam_entries;
3124 r_u->num_entries3 = num_sam_entries;
3126 r_u->num_entries4 = num_sam_entries;
3127 } else {
3128 r_u->ptr_entries1 = 0;
3129 r_u->num_entries2 = num_sam_entries;
3130 r_u->ptr_entries2 = 1;
3134 /*******************************************************************
3135 reads or writes a structure.
3136 ********************************************************************/
3138 BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3139 prs_struct *ps, int depth)
3141 uint32 i;
3143 if (r_u == NULL)
3144 return False;
3146 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3147 depth++;
3149 if(!prs_align(ps))
3150 return False;
3152 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3153 return False;
3154 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3155 return False;
3157 if (r_u->ptr_entries1 != 0) {
3158 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3159 return False;
3160 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3161 return False;
3162 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3163 return False;
3165 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3166 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3167 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3170 if (r_u->num_entries2 != 0 &&
3171 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3172 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3173 r_u->num_entries4 = 0;
3174 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3175 return False;
3178 for (i = 0; i < r_u->num_entries2; i++) {
3179 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3180 return False;
3183 for (i = 0; i < r_u->num_entries2; i++) {
3184 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3185 r_u->sam[i].hdr_name.buffer, ps,
3186 depth))
3187 return False;
3191 if(!prs_align(ps))
3192 return False;
3193 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3194 return False;
3195 if(!prs_uint32("status", ps, depth, &r_u->status))
3196 return False;
3198 return True;
3201 /*******************************************************************
3202 inits a ALIAS_INFO3 structure.
3203 ********************************************************************/
3205 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3207 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3209 DEBUG(5, ("init_samr_alias_info3\n"));
3211 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3212 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3215 /*******************************************************************
3216 reads or writes a structure.
3217 ********************************************************************/
3219 BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
3220 prs_struct *ps, int depth)
3222 if (al3 == NULL)
3223 return False;
3225 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3226 depth++;
3228 if(!prs_align(ps))
3229 return False;
3231 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3232 return False;
3233 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3234 al3->hdr_acct_desc.buffer, ps, depth))
3235 return False;
3237 return True;
3240 /*******************************************************************
3241 reads or writes a structure.
3242 ********************************************************************/
3244 BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
3245 prs_struct *ps, int depth)
3247 if (ctr == NULL)
3248 return False;
3250 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3251 depth++;
3253 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3254 return False;
3255 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3256 return False;
3258 switch (ctr->switch_value1) {
3259 case 3:
3260 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3261 return False;
3262 break;
3263 default:
3264 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3265 break;
3268 return True;
3271 /*******************************************************************
3272 inits a SAMR_Q_QUERY_ALIASINFO structure.
3273 ********************************************************************/
3275 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3276 POLICY_HND *pol, uint16 switch_level)
3278 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3280 q_e->pol = *pol;
3281 q_e->switch_level = switch_level;
3284 /*******************************************************************
3285 reads or writes a structure.
3286 ********************************************************************/
3288 BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3289 prs_struct *ps, int depth)
3291 if (q_e == NULL)
3292 return False;
3294 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3295 depth++;
3297 if(!prs_align(ps))
3298 return False;
3300 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3301 return False;
3303 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3304 return False;
3306 return True;
3309 /*******************************************************************
3310 inits a SAMR_R_QUERY_ALIASINFO structure.
3311 ********************************************************************/
3313 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3314 ALIAS_INFO_CTR * ctr, uint32 status)
3316 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3318 r_u->ptr = (status == 0x0 && ctr != NULL) ? 1 : 0;
3319 r_u->ctr = *ctr;
3320 r_u->status = status;
3323 /*******************************************************************
3324 reads or writes a structure.
3325 ********************************************************************/
3327 BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3328 prs_struct *ps, int depth)
3330 if (r_u == NULL)
3331 return False;
3333 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3334 depth++;
3336 if(!prs_align(ps))
3337 return False;
3339 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3340 return False;
3342 if (r_u->ptr != 0) {
3343 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3344 return False;
3347 if(!prs_align(ps))
3348 return False;
3349 if(!prs_uint32("status", ps, depth, &r_u->status))
3350 return False;
3352 return True;
3355 /*******************************************************************
3356 inits a SAMR_Q_SET_ALIASINFO structure.
3357 ********************************************************************/
3359 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3360 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3362 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3364 q_u->alias_pol = *hnd;
3365 q_u->ctr = *ctr;
3368 /*******************************************************************
3369 reads or writes a structure.
3370 ********************************************************************/
3372 BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3373 prs_struct *ps, int depth)
3375 if (q_u == NULL)
3376 return False;
3378 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3379 depth++;
3381 if(!prs_align(ps))
3382 return False;
3384 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3385 return False;
3386 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3387 return False;
3389 return True;
3392 /*******************************************************************
3393 reads or writes a structure.
3394 ********************************************************************/
3396 BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
3397 prs_struct *ps, int depth)
3399 if (r_u == NULL)
3400 return False;
3402 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3403 depth++;
3405 if(!prs_align(ps))
3406 return False;
3407 if(!prs_uint32("status", ps, depth, &r_u->status))
3408 return False;
3410 return True;
3413 /*******************************************************************
3414 inits a SAMR_Q_QUERY_USERALIASES structure.
3415 ********************************************************************/
3417 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3418 POLICY_HND *hnd,
3419 uint32 num_sids,
3420 uint32 *ptr_sid, DOM_SID2 * sid)
3422 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3424 q_u->pol = *hnd;
3426 q_u->num_sids1 = num_sids;
3427 q_u->ptr = 1;
3428 q_u->num_sids2 = num_sids;
3430 q_u->ptr_sid = ptr_sid;
3431 q_u->sid = sid;
3434 /*******************************************************************
3435 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3436 ********************************************************************/
3438 BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3439 prs_struct *ps, int depth)
3441 fstring tmp;
3442 uint32 i;
3444 if (q_u == NULL)
3445 return False;
3447 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3448 depth++;
3450 if(!prs_align(ps))
3451 return False;
3453 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3454 return False;
3456 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3457 return False;
3458 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3459 return False;
3461 if (q_u->ptr==0)
3462 return True;
3464 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3465 return False;
3467 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3468 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3469 if (q_u->ptr_sid == NULL)
3470 return False;
3472 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3473 if (q_u->sid == NULL)
3474 return False;
3477 for (i = 0; i < q_u->num_sids2; i++) {
3478 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3479 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3480 return False;
3483 for (i = 0; i < q_u->num_sids2; i++) {
3484 if (q_u->ptr_sid[i] != 0) {
3485 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3486 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3487 return False;
3491 return True;
3494 /*******************************************************************
3495 inits a SAMR_R_QUERY_USERALIASES structure.
3496 ********************************************************************/
3498 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3499 uint32 num_rids, uint32 *rid,
3500 uint32 status)
3502 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3504 if (status == 0x0) {
3505 r_u->num_entries = num_rids;
3506 r_u->ptr = 1;
3507 r_u->num_entries2 = num_rids;
3509 r_u->rid = rid;
3510 } else {
3511 r_u->num_entries = 0;
3512 r_u->ptr = 0;
3513 r_u->num_entries2 = 0;
3516 r_u->status = status;
3519 /*******************************************************************
3520 reads or writes a structure.
3521 ********************************************************************/
3523 BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
3524 prs_struct *ps, int depth)
3526 fstring tmp;
3527 uint32 i;
3528 if (rid == NULL)
3529 return False;
3531 prs_debug(ps, depth, desc, "samr_io_rids");
3532 depth++;
3534 if(!prs_align(ps))
3535 return False;
3537 if(!prs_uint32("num_rids", ps, depth, num_rids))
3538 return False;
3540 if ((*num_rids) != 0) {
3541 if (UNMARSHALLING(ps)) {
3542 /* reading */
3543 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3545 if ((*rid) == NULL)
3546 return False;
3548 for (i = 0; i < (*num_rids); i++) {
3549 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3550 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3551 return False;
3555 return True;
3558 /*******************************************************************
3559 reads or writes a structure.
3560 ********************************************************************/
3562 BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3563 prs_struct *ps, int depth)
3565 if (r_u == NULL)
3566 return False;
3568 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3569 depth++;
3571 if(!prs_align(ps))
3572 return False;
3574 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3575 return False;
3576 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3577 return False;
3579 if (r_u->ptr != 0) {
3580 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3581 return False;
3584 if(!prs_align(ps))
3585 return False;
3586 if(!prs_uint32("status", ps, depth, &r_u->status))
3587 return False;
3589 return True;
3592 /*******************************************************************
3593 inits a SAMR_Q_OPEN_ALIAS structure.
3594 ********************************************************************/
3596 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3597 uint32 unknown_0, uint32 rid)
3599 DEBUG(5, ("init_samr_q_open_alias\n"));
3601 q_u->dom_pol = *pol;
3603 /* example values: 0x0000 0008 */
3604 q_u->unknown_0 = unknown_0;
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("unknown_0", ps, depth, &q_u->unknown_0))
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;
3684 /*******************************************************************
3685 reads or writes a structure.
3686 ********************************************************************/
3688 BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
3689 prs_struct *ps, int depth)
3691 uint32 i;
3692 fstring tmp;
3694 if (q_u == NULL)
3695 return False;
3697 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
3698 depth++;
3700 if (UNMARSHALLING(ps))
3701 ZERO_STRUCTP(q_u);
3703 if(!prs_align(ps))
3704 return False;
3706 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3707 return False;
3709 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
3710 return False;
3711 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
3712 return False;
3713 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3714 return False;
3715 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
3716 return False;
3718 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
3719 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
3720 if (q_u->rid == NULL)
3721 return False;
3724 for (i = 0; i < q_u->num_rids2; i++) {
3725 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
3726 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
3727 return False;
3730 return True;
3733 /*******************************************************************
3734 inits a SAMR_R_LOOKUP_RIDS structure.
3735 ********************************************************************/
3737 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
3738 uint32 num_names, UNIHDR * hdr_name,
3739 UNISTR2 *uni_name, uint32 *type)
3741 DEBUG(5, ("init_samr_r_lookup_rids\n"));
3743 r_u->hdr_name = NULL;
3744 r_u->uni_name = NULL;
3745 r_u->type = NULL;
3747 if (num_names != 0) {
3748 r_u->num_names1 = num_names;
3749 r_u->ptr_names = 1;
3750 r_u->num_names2 = num_names;
3752 r_u->num_types1 = num_names;
3753 r_u->ptr_types = 1;
3754 r_u->num_types2 = num_names;
3756 r_u->hdr_name = hdr_name;
3757 r_u->uni_name = uni_name;
3758 r_u->type = type;
3759 } else {
3760 r_u->num_names1 = num_names;
3761 r_u->ptr_names = 0;
3762 r_u->num_names2 = num_names;
3764 r_u->num_types1 = num_names;
3765 r_u->ptr_types = 0;
3766 r_u->num_types2 = num_names;
3770 /*******************************************************************
3771 reads or writes a structure.
3772 ********************************************************************/
3774 BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
3775 prs_struct *ps, int depth)
3777 uint32 i;
3778 fstring tmp;
3779 if (r_u == NULL)
3780 return False;
3782 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
3783 depth++;
3785 if(!prs_align(ps))
3786 return False;
3788 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
3789 return False;
3790 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
3791 return False;
3793 if (r_u->ptr_names != 0) {
3795 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
3796 return False;
3799 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
3800 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
3801 if (r_u->hdr_name == NULL)
3802 return False;
3804 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
3805 if (r_u->uni_name == NULL)
3806 return False;
3809 for (i = 0; i < r_u->num_names2; i++) {
3810 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
3811 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
3812 return False;
3814 for (i = 0; i < r_u->num_names2; i++) {
3815 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
3816 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
3817 return False;
3822 if(!prs_align(ps))
3823 return False;
3824 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
3825 return False;
3826 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
3827 return False;
3829 if (r_u->ptr_types != 0) {
3831 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
3832 return False;
3834 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
3835 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
3836 if (r_u->type == NULL)
3837 return False;
3840 for (i = 0; i < r_u->num_types2; i++) {
3841 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
3842 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
3843 return False;
3847 if(!prs_uint32("status", ps, depth, &r_u->status))
3848 return False;
3850 return True;
3853 /*******************************************************************
3854 inits a SAMR_Q_OPEN_ALIAS structure.
3855 ********************************************************************/
3857 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
3859 DEBUG(5, ("init_samr_q_delete_alias\n"));
3861 q_u->alias_pol = *hnd;
3864 /*******************************************************************
3865 reads or writes a structure.
3866 ********************************************************************/
3868 BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
3869 prs_struct *ps, int depth)
3871 if (q_u == NULL)
3872 return False;
3874 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
3875 depth++;
3877 if(!prs_align(ps))
3878 return False;
3880 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3881 return False;
3883 return True;
3886 /*******************************************************************
3887 reads or writes a structure.
3888 ********************************************************************/
3890 BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
3891 prs_struct *ps, int depth)
3893 if (r_u == NULL)
3894 return False;
3896 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
3897 depth++;
3899 if(!prs_align(ps))
3900 return False;
3902 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3903 return False;
3904 if(!prs_uint32("status", ps, depth, &r_u->status))
3905 return False;
3907 return True;
3910 /*******************************************************************
3911 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
3912 ********************************************************************/
3914 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
3915 POLICY_HND *hnd, char *acct_desc)
3917 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3919 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
3921 q_u->dom_pol = *hnd;
3923 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
3924 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
3926 q_u->access_mask = 0x001f000f;
3929 /*******************************************************************
3930 reads or writes a structure.
3931 ********************************************************************/
3933 BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
3934 prs_struct *ps, int depth)
3936 if (q_u == NULL)
3937 return False;
3939 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
3940 depth++;
3942 if(!prs_align(ps))
3943 return False;
3945 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
3946 return False;
3948 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
3949 return False;
3950 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
3951 q_u->hdr_acct_desc.buffer, ps, depth))
3952 return False;
3954 if(!prs_align(ps))
3955 return False;
3956 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3957 return False;
3959 return True;
3962 /*******************************************************************
3963 reads or writes a structure.
3964 ********************************************************************/
3966 BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
3967 prs_struct *ps, int depth)
3969 if (r_u == NULL)
3970 return False;
3972 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
3973 depth++;
3975 if(!prs_align(ps))
3976 return False;
3978 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
3979 return False;
3981 if(!prs_uint32("rid", ps, depth, &r_u->rid))
3982 return False;
3984 if(!prs_uint32("status", ps, depth, &r_u->status))
3985 return False;
3987 return True;
3990 /*******************************************************************
3991 inits a SAMR_Q_ADD_ALIASMEM structure.
3992 ********************************************************************/
3994 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
3995 DOM_SID *sid)
3997 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
3999 q_u->alias_pol = *hnd;
4000 init_dom_sid2(&q_u->sid, sid);
4003 /*******************************************************************
4004 reads or writes a structure.
4005 ********************************************************************/
4007 BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4008 prs_struct *ps, int depth)
4010 if (q_u == NULL)
4011 return False;
4013 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4014 depth++;
4016 if(!prs_align(ps))
4017 return False;
4019 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4020 return False;
4021 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4022 return False;
4024 return True;
4027 /*******************************************************************
4028 reads or writes a structure.
4029 ********************************************************************/
4031 BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4032 prs_struct *ps, int depth)
4034 if (r_u == NULL)
4035 return False;
4037 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4038 depth++;
4040 if(!prs_align(ps))
4041 return False;
4043 if(!prs_uint32("status", ps, depth, &r_u->status))
4044 return False;
4046 return True;
4049 /*******************************************************************
4050 inits a SAMR_Q_DEL_ALIASMEM structure.
4051 ********************************************************************/
4053 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4054 DOM_SID *sid)
4056 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4058 q_u->alias_pol = *hnd;
4059 init_dom_sid2(&q_u->sid, sid);
4062 /*******************************************************************
4063 reads or writes a structure.
4064 ********************************************************************/
4066 BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4067 prs_struct *ps, int depth)
4069 if (q_u == NULL)
4070 return False;
4072 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4073 depth++;
4075 if(!prs_align(ps))
4076 return False;
4078 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4079 return False;
4080 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4081 return False;
4083 return True;
4086 /*******************************************************************
4087 reads or writes a structure.
4088 ********************************************************************/
4090 BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4091 prs_struct *ps, int depth)
4093 if (r_u == NULL)
4094 return False;
4096 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4097 depth++;
4099 if(!prs_align(ps))
4100 return False;
4102 if(!prs_uint32("status", ps, depth, &r_u->status))
4103 return False;
4105 return True;
4108 /*******************************************************************
4109 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4110 ********************************************************************/
4112 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4113 POLICY_HND *hnd)
4115 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4117 q_c->alias_pol = *hnd;
4120 /*******************************************************************
4121 reads or writes a structure.
4122 ********************************************************************/
4124 BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4125 prs_struct *ps, int depth)
4127 if (q_u == NULL)
4128 return False;
4130 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4131 depth++;
4133 if(!prs_align(ps))
4134 return False;
4136 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4137 return False;
4139 return True;
4142 /*******************************************************************
4143 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4144 ********************************************************************/
4146 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4147 uint32 status)
4149 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4151 r_u->status = status;
4154 /*******************************************************************
4155 reads or writes a structure.
4156 ********************************************************************/
4158 BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4159 prs_struct *ps, int depth)
4161 if (r_u == NULL)
4162 return False;
4164 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4165 depth++;
4167 if(!prs_align(ps))
4168 return False;
4170 if(!prs_uint32("status", ps, depth, &r_u->status))
4171 return False;
4173 return True;
4176 /*******************************************************************
4177 inits a SAMR_Q_QUERY_ALIASMEM structure.
4178 ********************************************************************/
4180 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4181 POLICY_HND *hnd)
4183 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4185 q_c->alias_pol = *hnd;
4188 /*******************************************************************
4189 reads or writes a structure.
4190 ********************************************************************/
4192 BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4193 prs_struct *ps, int depth)
4195 if (q_u == NULL)
4196 return False;
4198 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4199 depth++;
4201 if(!prs_align(ps))
4202 return False;
4204 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4205 return False;
4207 return True;
4210 /*******************************************************************
4211 inits a SAMR_R_QUERY_ALIASMEM structure.
4212 ********************************************************************/
4214 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4215 uint32 num_sids, DOM_SID2 * sid,
4216 uint32 status)
4218 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4220 if (status == 0) {
4221 r_u->num_sids = num_sids;
4222 r_u->ptr = (num_sids != 0) ? 1 : 0;
4223 r_u->num_sids1 = num_sids;
4225 r_u->sid = sid;
4226 } else {
4227 r_u->ptr = 0;
4228 r_u->num_sids = 0;
4231 r_u->status = status;
4234 /*******************************************************************
4235 reads or writes a structure.
4236 ********************************************************************/
4238 BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4239 prs_struct *ps, int depth)
4241 uint32 i;
4242 uint32 ptr_sid[MAX_LOOKUP_SIDS];
4244 if (r_u == NULL)
4245 return False;
4247 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4248 depth++;
4250 if(!prs_align(ps))
4251 return False;
4253 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4254 return False;
4255 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4256 return False;
4258 if (r_u->ptr != 0) {
4259 SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids);
4261 if (r_u->num_sids != 0) {
4262 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4263 return False;
4265 for (i = 0; i < r_u->num_sids1; i++) {
4266 ptr_sid[i] = 1;
4267 if(!prs_uint32("", ps, depth, &ptr_sid[i]))
4268 return False;
4271 for (i = 0; i < r_u->num_sids1; i++) {
4272 if (ptr_sid[i] != 0) {
4273 if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth))
4274 return False;
4280 if(!prs_align(ps))
4281 return False;
4282 if(!prs_uint32("status", ps, depth, &r_u->status))
4283 return False;
4285 return True;
4288 /*******************************************************************
4289 inits a SAMR_Q_LOOKUP_NAMES structure.
4290 ********************************************************************/
4292 void init_samr_q_lookup_names(SAMR_Q_LOOKUP_NAMES * q_u,
4293 POLICY_HND *pol, uint32 flags,
4294 uint32 num_names, char **name)
4296 uint32 i;
4298 DEBUG(5, ("init_samr_q_lookup_names\n"));
4300 q_u->pol = *pol;
4302 q_u->num_names1 = num_names;
4303 q_u->flags = flags;
4304 q_u->ptr = 0;
4305 q_u->num_names2 = num_names;
4307 for (i = 0; i < num_names; i++) {
4308 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4309 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4310 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4314 /*******************************************************************
4315 reads or writes a structure.
4316 ********************************************************************/
4318 BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4319 prs_struct *ps, int depth)
4321 uint32 i;
4323 if (q_u == NULL)
4324 return False;
4326 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4327 depth++;
4329 if (UNMARSHALLING(ps))
4330 ZERO_STRUCTP(q_u);
4332 if(!prs_align(ps))
4333 return False;
4335 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4336 return False;
4338 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4339 return False;
4340 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4341 return False;
4342 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4343 return False;
4344 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4345 return False;
4347 SMB_ASSERT_ARRAY(q_u->hdr_name, q_u->num_names2);
4349 for (i = 0; i < q_u->num_names2; i++) {
4350 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4351 return False;
4354 for (i = 0; i < q_u->num_names2; i++) {
4355 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4356 return False;
4359 return True;
4362 /*******************************************************************
4363 inits a SAMR_R_LOOKUP_NAMES structure.
4364 ********************************************************************/
4366 void init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4367 uint32 num_rids,
4368 uint32 *rid, uint32 *type,
4369 uint32 status)
4371 DEBUG(5, ("init_samr_r_lookup_names\n"));
4373 if ((status == 0) && (num_rids != 0)) {
4374 uint32 i;
4376 r_u->num_types1 = num_rids;
4377 r_u->ptr_types = 1;
4378 r_u->num_types2 = num_rids;
4380 r_u->num_rids1 = num_rids;
4381 r_u->ptr_rids = 1;
4382 r_u->num_rids2 = num_rids;
4384 r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids);
4385 r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids);
4387 if (!r_u->rids || !r_u->types)
4388 goto empty;
4390 for (i = 0; i < num_rids; i++) {
4391 r_u->rids[i] = rid[i];
4392 r_u->types[i] = type[i];
4394 } else {
4396 empty:
4397 r_u->num_types1 = 0;
4398 r_u->ptr_types = 0;
4399 r_u->num_types2 = 0;
4401 r_u->num_rids1 = 0;
4402 r_u->ptr_rids = 0;
4403 r_u->num_rids2 = 0;
4405 r_u->rids = NULL;
4406 r_u->types = NULL;
4409 r_u->status = status;
4412 /*******************************************************************
4413 reads or writes a structure.
4414 ********************************************************************/
4416 BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4417 prs_struct *ps, int depth)
4419 uint32 i;
4420 fstring tmp;
4422 if (r_u == NULL)
4423 return False;
4425 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4426 depth++;
4428 if (UNMARSHALLING(ps))
4429 ZERO_STRUCTP(r_u);
4431 if(!prs_align(ps))
4432 return False;
4434 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4435 return False;
4436 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4437 return False;
4439 if (r_u->ptr_rids != 0) {
4440 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4441 return False;
4443 if (r_u->num_rids2 != r_u->num_rids1) {
4444 /* RPC fault */
4445 return False;
4448 if (UNMARSHALLING(ps))
4449 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4451 if (!r_u->rids) {
4452 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4453 return False;
4456 for (i = 0; i < r_u->num_rids2; i++) {
4457 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4458 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4459 return False;
4463 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4464 return False;
4465 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4466 return False;
4468 if (r_u->ptr_types != 0) {
4469 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4470 return False;
4472 if (r_u->num_types2 != r_u->num_types1) {
4473 /* RPC fault */
4474 return False;
4477 if (UNMARSHALLING(ps))
4478 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4480 if (!r_u->types) {
4481 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4482 return False;
4485 for (i = 0; i < r_u->num_types2; i++) {
4486 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4487 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4488 return False;
4492 if(!prs_uint32("status", ps, depth, &r_u->status))
4493 return False;
4495 return True;
4498 /*******************************************************************
4499 inits a SAMR_Q_DELETE_DOM_USER structure.
4500 ********************************************************************/
4502 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4503 POLICY_HND *hnd)
4505 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4507 q_c->user_pol = *hnd;
4510 /*******************************************************************
4511 reads or writes a structure.
4512 ********************************************************************/
4514 BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4515 prs_struct *ps, int depth)
4517 if (q_u == NULL)
4518 return False;
4520 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4521 depth++;
4523 if(!prs_align(ps))
4524 return False;
4526 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4527 return False;
4529 return True;
4532 /*******************************************************************
4533 reads or writes a structure.
4534 ********************************************************************/
4536 BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4537 prs_struct *ps, int depth)
4539 if (r_u == NULL)
4540 return False;
4542 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4543 depth++;
4545 if(!prs_align(ps))
4546 return False;
4548 if(!prs_uint32("status", ps, depth, &r_u->status))
4549 return False;
4551 return True;
4554 /*******************************************************************
4555 reads or writes a structure.
4556 ********************************************************************/
4558 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4559 POLICY_HND *pol,
4560 uint32 access_mask, uint32 rid)
4562 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4564 q_u->domain_pol = *pol;
4565 q_u->access_mask = access_mask;
4566 q_u->user_rid = rid;
4569 /*******************************************************************
4570 reads or writes a structure.
4571 ********************************************************************/
4573 BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
4574 prs_struct *ps, int depth)
4576 if (q_u == NULL)
4577 return False;
4579 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4580 depth++;
4582 if(!prs_align(ps))
4583 return False;
4585 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4586 return False;
4588 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4589 return False;
4590 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4591 return False;
4593 return True;
4596 /*******************************************************************
4597 reads or writes a structure.
4598 ********************************************************************/
4600 BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
4601 prs_struct *ps, int depth)
4603 if (r_u == NULL)
4604 return False;
4606 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4607 depth++;
4609 if(!prs_align(ps))
4610 return False;
4612 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4613 return False;
4615 if(!prs_uint32("status", ps, depth, &r_u->status))
4616 return False;
4618 return True;
4622 /*******************************************************************
4623 reads or writes a structure.
4624 ********************************************************************/
4626 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4627 POLICY_HND *pol,
4628 char *name,
4629 uint32 acb_info, uint32 access_mask)
4631 int len_name;
4632 len_name = strlen(name);
4634 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4636 q_u->domain_pol = *pol;
4638 init_uni_hdr(&q_u->hdr_name, len_name);
4639 init_unistr2(&q_u->uni_name, name, len_name);
4641 q_u->acb_info = acb_info;
4642 q_u->access_mask = access_mask;
4645 /*******************************************************************
4646 reads or writes a structure.
4647 ********************************************************************/
4649 BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
4650 prs_struct *ps, int depth)
4652 if (q_u == NULL)
4653 return False;
4655 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4656 depth++;
4658 if(!prs_align(ps))
4659 return False;
4661 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4662 return False;
4664 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
4665 return False;
4666 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
4667 return False;
4669 if(!prs_align(ps))
4670 return False;
4671 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
4672 return False;
4673 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4674 return False;
4676 return True;
4679 /*******************************************************************
4680 reads or writes a structure.
4681 ********************************************************************/
4683 BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
4684 prs_struct *ps, int depth)
4686 if (r_u == NULL)
4687 return False;
4689 prs_debug(ps, depth, desc, "samr_io_r_create_user");
4690 depth++;
4692 if(!prs_align(ps))
4693 return False;
4695 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4696 return False;
4698 if(!prs_uint32("unknown_0", ps, depth, &r_u->unknown_0))
4699 return False;
4700 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
4701 return False;
4702 if(!prs_uint32("status", ps, depth, &r_u->status))
4703 return False;
4705 return True;
4708 /*******************************************************************
4709 inits a SAMR_Q_QUERY_USERINFO structure.
4710 ********************************************************************/
4712 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
4713 POLICY_HND *hnd, uint16 switch_value)
4715 DEBUG(5, ("init_samr_q_query_userinfo\n"));
4717 q_u->pol = *hnd;
4718 q_u->switch_value = switch_value;
4721 /*******************************************************************
4722 reads or writes a structure.
4723 ********************************************************************/
4725 BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
4726 prs_struct *ps, int depth)
4728 if (q_u == NULL)
4729 return False;
4731 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
4732 depth++;
4734 if(!prs_align(ps))
4735 return False;
4737 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4738 return False;
4740 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
4741 return False;
4743 return True;
4746 /*******************************************************************
4747 reads or writes a LOGON_HRS structure.
4748 ********************************************************************/
4750 static BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs,
4751 prs_struct *ps, int depth)
4753 if (hrs == NULL)
4754 return False;
4756 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
4757 depth++;
4759 if(!prs_align(ps))
4760 return False;
4762 if(!prs_uint32("len ", ps, depth, &hrs->len))
4763 return False;
4765 if (hrs->len > sizeof(hrs->hours)) {
4766 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
4767 hrs->len = sizeof(hrs->hours);
4770 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
4771 return False;
4773 return True;
4776 /*******************************************************************
4777 inits a SAM_USER_INFO_12 structure.
4778 ********************************************************************/
4780 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
4781 uint8 lm_pwd[16], uint8 nt_pwd[16])
4783 DEBUG(5, ("init_sam_user_info12\n"));
4785 usr->lm_pwd_active =
4786 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
4787 usr->nt_pwd_active =
4788 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
4791 /*******************************************************************
4792 reads or writes a structure.
4793 ********************************************************************/
4795 static BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
4796 prs_struct *ps, int depth)
4798 if (u == NULL)
4799 return False;
4801 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
4802 depth++;
4804 if(!prs_align(ps))
4805 return False;
4807 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
4808 return False;
4809 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
4810 return False;
4812 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
4813 return False;
4814 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
4815 return False;
4817 return True;
4820 /*******************************************************************
4821 inits a SAM_USER_INFO_10 structure.
4822 ********************************************************************/
4824 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
4826 DEBUG(5, ("init_sam_user_info10\n"));
4828 usr->acb_info = acb_info;
4831 /*******************************************************************
4832 reads or writes a structure.
4833 ********************************************************************/
4835 static BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
4836 prs_struct *ps, int depth)
4838 if (usr == NULL)
4839 return False;
4841 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
4842 depth++;
4844 if(!prs_align(ps))
4845 return False;
4847 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
4848 return False;
4850 return True;
4853 /*******************************************************************
4854 inits a SAM_USER_INFO_11 structure.
4855 ********************************************************************/
4857 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
4858 NTTIME * expiry,
4859 char *mach_acct,
4860 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
4862 int len_mach_acct;
4864 DEBUG(5, ("init_sam_user_info11\n"));
4866 len_mach_acct = strlen(mach_acct);
4868 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
4869 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
4871 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
4872 usr->padding_2 = 0; /* 0 - padding 4 bytes */
4874 usr->ptr_1 = 1; /* pointer */
4875 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
4876 usr->padding_4 = 0; /* 0 - padding 4 bytes */
4878 usr->ptr_2 = 1; /* pointer */
4879 usr->padding_5 = 0; /* 0 - padding 4 bytes */
4881 usr->ptr_3 = 1; /* pointer */
4882 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
4884 usr->rid_user = rid_user;
4885 usr->rid_group = rid_group;
4887 usr->acct_ctrl = acct_ctrl;
4888 usr->unknown_3 = 0x0000;
4890 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
4891 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
4893 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
4894 usr->padding_8 = 0; /* 0 - padding 4 bytes */
4896 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
4899 /*******************************************************************
4900 reads or writes a structure.
4901 ********************************************************************/
4903 static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
4904 prs_struct *ps, int depth)
4906 if (usr == NULL)
4907 return False;
4909 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
4910 depth++;
4912 if(!prs_align(ps))
4913 return False;
4915 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
4916 return False;
4918 if(!smb_io_time("time", &usr->expiry, ps, depth))
4919 return False;
4921 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
4922 return False;
4924 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
4925 return False;
4927 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
4928 return False;
4930 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
4931 return False;
4932 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
4933 return False;
4935 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
4936 return False;
4938 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
4939 return False;
4940 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
4941 return False;
4943 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
4944 return False;
4945 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
4946 return False;
4948 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
4949 return False;
4950 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
4951 return False;
4952 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
4953 return False;
4954 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
4955 return False;
4956 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
4957 return False;
4958 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
4959 return False;
4961 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
4962 return False;
4964 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
4965 return False;
4967 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
4968 return False;
4970 if(!prs_align(ps))
4971 return False;
4973 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
4974 return False;
4976 return True;
4979 /*************************************************************************
4980 init_sam_user_infoa
4982 unknown_3 = 0x09f8 27fa
4983 unknown_5 = 0x0001 0000
4984 unknown_6 = 0x0000 04ec
4986 *************************************************************************/
4988 void init_sam_user_info24(SAM_USER_INFO_24 * usr,
4989 char newpass[516], uint16 passlen)
4991 DEBUG(10, ("init_sam_user_info24: passlen: %d\n", passlen));
4992 memcpy(usr->pass, newpass, sizeof(usr->pass));
4995 /*******************************************************************
4996 reads or writes a structure.
4997 ********************************************************************/
4999 static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
5000 prs_struct *ps, int depth)
5002 if (usr == NULL)
5003 return False;
5005 prs_debug(ps, depth, desc, "sam_io_user_info24");
5006 depth++;
5008 if(!prs_align(ps))
5009 return False;
5011 if(!prs_uint8s(False, "password", ps, depth, usr->pass, sizeof(usr->pass)))
5012 return False;
5014 return True;
5017 /*************************************************************************
5018 init_sam_user_info23
5020 unknown_3 = 0x09f8 27fa
5021 unknown_5 = 0x0001 0000
5022 unknown_6 = 0x0000 04ec
5024 *************************************************************************/
5026 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5027 NTTIME * logoff_time, /* all zeros */
5028 NTTIME * kickoff_time, /* all zeros */
5029 NTTIME * pass_last_set_time, /* all zeros */
5030 NTTIME * pass_can_change_time, /* all zeros */
5031 NTTIME * pass_must_change_time, /* all zeros */
5032 UNISTR2 *user_name,
5033 UNISTR2 *full_name,
5034 UNISTR2 *home_dir,
5035 UNISTR2 *dir_drive,
5036 UNISTR2 *log_scr,
5037 UNISTR2 *prof_path,
5038 UNISTR2 *desc,
5039 UNISTR2 *wkstas,
5040 UNISTR2 *unk_str,
5041 UNISTR2 *mung_dial,
5042 uint32 user_rid, /* 0x0000 0000 */
5043 uint32 group_rid,
5044 uint32 acb_info,
5045 uint32 unknown_3,
5046 uint16 logon_divs,
5047 LOGON_HRS * hrs,
5048 uint32 unknown_5,
5049 char newpass[516], uint32 unknown_6)
5051 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5052 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5053 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5054 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5055 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5056 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5057 int len_description = desc != NULL ? desc->uni_str_len : 0;
5058 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5059 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5060 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5062 usr->logon_time = *logon_time; /* all zeros */
5063 usr->logoff_time = *logoff_time; /* all zeros */
5064 usr->kickoff_time = *kickoff_time; /* all zeros */
5065 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5066 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5067 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5069 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5070 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5071 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5072 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5073 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5074 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5075 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5076 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5077 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5078 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5080 ZERO_STRUCT(usr->nt_pwd);
5081 ZERO_STRUCT(usr->lm_pwd);
5083 usr->user_rid = user_rid; /* 0x0000 0000 */
5084 usr->group_rid = group_rid;
5085 usr->acb_info = acb_info;
5086 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5088 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5089 usr->ptr_logon_hrs = hrs ? 1 : 0;
5091 ZERO_STRUCT(usr->padding1);
5093 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5095 memcpy(usr->pass, newpass, sizeof(usr->pass));
5097 copy_unistr2(&usr->uni_user_name, user_name);
5098 copy_unistr2(&usr->uni_full_name, full_name);
5099 copy_unistr2(&usr->uni_home_dir, home_dir);
5100 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5101 copy_unistr2(&usr->uni_logon_script, log_scr);
5102 copy_unistr2(&usr->uni_profile_path, prof_path);
5103 copy_unistr2(&usr->uni_acct_desc, desc);
5104 copy_unistr2(&usr->uni_workstations, wkstas);
5105 copy_unistr2(&usr->uni_unknown_str, unk_str);
5106 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5108 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5109 usr->padding4 = 0;
5111 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5114 /*************************************************************************
5115 init_sam_user_info23
5117 unknown_3 = 0x09f8 27fa
5118 unknown_5 = 0x0001 0000
5119 unknown_6 = 0x0000 04ec
5121 *************************************************************************/
5123 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5124 NTTIME * logoff_time, /* all zeros */
5125 NTTIME * kickoff_time, /* all zeros */
5126 NTTIME * pass_last_set_time, /* all zeros */
5127 NTTIME * pass_can_change_time, /* all zeros */
5128 NTTIME * pass_must_change_time, /* all zeros */
5129 char *user_name, /* NULL */
5130 char *full_name,
5131 char *home_dir, char *dir_drive, char *log_scr,
5132 char *prof_path, char *desc, char *wkstas,
5133 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5134 uint32 group_rid, uint32 acb_info,
5135 uint32 unknown_3, uint16 logon_divs,
5136 LOGON_HRS * hrs, uint32 unknown_5,
5137 char newpass[516], uint32 unknown_6)
5139 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5140 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5141 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5142 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5143 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5144 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5145 int len_description = desc != NULL ? strlen(desc) : 0;
5146 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5147 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5148 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5150 usr->logon_time = *logon_time; /* all zeros */
5151 usr->logoff_time = *logoff_time; /* all zeros */
5152 usr->kickoff_time = *kickoff_time; /* all zeros */
5153 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5154 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5155 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5157 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5158 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5159 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5160 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5161 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5162 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5163 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5164 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5165 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5166 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5168 ZERO_STRUCT(usr->nt_pwd);
5169 ZERO_STRUCT(usr->lm_pwd);
5171 usr->user_rid = user_rid; /* 0x0000 0000 */
5172 usr->group_rid = group_rid;
5173 usr->acb_info = acb_info;
5174 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5176 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5177 usr->ptr_logon_hrs = hrs ? 1 : 0;
5179 ZERO_STRUCT(usr->padding1);
5181 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5183 memcpy(usr->pass, newpass, sizeof(usr->pass));
5185 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5186 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5187 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5188 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5189 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5190 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5191 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5192 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5193 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5194 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5196 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5197 usr->padding4 = 0;
5199 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5202 /*******************************************************************
5203 reads or writes a structure.
5204 ********************************************************************/
5206 static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
5207 prs_struct *ps, int depth)
5209 if (usr == NULL)
5210 return False;
5212 prs_debug(ps, depth, desc, "sam_io_user_info23");
5213 depth++;
5215 if(!prs_align(ps))
5216 return False;
5218 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5219 return False;
5220 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5221 return False;
5222 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5223 return False;
5224 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5225 return False;
5226 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5227 return False;
5228 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5229 return False;
5231 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5232 return False;
5233 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5234 return False;
5235 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5236 return False;
5237 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5238 return False;
5239 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5240 return False;
5241 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5242 return False;
5243 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5244 return False;
5245 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5246 return False;
5247 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5248 return False;
5249 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5250 return False;
5252 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5253 return False;
5254 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5255 return False;
5257 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5258 return False;
5259 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5260 return False;
5261 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5262 return False;
5264 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5265 return False;
5266 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5267 return False;
5268 if(!prs_align(ps))
5269 return False;
5270 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5271 return False;
5272 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5273 return False;
5274 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5275 return False;
5277 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5278 return False;
5280 /* here begins pointed-to data */
5282 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5283 return False;
5285 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5286 return False;
5288 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5289 return False;
5291 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5292 return False;
5294 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5295 return False;
5297 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5298 return False;
5300 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5301 return False;
5303 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5304 return False;
5306 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5307 return False;
5309 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5310 return False;
5312 /* ok, this is only guess-work (as usual) */
5313 if (usr->ptr_logon_hrs) {
5314 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5315 return False;
5316 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5317 return False;
5318 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5319 return False;
5320 } else if (UNMARSHALLING(ps)) {
5321 usr->unknown_6 = 0;
5322 usr->padding4 = 0;
5325 return True;
5329 /*************************************************************************
5330 init_sam_user_info21W
5332 unknown_3 = 0x00ff ffff
5333 unknown_5 = 0x0002 0000
5334 unknown_6 = 0x0000 04ec
5336 *************************************************************************/
5338 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5339 NTTIME * logon_time,
5340 NTTIME * logoff_time,
5341 NTTIME * kickoff_time,
5342 NTTIME * pass_last_set_time,
5343 NTTIME * pass_can_change_time,
5344 NTTIME * pass_must_change_time,
5345 UNISTR2 *user_name,
5346 UNISTR2 *full_name,
5347 UNISTR2 *home_dir,
5348 UNISTR2 *dir_drive,
5349 UNISTR2 *log_scr,
5350 UNISTR2 *prof_path,
5351 UNISTR2 *desc,
5352 UNISTR2 *wkstas,
5353 UNISTR2 *unk_str,
5354 UNISTR2 *mung_dial,
5355 uchar lm_pwd[16],
5356 uchar nt_pwd[16],
5357 uint32 user_rid,
5358 uint32 group_rid,
5359 uint32 acb_info,
5360 uint32 unknown_3,
5361 uint16 logon_divs,
5362 LOGON_HRS * hrs,
5363 uint32 unknown_5, uint32 unknown_6)
5365 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5366 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5367 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5368 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5369 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5370 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5371 int len_description = desc != NULL ? desc->uni_str_len : 0;
5372 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5373 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5374 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5376 usr->logon_time = *logon_time;
5377 usr->logoff_time = *logoff_time;
5378 usr->kickoff_time = *kickoff_time;
5379 usr->pass_last_set_time = *pass_last_set_time;
5380 usr->pass_can_change_time = *pass_can_change_time;
5381 usr->pass_must_change_time = *pass_must_change_time;
5383 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5384 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5385 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5386 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5387 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5388 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5389 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5390 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5391 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5392 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5394 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5395 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5397 usr->user_rid = user_rid;
5398 usr->group_rid = group_rid;
5399 usr->acb_info = acb_info;
5400 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5402 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5403 usr->ptr_logon_hrs = hrs ? 1 : 0;
5404 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5406 ZERO_STRUCT(usr->padding1);
5408 copy_unistr2(&usr->uni_user_name, user_name);
5409 copy_unistr2(&usr->uni_full_name, full_name);
5410 copy_unistr2(&usr->uni_home_dir, home_dir);
5411 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5412 copy_unistr2(&usr->uni_logon_script, log_scr);
5413 copy_unistr2(&usr->uni_profile_path, prof_path);
5414 copy_unistr2(&usr->uni_acct_desc, desc);
5415 copy_unistr2(&usr->uni_workstations, wkstas);
5416 copy_unistr2(&usr->uni_unknown_str, unk_str);
5417 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5419 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5420 usr->padding4 = 0;
5422 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5425 /*************************************************************************
5426 init_sam_user_info21
5428 unknown_3 = 0x00ff ffff
5429 unknown_5 = 0x0002 0000
5430 unknown_6 = 0x0000 04ec
5432 *************************************************************************/
5434 void init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw)
5436 NTTIME logon_time, logoff_time, kickoff_time,
5437 pass_last_set_time, pass_can_change_time,
5438 pass_must_change_time;
5440 int len_user_name, len_full_name, len_home_dir,
5441 len_dir_drive, len_logon_script, len_profile_path,
5442 len_description, len_workstations, len_unknown_str,
5443 len_munged_dial;
5445 char* user_name = pdb_get_username(pw);
5446 char* full_name = pdb_get_fullname(pw);
5447 char* home_dir = pdb_get_homedir(pw);
5448 char* dir_drive = pdb_get_dirdrive(pw);
5449 char* logon_script = pdb_get_logon_script(pw);
5450 char* profile_path = pdb_get_profile_path(pw);
5451 char* description = pdb_get_acct_desc(pw);
5452 char* workstations = pdb_get_workstations(pw);
5453 char* munged_dial = pdb_get_munged_dial(pw);
5455 len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
5456 len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
5457 len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
5458 len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
5459 len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
5460 len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
5461 len_description = description != NULL ? strlen(description )+1 : 0;
5462 len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
5463 len_unknown_str = 0;
5464 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
5467 /* Create NTTIME structs */
5468 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5469 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5470 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5471 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5472 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
5473 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
5475 /* structure assignment */
5476 usr->logon_time = logon_time;
5477 usr->logoff_time = logoff_time;
5478 usr->kickoff_time = kickoff_time;
5479 usr->pass_last_set_time = pass_last_set_time;
5480 usr->pass_can_change_time = pass_can_change_time;
5481 usr->pass_must_change_time = pass_must_change_time;
5483 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5484 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5485 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5486 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5487 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5488 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5489 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5490 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5491 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5492 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5494 ZERO_STRUCT(usr->nt_pwd);
5495 ZERO_STRUCT(usr->lm_pwd);
5497 usr->user_rid = pdb_get_user_rid(pw);
5498 usr->group_rid = pdb_get_group_rid(pw);
5499 usr->acb_info = pdb_get_acct_ctrl(pw);
5500 usr->unknown_3 = pdb_get_unknown3(pw);
5502 usr->logon_divs = pdb_get_logon_divs(pw);
5503 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
5504 usr->unknown_5 = pdb_get_unknown5(pw); /* 0x0002 0000 */
5506 ZERO_STRUCT(usr->padding1);
5508 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
5509 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5510 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5511 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5512 init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
5513 init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
5514 init_unistr2(&usr->uni_acct_desc, description, len_description);
5515 init_unistr2(&usr->uni_workstations, workstations, len_workstations);
5516 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
5517 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
5519 usr->unknown_6 = pdb_get_unknown6(pw);
5520 usr->padding4 = 0;
5522 if (pdb_get_hours(pw)) {
5523 usr->logon_hrs.len = pdb_get_hours_len(pw);
5524 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
5525 } else
5526 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
5529 /*******************************************************************
5530 reads or writes a structure.
5531 ********************************************************************/
5533 static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
5534 prs_struct *ps, int depth)
5536 if (usr == NULL)
5537 return False;
5539 prs_debug(ps, depth, desc, "sam_io_user_info21");
5540 depth++;
5542 if(!prs_align(ps))
5543 return False;
5545 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5546 return False;
5547 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5548 return False;
5549 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
5550 return False;
5551 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5552 return False;
5553 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
5554 return False;
5555 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5556 return False;
5558 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5559 return False;
5560 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5561 return False;
5562 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5563 return False;
5564 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5565 return False;
5566 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5567 return False;
5568 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5569 return False;
5570 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5571 return False;
5572 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5573 return False;
5574 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5575 return False;
5576 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5577 return False;
5579 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5580 return False;
5581 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5582 return False;
5584 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5585 return False;
5586 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5587 return False;
5588 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5589 return False;
5591 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5592 return False;
5593 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5594 return False;
5595 if(!prs_align(ps))
5596 return False;
5597 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5598 return False;
5599 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5600 return False;
5602 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5603 return False;
5605 /* here begins pointed-to data */
5607 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5608 return False;
5609 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5610 return False;
5611 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5612 return False;
5613 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5614 return False;
5615 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5616 return False;
5617 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5618 return False;
5619 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5620 return False;
5621 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5622 return False;
5623 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5624 return False;
5625 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
5626 return False;
5628 /* ok, this is only guess-work (as usual) */
5629 if (usr->ptr_logon_hrs) {
5630 if(!prs_align(ps))
5631 return False;
5632 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5633 return False;
5634 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5635 return False;
5636 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5637 return False;
5638 } else if (UNMARSHALLING(ps)) {
5639 usr->unknown_6 = 0;
5640 usr->padding4 = 0;
5643 return True;
5646 /*******************************************************************
5647 inits a SAM_USERINFO_CTR structure.
5648 ********************************************************************/
5650 uint32 make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
5651 uint16 switch_value,
5652 SAM_USER_INFO_21 * usr)
5654 DEBUG(5, ("init_samr_userinfo_ctr\n"));
5656 ctr->switch_value = switch_value;
5657 ctr->info.id = NULL;
5659 switch (switch_value) {
5660 case 0x10:
5661 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
5662 if (ctr->info.id10 == NULL)
5663 return NT_STATUS_NO_MEMORY;
5665 init_sam_user_info10(ctr->info.id10, usr->acb_info);
5666 break;
5667 #if 0
5668 /* whoops - got this wrong. i think. or don't understand what's happening. */
5669 case 0x11:
5671 NTTIME expire;
5672 info = (void *)&id11;
5674 expire.low = 0xffffffff;
5675 expire.high = 0x7fffffff;
5677 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
5678 init_sam_user_info11(ctr->info.id11, &expire,
5679 "BROOKFIELDS$", /* name */
5680 0x03ef, /* user rid */
5681 0x201, /* group rid */
5682 0x0080); /* acb info */
5684 break;
5686 #endif
5687 case 0x12:
5688 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
5689 if (ctr->info.id12 == NULL)
5690 return NT_STATUS_NO_MEMORY;
5692 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
5693 break;
5694 case 21:
5696 SAM_USER_INFO_21 *cusr;
5697 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
5698 ctr->info.id21 = cusr;
5699 if (ctr->info.id21 == NULL)
5700 return NT_STATUS_NO_MEMORY;
5701 memcpy(cusr, usr, sizeof(*usr));
5702 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
5703 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
5704 break;
5706 default:
5707 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
5708 return NT_STATUS_INVALID_INFO_CLASS;
5711 return NT_STATUS_NOPROBLEMO;
5714 /*******************************************************************
5715 inits a SAM_USERINFO_CTR structure.
5716 ********************************************************************/
5718 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
5719 uint16 switch_value, void *info)
5721 DEBUG(5, ("init_samr_userinfo_ctr\n"));
5723 ctr->switch_value = switch_value;
5724 ctr->info.id = info;
5726 switch (switch_value) {
5727 case 0x18:
5728 SamOEMhash(ctr->info.id24->pass, sess_key, 1);
5729 dump_data(100, (char *)sess_key, 16);
5730 dump_data(100, (char *)ctr->info.id24->pass, 516);
5731 break;
5732 case 0x17:
5733 SamOEMhash(ctr->info.id23->pass, sess_key, 1);
5734 dump_data(100, (char *)sess_key, 16);
5735 dump_data(100, (char *)ctr->info.id23->pass, 516);
5736 break;
5737 default:
5738 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
5742 /*******************************************************************
5743 reads or writes a structure.
5744 ********************************************************************/
5746 static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR **ppctr,
5747 prs_struct *ps, int depth)
5749 BOOL ret;
5750 SAM_USERINFO_CTR *ctr;
5752 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
5753 depth++;
5755 if (UNMARSHALLING(ps)) {
5756 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
5757 if (ctr == NULL)
5758 return False;
5759 *ppctr = ctr;
5760 } else {
5761 ctr = *ppctr;
5764 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
5766 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
5767 return False;
5768 if(!prs_align(ps))
5769 return False;
5771 ret = False;
5773 switch (ctr->switch_value) {
5774 case 0x10:
5775 if (UNMARSHALLING(ps))
5776 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
5777 if (ctr->info.id10 == NULL) {
5778 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5779 return False;
5781 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
5782 break;
5783 case 0x11:
5784 if (UNMARSHALLING(ps))
5785 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
5787 if (ctr->info.id11 == NULL) {
5788 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5789 return False;
5791 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
5792 break;
5793 case 0x12:
5794 if (UNMARSHALLING(ps))
5795 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
5797 if (ctr->info.id12 == NULL) {
5798 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5799 return False;
5801 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
5802 break;
5803 case 21:
5804 if (UNMARSHALLING(ps))
5805 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
5807 if (ctr->info.id21 == NULL) {
5808 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5809 return False;
5811 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
5812 break;
5813 case 23:
5814 if (UNMARSHALLING(ps))
5815 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
5817 if (ctr->info.id23 == NULL) {
5818 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5819 return False;
5821 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
5822 break;
5823 case 24:
5824 if (UNMARSHALLING(ps))
5825 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
5827 if (ctr->info.id24 == NULL) {
5828 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5829 return False;
5831 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
5832 break;
5833 default:
5834 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
5835 ret = False;
5836 break;
5839 return ret;
5842 /*******************************************************************
5843 inits a SAMR_R_QUERY_USERINFO structure.
5844 ********************************************************************/
5846 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
5847 SAM_USERINFO_CTR * ctr, uint32 status)
5849 DEBUG(5, ("init_samr_r_query_userinfo\n"));
5851 r_u->ptr = 0;
5852 r_u->ctr = NULL;
5854 if (status == 0) {
5855 r_u->ptr = 1;
5856 r_u->ctr = ctr;
5859 r_u->status = status; /* return status */
5862 /*******************************************************************
5863 reads or writes a structure.
5864 ********************************************************************/
5866 BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
5867 prs_struct *ps, int depth)
5869 if (r_u == NULL)
5870 return False;
5872 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
5873 depth++;
5875 if(!prs_align(ps))
5876 return False;
5878 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
5879 return False;
5881 if (r_u->ptr != 0) {
5882 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
5883 return False;
5886 if(!prs_align(ps))
5887 return False;
5888 if(!prs_uint32("status", ps, depth, &r_u->status))
5889 return False;
5891 return True;
5894 /*******************************************************************
5895 inits a SAMR_Q_SET_USERINFO structure.
5896 ********************************************************************/
5898 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
5899 POLICY_HND *hnd, unsigned char sess_key[16],
5900 uint16 switch_value, void *info)
5902 DEBUG(5, ("init_samr_q_set_userinfo\n"));
5904 q_u->pol = *hnd;
5905 q_u->switch_value = switch_value;
5906 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
5909 /*******************************************************************
5910 reads or writes a structure.
5911 ********************************************************************/
5913 BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
5914 prs_struct *ps, int depth)
5916 if (q_u == NULL)
5917 return False;
5919 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
5920 depth++;
5922 if(!prs_align(ps))
5923 return False;
5925 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
5927 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
5928 return False;
5929 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
5930 return False;
5932 return True;
5935 /*******************************************************************
5936 inits a SAMR_R_SET_USERINFO structure.
5937 ********************************************************************/
5939 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, uint32 status)
5941 DEBUG(5, ("init_samr_r_set_userinfo\n"));
5943 r_u->status = status; /* return status */
5946 /*******************************************************************
5947 reads or writes a structure.
5948 ********************************************************************/
5950 BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
5951 prs_struct *ps, int depth)
5953 if (r_u == NULL)
5954 return False;
5956 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
5957 depth++;
5959 if(!prs_align(ps))
5960 return False;
5962 if(!prs_uint32("status", ps, depth, &r_u->status))
5963 return False;
5965 return True;
5968 /*******************************************************************
5969 inits a SAMR_Q_SET_USERINFO2 structure.
5970 ********************************************************************/
5972 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
5973 POLICY_HND *hnd, unsigned char sess_key[16],
5974 uint16 switch_value, SAM_USERINFO_CTR * ctr)
5976 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
5978 q_u->pol = *hnd;
5979 q_u->switch_value = switch_value;
5980 q_u->ctr = ctr;
5982 if (q_u->ctr != NULL)
5983 q_u->ctr->switch_value = switch_value;
5985 switch (switch_value) {
5986 case 0x12:
5987 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 0);
5988 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 0);
5989 dump_data(100, (char *)sess_key, 16);
5990 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
5991 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
5992 break;
5996 /*******************************************************************
5997 reads or writes a structure.
5998 ********************************************************************/
6000 BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6001 prs_struct *ps, int depth)
6003 if (q_u == NULL)
6004 return False;
6006 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6007 depth++;
6009 if(!prs_align(ps))
6010 return False;
6012 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6013 return False;
6015 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6016 return False;
6017 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6018 return False;
6020 return True;
6023 /*******************************************************************
6024 inits a SAMR_R_SET_USERINFO2 structure.
6025 ********************************************************************/
6027 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, uint32 status)
6029 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6031 r_u->status = status; /* return status */
6034 /*******************************************************************
6035 reads or writes a structure.
6036 ********************************************************************/
6038 BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
6039 prs_struct *ps, int depth)
6041 if (r_u == NULL)
6042 return False;
6044 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6045 depth++;
6047 if(!prs_align(ps))
6048 return False;
6050 if(!prs_uint32("status", ps, depth, &r_u->status))
6051 return False;
6053 return True;
6056 /*******************************************************************
6057 inits a SAMR_Q_CONNECT structure.
6058 ********************************************************************/
6060 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6061 char *srv_name, uint32 access_mask)
6063 int len_srv_name = strlen(srv_name);
6065 DEBUG(5, ("init_samr_q_connect\n"));
6067 /* make PDC server name \\server */
6068 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6069 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6071 /* example values: 0x0000 0002 */
6072 q_u->access_mask = access_mask;
6075 /*******************************************************************
6076 reads or writes a structure.
6077 ********************************************************************/
6079 BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
6080 prs_struct *ps, int depth)
6082 if (q_u == NULL)
6083 return False;
6085 prs_debug(ps, depth, desc, "samr_io_q_connect");
6086 depth++;
6088 if(!prs_align(ps))
6089 return False;
6091 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6092 return False;
6093 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6094 return False;
6096 if(!prs_align(ps))
6097 return False;
6098 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6099 return False;
6101 return True;
6104 /*******************************************************************
6105 reads or writes a structure.
6106 ********************************************************************/
6108 BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
6109 prs_struct *ps, int depth)
6111 if (r_u == NULL)
6112 return False;
6114 prs_debug(ps, depth, desc, "samr_io_r_connect");
6115 depth++;
6117 if(!prs_align(ps))
6118 return False;
6120 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6121 return False;
6123 if(!prs_uint32("status", ps, depth, &r_u->status))
6124 return False;
6126 return True;
6129 /*******************************************************************
6130 inits a SAMR_Q_CONNECT_ANON structure.
6131 ********************************************************************/
6133 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6135 DEBUG(5, ("init_samr_q_connect_anon\n"));
6137 q_u->ptr = 1;
6138 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6139 q_u->unknown_1 = 0x01;
6140 q_u->access_mask = 0x20;
6143 /*******************************************************************
6144 reads or writes a structure.
6145 ********************************************************************/
6147 BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
6148 prs_struct *ps, int depth)
6150 if (q_u == NULL)
6151 return False;
6153 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6154 depth++;
6156 if(!prs_align(ps))
6157 return False;
6159 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6160 return False;
6161 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6162 return False;
6163 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6164 return False;
6165 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6166 return False;
6168 return True;
6171 /*******************************************************************
6172 reads or writes a structure.
6173 ********************************************************************/
6175 BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
6176 prs_struct *ps, int depth)
6178 if (r_u == NULL)
6179 return False;
6181 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6182 depth++;
6184 if(!prs_align(ps))
6185 return False;
6187 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6188 return False;
6190 if(!prs_uint32("status", ps, depth, &r_u->status))
6191 return False;
6193 return True;
6196 /*******************************************************************
6197 inits a SAMR_Q_GET_DOM_PWINFO structure.
6198 ********************************************************************/
6200 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6201 char *srv_name)
6203 int len_srv_name = strlen(srv_name);
6205 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6207 q_u->ptr = 1;
6208 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6209 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6212 /*******************************************************************
6213 reads or writes a structure.
6214 ********************************************************************/
6216 BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6217 prs_struct *ps, int depth)
6219 if (q_u == NULL)
6220 return False;
6222 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6223 depth++;
6225 if(!prs_align(ps))
6226 return False;
6228 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6229 return False;
6230 if (q_u->ptr != 0) {
6231 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6232 return False;
6233 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6234 return False;
6237 return True;
6240 /*******************************************************************
6241 reads or writes a structure.
6242 ********************************************************************/
6244 BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6245 prs_struct *ps, int depth)
6247 if (r_u == NULL)
6248 return False;
6250 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6251 depth++;
6253 if(!prs_align(ps))
6254 return False;
6256 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
6257 return False;
6258 if(!prs_align(ps))
6259 return False;
6260 if(!prs_uint16("unk_1", ps, depth, &r_u->unk_1))
6261 return False;
6262 if(!prs_align(ps))
6263 return False;
6264 if(!prs_uint16("unk_2", ps, depth, &r_u->unk_2))
6265 return False;
6266 if(!prs_align(ps))
6267 return False;
6269 if(!prs_uint32("status", ps, depth, &r_u->status))
6270 return False;
6272 return True;
6275 /*******************************************************************
6276 make a SAMR_ENC_PASSWD structure.
6277 ********************************************************************/
6279 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
6281 ZERO_STRUCTP(pwd);
6283 if (pass == NULL) {
6284 pwd->ptr = 0;
6285 } else {
6286 pwd->ptr = 1;
6287 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6291 /*******************************************************************
6292 reads or writes a SAMR_ENC_PASSWD structure.
6293 ********************************************************************/
6295 BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
6296 prs_struct *ps, int depth)
6298 if (pwd == NULL)
6299 return False;
6301 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6302 depth++;
6304 if(!prs_align(ps))
6305 return False;
6307 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
6308 return False;
6310 if (pwd->ptr != 0) {
6311 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
6312 return False;
6315 return True;
6318 /*******************************************************************
6319 inits a SAMR_ENC_HASH structure.
6320 ********************************************************************/
6322 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
6324 ZERO_STRUCTP(hsh);
6326 if (hash == NULL) {
6327 hsh->ptr = 0;
6328 } else {
6329 hsh->ptr = 1;
6330 memcpy(hsh->hash, hash, sizeof(hsh->hash));
6334 /*******************************************************************
6335 reads or writes a SAMR_ENC_HASH structure.
6336 ********************************************************************/
6338 BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
6339 prs_struct *ps, int depth)
6341 if (hsh == NULL)
6342 return False;
6344 prs_debug(ps, depth, desc, "samr_io_enc_hash");
6345 depth++;
6347 if(!prs_align(ps))
6348 return False;
6350 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
6351 return False;
6352 if (hsh->ptr != 0) {
6353 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
6354 return False;
6357 return True;
6360 /*******************************************************************
6361 inits a SAMR_R_GET_DOM_PWINFO structure.
6362 ********************************************************************/
6364 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
6365 char *dest_host, char *user_name,
6366 char nt_newpass[516],
6367 uchar nt_oldhash[16],
6368 char lm_newpass[516],
6369 uchar lm_oldhash[16])
6371 int len_dest_host = strlen(dest_host);
6372 int len_user_name = strlen(user_name);
6374 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
6376 q_u->ptr_0 = 1;
6377 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
6378 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
6379 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
6380 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
6382 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
6383 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
6385 q_u->unknown = 0x01;
6387 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
6388 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
6391 /*******************************************************************
6392 reads or writes a structure.
6393 ********************************************************************/
6395 BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
6396 prs_struct *ps, int depth)
6398 if (q_u == NULL)
6399 return False;
6401 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
6402 depth++;
6404 if(!prs_align(ps))
6405 return False;
6407 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
6408 return False;
6410 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
6411 return False;
6412 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
6413 return False;
6415 if(!prs_align(ps))
6416 return False;
6417 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
6418 return False;
6419 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
6420 return False;
6422 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
6423 return False;
6424 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
6425 return False;
6427 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
6428 return False;
6430 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
6431 return False;
6432 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
6433 return False;
6435 return True;
6438 /*******************************************************************
6439 inits a SAMR_R_CHGPASSWD_USER structure.
6440 ********************************************************************/
6442 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, uint32 status)
6444 DEBUG(5, ("init_r_chgpasswd_user\n"));
6446 r_u->status = status;
6449 /*******************************************************************
6450 reads or writes a structure.
6451 ********************************************************************/
6453 BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
6454 prs_struct *ps, int depth)
6456 if (r_u == NULL)
6457 return False;
6459 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
6460 depth++;
6462 if(!prs_align(ps))
6463 return False;
6465 if(!prs_uint32("status", ps, depth, &r_u->status))
6466 return False;
6468 return True;