add WITH_SENDFILE profiling data (from Pierre Belanger)
[Samba.git] / source / rpc_parse / parse_samr.c
blob355e10a97bf90cb5b2ba64845991584c4805d614
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
10 * Copyright (C) Jean François Micouleau 1998-2001.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "includes.h"
28 #include "rpc_parse.h"
29 #include "nterr.h"
31 /*******************************************************************
32 inits a SAMR_Q_CLOSE_HND structure.
33 ********************************************************************/
35 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
37 DEBUG(5, ("init_samr_q_close_hnd\n"));
39 q_c->pol = *hnd;
42 /*******************************************************************
43 reads or writes a structure.
44 ********************************************************************/
46 BOOL samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND * q_u,
47 prs_struct *ps, int depth)
49 if (q_u == NULL)
50 return False;
52 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
53 depth++;
55 if(!prs_align(ps))
56 return False;
58 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
61 /*******************************************************************
62 reads or writes a structure.
63 ********************************************************************/
65 BOOL samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND * r_u,
66 prs_struct *ps, int depth)
68 if (r_u == NULL)
69 return False;
71 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
72 depth++;
74 if(!prs_align(ps))
75 return False;
77 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
78 return False;
80 if(!prs_ntstatus("status", ps, depth, &r_u->status))
81 return False;
83 return True;
86 /*******************************************************************
87 inits a SAMR_Q_LOOKUP_DOMAIN structure.
88 ********************************************************************/
90 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
91 POLICY_HND *pol, char *dom_name)
93 int len_name = strlen(dom_name);
95 DEBUG(5, ("init_samr_q_lookup_domain\n"));
97 q_u->connect_pol = *pol;
99 init_uni_hdr(&q_u->hdr_domain, len_name);
100 init_unistr2(&q_u->uni_domain, dom_name, len_name);
103 /*******************************************************************
104 reads or writes a structure.
105 ********************************************************************/
106 BOOL samr_io_q_lookup_domain(char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
107 prs_struct *ps, int depth)
109 if (q_u == NULL)
110 return False;
112 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
113 depth++;
115 if(!prs_align(ps))
116 return False;
118 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
119 return False;
121 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
122 return False;
124 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
125 return False;
127 return True;
130 /*******************************************************************
131 inits a SAMR_R_LOOKUP_DOMAIN structure.
132 ********************************************************************/
134 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
135 DOM_SID *dom_sid, NTSTATUS status)
137 DEBUG(5, ("init_samr_r_lookup_domain\n"));
139 r_u->status = status;
140 r_u->ptr_sid = 0;
141 if (NT_STATUS_IS_OK(status)) {
142 r_u->ptr_sid = 1;
143 init_dom_sid2(&r_u->dom_sid, dom_sid);
147 /*******************************************************************
148 reads or writes a structure.
149 ********************************************************************/
151 BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
152 prs_struct *ps, int depth)
154 if (r_u == NULL)
155 return False;
157 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
158 depth++;
160 if(!prs_align(ps))
161 return False;
163 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
164 return False;
166 if (r_u->ptr_sid != 0) {
167 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
168 return False;
169 if(!prs_align(ps))
170 return False;
173 if(!prs_ntstatus("status", ps, depth, &r_u->status))
174 return False;
176 return True;
179 /*******************************************************************
180 reads or writes a structure.
181 ********************************************************************/
183 void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
185 DEBUG(5, ("samr_init_samr_q_unknown_2d\n"));
187 q_u->dom_pol = *dom_pol;
188 init_dom_sid2(&q_u->sid, sid);
191 /*******************************************************************
192 reads or writes a structure.
193 ********************************************************************/
195 BOOL samr_io_q_unknown_2d(char *desc, SAMR_Q_UNKNOWN_2D * q_u,
196 prs_struct *ps, int depth)
198 if (q_u == NULL)
199 return False;
201 prs_debug(ps, depth, desc, "samr_io_q_unknown_2d");
202 depth++;
204 if(!prs_align(ps))
205 return False;
207 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
208 return False;
210 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
211 return False;
213 if(!prs_align(ps))
214 return False;
216 return True;
219 /*******************************************************************
220 reads or writes a structure.
221 ********************************************************************/
223 BOOL samr_io_r_unknown_2d(char *desc, SAMR_R_UNKNOWN_2D * r_u,
224 prs_struct *ps, int depth)
226 if (r_u == NULL)
227 return False;
229 prs_debug(ps, depth, desc, "samr_io_r_unknown_2d");
230 depth++;
232 if(!prs_align(ps))
233 return False;
235 if(!prs_ntstatus("status", ps, depth, &r_u->status))
236 return False;
238 return True;
241 /*******************************************************************
242 reads or writes a structure.
243 ********************************************************************/
245 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
246 POLICY_HND *pol, uint32 flags,
247 const DOM_SID *sid)
249 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
251 q_u->pol = *pol;
252 q_u->flags = flags;
253 init_dom_sid2(&q_u->dom_sid, sid);
256 /*******************************************************************
257 reads or writes a structure.
258 ********************************************************************/
260 BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
261 prs_struct *ps, int depth)
263 if (q_u == NULL)
264 return False;
266 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
267 depth++;
269 if(!prs_align(ps))
270 return False;
272 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
273 return False;
275 if(!prs_uint32("flags", ps, depth, &q_u->flags))
276 return False;
278 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
279 return False;
281 return True;
284 /*******************************************************************
285 reads or writes a structure.
286 ********************************************************************/
288 BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN * r_u,
289 prs_struct *ps, int depth)
291 if (r_u == NULL)
292 return False;
294 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
295 depth++;
297 if(!prs_align(ps))
298 return False;
300 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
301 return False;
303 if(!prs_ntstatus("status", ps, depth, &r_u->status))
304 return False;
306 return True;
309 /*******************************************************************
310 reads or writes a structure.
311 ********************************************************************/
313 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
314 POLICY_HND *user_pol)
316 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
318 q_u->user_pol = *user_pol;
321 /*******************************************************************
322 reads or writes a structure.
323 ********************************************************************/
325 BOOL samr_io_q_get_usrdom_pwinfo(char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
326 prs_struct *ps, int depth)
328 if (q_u == NULL)
329 return False;
331 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
332 depth++;
334 if(!prs_align(ps))
335 return False;
337 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
340 /*******************************************************************
341 Init.
342 ********************************************************************/
344 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
346 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
348 r_u->unknown_0 = 0x0000;
351 * used to be
352 * r_u->unknown_1 = 0x0015;
353 * but for trusts.
355 r_u->unknown_1 = 0x01D1;
356 r_u->unknown_1 = 0x0015;
358 r_u->unknown_2 = 0x00000000;
360 r_u->status = status;
363 /*******************************************************************
364 reads or writes a structure.
365 ********************************************************************/
367 BOOL samr_io_r_get_usrdom_pwinfo(char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
368 prs_struct *ps, int depth)
370 if (r_u == NULL)
371 return False;
373 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
374 depth++;
376 if(!prs_align(ps))
377 return False;
379 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
380 return False;
381 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
382 return False;
383 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
384 return False;
385 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
386 return False;
388 return True;
391 /*******************************************************************
392 reads or writes a structure.
393 ********************************************************************/
395 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
396 POLICY_HND *user_pol, uint32 sec_info)
398 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
400 q_u->user_pol = *user_pol;
401 q_u->sec_info = sec_info;
405 /*******************************************************************
406 reads or writes a structure.
407 ********************************************************************/
409 BOOL samr_io_q_query_sec_obj(char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
410 prs_struct *ps, int depth)
412 if (q_u == NULL)
413 return False;
415 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
416 depth++;
418 if(!prs_align(ps))
419 return False;
421 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
422 return False;
424 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
425 return False;
427 return True;
430 /*******************************************************************
431 reads or writes a structure.
432 ********************************************************************/
434 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
435 POLICY_HND *domain_pol, uint16 switch_value)
437 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
439 q_u->domain_pol = *domain_pol;
440 q_u->switch_value = switch_value;
443 /*******************************************************************
444 reads or writes a structure.
445 ********************************************************************/
447 BOOL samr_io_q_query_dom_info(char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
448 prs_struct *ps, int depth)
450 if (q_u == NULL)
451 return False;
453 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
454 depth++;
456 if(!prs_align(ps))
457 return False;
459 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
460 return False;
462 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
463 return False;
465 return True;
469 /*******************************************************************
470 inits a structure.
471 ********************************************************************/
473 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
475 u_3->logout.low = nt_logout.low;
476 u_3->logout.high = nt_logout.high;
479 /*******************************************************************
480 reads or writes a structure.
481 ********************************************************************/
483 static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 * u_3,
484 prs_struct *ps, int depth)
486 if (u_3 == NULL)
487 return False;
489 prs_debug(ps, depth, desc, "sam_io_unk_info3");
490 depth++;
492 if(!smb_io_time("logout", &u_3->logout, ps, depth))
493 return False;
495 return True;
498 /*******************************************************************
499 inits a structure.
500 ********************************************************************/
502 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
504 u_6->unknown_0 = 0x00000000;
505 u_6->ptr_0 = 1;
506 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
509 /*******************************************************************
510 reads or writes a structure.
511 ********************************************************************/
513 static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 * u_6,
514 prs_struct *ps, int depth)
516 if (u_6 == NULL)
517 return False;
519 prs_debug(ps, depth, desc, "sam_io_unk_info6");
520 depth++;
522 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
523 return False;
524 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
525 return False;
526 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
527 return False;
529 return True;
532 /*******************************************************************
533 inits a structure.
534 ********************************************************************/
536 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
538 u_7->unknown_0 = 0x0003;
541 /*******************************************************************
542 reads or writes a structure.
543 ********************************************************************/
545 static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 * u_7,
546 prs_struct *ps, int depth)
548 if (u_7 == NULL)
549 return False;
551 prs_debug(ps, depth, desc, "sam_io_unk_info7");
552 depth++;
554 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
555 return False;
557 return True;
560 /*******************************************************************
561 inits a structure.
562 ********************************************************************/
564 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
566 u_12->duration.low = nt_lock_duration.low;
567 u_12->duration.high = nt_lock_duration.high;
568 u_12->reset_count.low = nt_reset_time.low;
569 u_12->reset_count.high = nt_reset_time.high;
571 u_12->bad_attempt_lockout = lockout;
574 /*******************************************************************
575 reads or writes a structure.
576 ********************************************************************/
578 static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
579 prs_struct *ps, int depth)
581 if (u_12 == NULL)
582 return False;
584 prs_debug(ps, depth, desc, "sam_io_unk_info12");
585 depth++;
587 if(!smb_io_time("duration", &u_12->duration, ps, depth))
588 return False;
589 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
590 return False;
591 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
592 return False;
594 return True;
597 /*******************************************************************
598 inits a structure.
599 ********************************************************************/
600 void init_unk_info5(SAM_UNK_INFO_5 * u_5,char *server)
602 int len_server = strlen(server);
604 init_uni_hdr(&u_5->hdr_server, len_server);
606 init_unistr2(&u_5->uni_server, server, len_server);
609 /*******************************************************************
610 reads or writes a structure.
611 ********************************************************************/
613 static BOOL sam_io_unk_info5(char *desc, SAM_UNK_INFO_5 * u_5,
614 prs_struct *ps, int depth)
616 if (u_5 == NULL)
617 return False;
619 prs_debug(ps, depth, desc, "sam_io_unk_info5");
620 depth++;
622 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
623 return False;
625 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
626 return False;
628 return True;
631 /*******************************************************************
632 inits a structure.
633 ********************************************************************/
634 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
635 char *domain, char *server,
636 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
638 int len_domain = strlen(domain);
639 int len_server = strlen(server);
641 u_2->unknown_0 = 0x00000000;
642 u_2->unknown_1 = 0x80000000;
643 u_2->unknown_2 = 0x00000000;
645 u_2->ptr_0 = 1;
646 init_uni_hdr(&u_2->hdr_domain, len_domain);
647 init_uni_hdr(&u_2->hdr_server, len_server);
649 u_2->seq_num = seq_num;
650 u_2->unknown_3 = 0x00000000;
652 u_2->unknown_4 = 0x00000001;
653 u_2->unknown_5 = 0x00000003;
654 u_2->unknown_6 = 0x00000001;
655 u_2->num_domain_usrs = num_users;
656 u_2->num_domain_grps = num_groups;
657 u_2->num_local_grps = num_alias;
659 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
661 init_unistr2(&u_2->uni_domain, domain, len_domain);
662 init_unistr2(&u_2->uni_server, server, len_server);
665 /*******************************************************************
666 reads or writes a structure.
667 ********************************************************************/
669 static BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 * u_2,
670 prs_struct *ps, int depth)
672 if (u_2 == NULL)
673 return False;
675 prs_debug(ps, depth, desc, "sam_io_unk_info2");
676 depth++;
678 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
679 return False;
680 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
681 return False;
682 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
683 return False;
685 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
686 return False;
687 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
688 return False;
689 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
690 return False;
692 /* put all the data in here, at the moment, including what the above
693 pointer is referring to
696 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
697 return False;
698 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
699 return False;
701 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
702 return False;
703 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
704 return False;
705 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
706 return False;
707 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
708 return False;
709 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
710 return False;
711 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
712 return False;
714 if(!prs_uint8s(False, "padding", ps, depth, u_2->padding,sizeof(u_2->padding)))
715 return False;
717 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
718 return False;
719 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
720 return False;
722 return True;
725 /*******************************************************************
726 inits a structure.
727 ********************************************************************/
729 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
730 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
732 u_1->min_length_password = min_pass_len;
733 u_1->password_history = pass_hist;
734 u_1->flag = flag;
736 /* password never expire */
737 u_1->expire.high = nt_expire.high;
738 u_1->expire.low = nt_expire.low;
740 /* can change the password now */
741 u_1->min_passwordage.high = nt_min_age.high;
742 u_1->min_passwordage.low = nt_min_age.low;
746 /*******************************************************************
747 reads or writes a structure.
748 ********************************************************************/
750 static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 * u_1,
751 prs_struct *ps, int depth)
753 if (u_1 == NULL)
754 return False;
756 prs_debug(ps, depth, desc, "sam_io_unk_info1");
757 depth++;
759 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
760 return False;
761 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
762 return False;
763 if(!prs_uint32("flag", ps, depth, &u_1->flag))
764 return False;
765 if(!smb_io_time("expire", &u_1->expire, ps, depth))
766 return False;
767 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
768 return False;
770 return True;
773 /*******************************************************************
774 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
775 ********************************************************************/
777 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
778 uint16 switch_value, SAM_UNK_CTR * ctr,
779 NTSTATUS status)
781 DEBUG(5, ("init_samr_r_query_dom_info\n"));
783 r_u->ptr_0 = 0;
784 r_u->switch_value = 0;
785 r_u->status = status; /* return status */
787 if (NT_STATUS_IS_OK(status)) {
788 r_u->switch_value = switch_value;
789 r_u->ptr_0 = 1;
790 r_u->ctr = ctr;
794 /*******************************************************************
795 reads or writes a structure.
796 ********************************************************************/
798 BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
799 prs_struct *ps, int depth)
801 if (r_u == NULL)
802 return False;
804 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
805 depth++;
807 if(!prs_align(ps))
808 return False;
810 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
811 return False;
813 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
814 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
815 return False;
816 if(!prs_align(ps))
817 return False;
819 switch (r_u->switch_value) {
820 case 0x0c:
821 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
822 return False;
823 break;
824 case 0x07:
825 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
826 return False;
827 break;
828 case 0x06:
829 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
830 return False;
831 break;
832 case 0x05:
833 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
834 return False;
835 break;
836 case 0x03:
837 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
838 return False;
839 break;
840 case 0x02:
841 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
842 return False;
843 break;
844 case 0x01:
845 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
846 return False;
847 break;
848 default:
849 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
850 r_u->switch_value));
851 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
852 return False;
856 if(!prs_align(ps))
857 return False;
859 if(!prs_ntstatus("status", ps, depth, &r_u->status))
860 return False;
862 return True;
865 /*******************************************************************
866 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
867 ********************************************************************/
869 BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
870 prs_struct *ps, int depth)
872 if (r_u == NULL)
873 return False;
875 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
876 depth++;
878 if(!prs_align(ps))
879 return False;
881 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
882 return False;
883 if (r_u->ptr != 0) {
884 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
885 return False;
888 if(!prs_ntstatus("status", ps, depth, &r_u->status))
889 return False;
891 return True;
894 /*******************************************************************
895 reads or writes a SAM_STR1 structure.
896 ********************************************************************/
898 static BOOL sam_io_sam_str1(char *desc, SAM_STR1 * sam, uint32 acct_buf,
899 uint32 name_buf, uint32 desc_buf,
900 prs_struct *ps, int depth)
902 if (sam == NULL)
903 return False;
905 prs_debug(ps, depth, desc, "sam_io_sam_str1");
906 depth++;
908 if(!prs_align(ps))
909 return False;
910 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
911 return False;
913 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
914 return False;
916 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
917 return False;
919 return True;
922 /*******************************************************************
923 inits a SAM_ENTRY1 structure.
924 ********************************************************************/
926 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
927 uint32 len_sam_name, uint32 len_sam_full,
928 uint32 len_sam_desc, uint32 rid_user,
929 uint16 acb_info)
931 DEBUG(5, ("init_sam_entry1\n"));
933 ZERO_STRUCTP(sam);
935 sam->user_idx = user_idx;
936 sam->rid_user = rid_user;
937 sam->acb_info = acb_info;
939 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
940 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
941 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
944 /*******************************************************************
945 reads or writes a SAM_ENTRY1 structure.
946 ********************************************************************/
948 static BOOL sam_io_sam_entry1(char *desc, SAM_ENTRY1 * sam,
949 prs_struct *ps, int depth)
951 if (sam == NULL)
952 return False;
954 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
955 depth++;
957 if(!prs_align(ps))
958 return False;
960 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
961 return False;
963 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
964 return False;
965 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
966 return False;
968 if(!prs_align(ps))
969 return False;
971 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
972 return False;
973 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
974 return False;
975 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
976 return False;
978 return True;
981 /*******************************************************************
982 reads or writes a SAM_STR2 structure.
983 ********************************************************************/
985 static BOOL sam_io_sam_str2(char *desc, SAM_STR2 * sam, uint32 acct_buf,
986 uint32 desc_buf, prs_struct *ps, int depth)
988 if (sam == NULL)
989 return False;
991 prs_debug(ps, depth, desc, "sam_io_sam_str2");
992 depth++;
994 if(!prs_align(ps))
995 return False;
997 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
998 return False;
999 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1000 return False;
1002 return True;
1005 /*******************************************************************
1006 inits a SAM_ENTRY2 structure.
1007 ********************************************************************/
1008 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1009 uint32 len_sam_name, uint32 len_sam_desc,
1010 uint32 rid_user, uint16 acb_info)
1012 DEBUG(5, ("init_sam_entry2\n"));
1014 sam->user_idx = user_idx;
1015 sam->rid_user = rid_user;
1016 sam->acb_info = acb_info;
1018 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
1019 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
1022 /*******************************************************************
1023 reads or writes a SAM_ENTRY2 structure.
1024 ********************************************************************/
1026 static BOOL sam_io_sam_entry2(char *desc, SAM_ENTRY2 * sam,
1027 prs_struct *ps, int depth)
1029 if (sam == NULL)
1030 return False;
1032 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1033 depth++;
1035 if(!prs_align(ps))
1036 return False;
1038 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1039 return False;
1041 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1042 return False;
1043 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1044 return False;
1046 if(!prs_align(ps))
1047 return False;
1049 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1050 return False;
1051 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1052 return False;
1054 return True;
1057 /*******************************************************************
1058 reads or writes a SAM_STR3 structure.
1059 ********************************************************************/
1061 static BOOL sam_io_sam_str3(char *desc, SAM_STR3 * sam, uint32 acct_buf,
1062 uint32 desc_buf, prs_struct *ps, int depth)
1064 if (sam == NULL)
1065 return False;
1067 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1068 depth++;
1070 if(!prs_align(ps))
1071 return False;
1073 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1074 return False;
1075 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1076 return False;
1078 return True;
1081 /*******************************************************************
1082 inits a SAM_ENTRY3 structure.
1083 ********************************************************************/
1085 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1086 uint32 len_grp_name, uint32 len_grp_desc,
1087 uint32 rid_grp)
1089 DEBUG(5, ("init_sam_entry3\n"));
1091 sam->grp_idx = grp_idx;
1092 sam->rid_grp = rid_grp;
1093 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1095 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1096 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1099 /*******************************************************************
1100 reads or writes a SAM_ENTRY3 structure.
1101 ********************************************************************/
1103 static BOOL sam_io_sam_entry3(char *desc, SAM_ENTRY3 * sam,
1104 prs_struct *ps, int depth)
1106 if (sam == NULL)
1107 return False;
1109 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1110 depth++;
1112 if(!prs_align(ps))
1113 return False;
1115 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1116 return False;
1118 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1119 return False;
1120 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1121 return False;
1123 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1124 return False;
1125 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1126 return False;
1128 return True;
1131 /*******************************************************************
1132 inits a SAM_ENTRY4 structure.
1133 ********************************************************************/
1135 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1136 uint32 len_acct_name)
1138 DEBUG(5, ("init_sam_entry4\n"));
1140 sam->user_idx = user_idx;
1141 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1144 /*******************************************************************
1145 reads or writes a SAM_ENTRY4 structure.
1146 ********************************************************************/
1148 static BOOL sam_io_sam_entry4(char *desc, SAM_ENTRY4 * sam,
1149 prs_struct *ps, int depth)
1151 if (sam == NULL)
1152 return False;
1154 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1155 depth++;
1157 if(!prs_align(ps))
1158 return False;
1160 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1161 return False;
1162 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1163 return False;
1165 return True;
1168 /*******************************************************************
1169 inits a SAM_ENTRY5 structure.
1170 ********************************************************************/
1172 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1173 uint32 len_grp_name)
1175 DEBUG(5, ("init_sam_entry5\n"));
1177 sam->grp_idx = grp_idx;
1178 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1179 len_grp_name != 0);
1182 /*******************************************************************
1183 reads or writes a SAM_ENTRY5 structure.
1184 ********************************************************************/
1186 static BOOL sam_io_sam_entry5(char *desc, SAM_ENTRY5 * sam,
1187 prs_struct *ps, int depth)
1189 if (sam == NULL)
1190 return False;
1192 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1193 depth++;
1195 if(!prs_align(ps))
1196 return False;
1198 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1199 return False;
1200 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1201 return False;
1203 return True;
1206 /*******************************************************************
1207 inits a SAM_ENTRY structure.
1208 ********************************************************************/
1210 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1212 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1214 sam->rid = rid;
1215 init_uni_hdr(&sam->hdr_name, len_sam_name);
1218 /*******************************************************************
1219 reads or writes a SAM_ENTRY structure.
1220 ********************************************************************/
1222 static BOOL sam_io_sam_entry(char *desc, SAM_ENTRY * sam,
1223 prs_struct *ps, int depth)
1225 if (sam == NULL)
1226 return False;
1228 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1229 depth++;
1231 if(!prs_align(ps))
1232 return False;
1233 if(!prs_uint32("rid", ps, depth, &sam->rid))
1234 return False;
1235 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1236 return False;
1238 return True;
1241 /*******************************************************************
1242 inits a SAMR_Q_ENUM_DOM_USERS structure.
1243 ********************************************************************/
1245 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1246 uint32 start_idx,
1247 uint16 acb_mask, uint16 unk_1, uint32 size)
1249 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1251 q_e->pol = *pol;
1253 q_e->start_idx = start_idx; /* zero indicates lots */
1254 q_e->acb_mask = acb_mask;
1255 q_e->unknown_1 = unk_1;
1256 q_e->max_size = size;
1259 /*******************************************************************
1260 reads or writes a structure.
1261 ********************************************************************/
1263 BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1264 prs_struct *ps, int depth)
1266 if (q_e == NULL)
1267 return False;
1269 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1270 depth++;
1272 if(!prs_align(ps))
1273 return False;
1275 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1276 return False;
1278 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1279 return False;
1280 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1281 return False;
1282 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1283 return False;
1285 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1286 return False;
1288 return True;
1292 /*******************************************************************
1293 inits a SAMR_R_ENUM_DOM_USERS structure.
1294 ********************************************************************/
1296 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1297 uint32 next_idx, uint32 num_sam_entries)
1299 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1301 r_u->next_idx = next_idx;
1303 if (num_sam_entries != 0) {
1304 r_u->ptr_entries1 = 1;
1305 r_u->ptr_entries2 = 1;
1306 r_u->num_entries2 = num_sam_entries;
1307 r_u->num_entries3 = num_sam_entries;
1309 r_u->num_entries4 = num_sam_entries;
1310 } else {
1311 r_u->ptr_entries1 = 0;
1312 r_u->num_entries2 = num_sam_entries;
1313 r_u->ptr_entries2 = 1;
1317 /*******************************************************************
1318 reads or writes a structure.
1319 ********************************************************************/
1321 BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1322 prs_struct *ps, int depth)
1324 uint32 i;
1326 if (r_u == NULL)
1327 return False;
1329 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1330 depth++;
1332 if(!prs_align(ps))
1333 return False;
1335 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1336 return False;
1337 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1338 return False;
1340 if (r_u->ptr_entries1 != 0) {
1341 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1342 return False;
1343 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1344 return False;
1345 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1346 return False;
1348 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1349 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1350 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
1353 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1354 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1355 r_u->num_entries4 = 0;
1356 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1357 return False;
1360 for (i = 0; i < r_u->num_entries2; i++) {
1361 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1362 return False;
1365 for (i = 0; i < r_u->num_entries2; i++) {
1366 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1367 return False;
1372 if(!prs_align(ps))
1373 return False;
1375 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1376 return False;
1377 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1378 return False;
1380 return True;
1383 /*******************************************************************
1384 inits a SAMR_Q_QUERY_DISPINFO structure.
1385 ********************************************************************/
1387 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1388 uint16 switch_level, uint32 start_idx,
1389 uint32 max_entries)
1391 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1393 q_e->domain_pol = *pol;
1395 q_e->switch_level = switch_level;
1397 q_e->start_idx = start_idx;
1398 q_e->max_entries = max_entries;
1399 q_e->max_size = 0xffff; /* Not especially useful */
1402 /*******************************************************************
1403 reads or writes a structure.
1404 ********************************************************************/
1406 BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1407 prs_struct *ps, int depth)
1409 if (q_e == NULL)
1410 return False;
1412 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1413 depth++;
1415 if(!prs_align(ps))
1416 return False;
1418 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1419 return False;
1421 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1422 return False;
1423 if(!prs_align(ps))
1424 return False;
1426 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1427 return False;
1428 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1429 return False;
1430 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1431 return False;
1433 return True;
1436 /*******************************************************************
1437 inits a SAM_DISPINFO_1 structure.
1438 ********************************************************************/
1440 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1441 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1443 uint32 len_sam_name, len_sam_full, len_sam_desc;
1444 uint32 i;
1446 SAM_ACCOUNT *pwd = NULL;
1447 ZERO_STRUCTP(sam);
1449 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1451 if (num_entries==0)
1452 return NT_STATUS_OK;
1454 sam->sam=(SAM_ENTRY1 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY1));
1455 if (!sam->sam)
1456 return NT_STATUS_NO_MEMORY;
1458 sam->str=(SAM_STR1 *)talloc(ctx, num_entries*sizeof(SAM_STR1));
1459 if (!sam->str)
1460 return NT_STATUS_NO_MEMORY;
1462 ZERO_STRUCTP(sam->sam);
1463 ZERO_STRUCTP(sam->str);
1465 for (i = 0; i < num_entries ; i++) {
1466 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1468 pwd=disp_user_info[i+start_idx].sam;
1470 len_sam_name = strlen(unix_to_dos_static(pdb_get_username(pwd)));
1471 len_sam_full = strlen(unix_to_dos_static(pdb_get_fullname(pwd)));
1472 len_sam_desc = strlen(unix_to_dos_static(pdb_get_acct_desc(pwd)));
1474 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1475 len_sam_name, len_sam_full, len_sam_desc,
1476 pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd));
1478 ZERO_STRUCTP(&sam->str[i].uni_acct_name);
1479 ZERO_STRUCTP(&sam->str[i].uni_full_name);
1480 ZERO_STRUCTP(&sam->str[i].uni_acct_desc);
1482 init_unistr2(&sam->str[i].uni_acct_name, unix_to_dos_static(pdb_get_username(pwd)), len_sam_name);
1483 init_unistr2(&sam->str[i].uni_full_name, unix_to_dos_static(pdb_get_fullname(pwd)), len_sam_full);
1484 init_unistr2(&sam->str[i].uni_acct_desc, unix_to_dos_static(pdb_get_acct_desc(pwd)), len_sam_desc);
1487 return NT_STATUS_OK;
1490 /*******************************************************************
1491 reads or writes a structure.
1492 ********************************************************************/
1494 static BOOL sam_io_sam_dispinfo_1(char *desc, SAM_DISPINFO_1 * sam,
1495 uint32 num_entries,
1496 prs_struct *ps, int depth)
1498 uint32 i;
1500 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1501 depth++;
1503 if(!prs_align(ps))
1504 return False;
1506 if (UNMARSHALLING(ps) && num_entries > 0) {
1508 if ((sam->sam = (SAM_ENTRY1 *)
1509 prs_alloc_mem(ps, sizeof(SAM_ENTRY1) *
1510 num_entries)) == NULL) {
1511 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1512 return False;
1515 if ((sam->str = (SAM_STR1 *)
1516 prs_alloc_mem(ps, sizeof(SAM_STR1) *
1517 num_entries)) == NULL) {
1518 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1519 return False;
1523 for (i = 0; i < num_entries; i++) {
1524 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1525 return False;
1528 for (i = 0; i < num_entries; i++) {
1529 if(!sam_io_sam_str1("", &sam->str[i],
1530 sam->sam[i].hdr_acct_name.buffer,
1531 sam->sam[i].hdr_user_name.buffer,
1532 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1533 return False;
1536 return True;
1539 /*******************************************************************
1540 inits a SAM_DISPINFO_2 structure.
1541 ********************************************************************/
1543 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1544 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1546 uint32 len_sam_name, len_sam_desc;
1547 uint32 i;
1549 SAM_ACCOUNT *pwd = NULL;
1550 ZERO_STRUCTP(sam);
1552 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1554 if (num_entries==0)
1555 return NT_STATUS_OK;
1557 if (!(sam->sam=(SAM_ENTRY2 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY2))))
1558 return NT_STATUS_NO_MEMORY;
1560 if (!(sam->str=(SAM_STR2 *)talloc(ctx, num_entries*sizeof(SAM_STR2))))
1561 return NT_STATUS_NO_MEMORY;
1563 ZERO_STRUCTP(sam->sam);
1564 ZERO_STRUCTP(sam->str);
1566 for (i = 0; i < num_entries; i++) {
1567 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1568 pwd=disp_user_info[i+start_idx].sam;
1570 len_sam_name = strlen(unix_to_dos_static(pdb_get_username(pwd)));
1571 len_sam_desc = strlen(unix_to_dos_static(pdb_get_acct_desc(pwd)));
1573 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1574 len_sam_name, len_sam_desc,
1575 pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd));
1577 ZERO_STRUCTP(&sam->str[i].uni_srv_name);
1578 ZERO_STRUCTP(&sam->str[i].uni_srv_desc);
1580 init_unistr2(&sam->str[i].uni_srv_name, unix_to_dos_static(pdb_get_username(pwd)), len_sam_name);
1581 init_unistr2(&sam->str[i].uni_srv_desc, unix_to_dos_static(pdb_get_acct_desc(pwd)), len_sam_desc);
1584 return NT_STATUS_OK;
1587 /*******************************************************************
1588 reads or writes a structure.
1589 ********************************************************************/
1591 static BOOL sam_io_sam_dispinfo_2(char *desc, SAM_DISPINFO_2 * sam,
1592 uint32 num_entries,
1593 prs_struct *ps, int depth)
1595 uint32 i;
1597 if (sam == NULL)
1598 return False;
1600 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1601 depth++;
1603 if(!prs_align(ps))
1604 return False;
1606 if (UNMARSHALLING(ps) && num_entries > 0) {
1608 if ((sam->sam = (SAM_ENTRY2 *)
1609 prs_alloc_mem(ps, sizeof(SAM_ENTRY2) *
1610 num_entries)) == NULL) {
1611 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1612 return False;
1615 if ((sam->str = (SAM_STR2 *)
1616 prs_alloc_mem(ps, sizeof(SAM_STR2) *
1617 num_entries)) == NULL) {
1618 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1619 return False;
1623 for (i = 0; i < num_entries; i++) {
1624 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1625 return False;
1628 for (i = 0; i < num_entries; i++) {
1629 if(!sam_io_sam_str2("", &sam->str[i],
1630 sam->sam[i].hdr_srv_name.buffer,
1631 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1632 return False;
1635 return True;
1638 /*******************************************************************
1639 inits a SAM_DISPINFO_3 structure.
1640 ********************************************************************/
1642 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1643 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1645 uint32 len_sam_name, len_sam_desc;
1646 uint32 i;
1648 ZERO_STRUCTP(sam);
1650 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1652 if (num_entries==0)
1653 return NT_STATUS_OK;
1655 if (!(sam->sam=(SAM_ENTRY3 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY3))))
1656 return NT_STATUS_NO_MEMORY;
1658 if (!(sam->str=(SAM_STR3 *)talloc(ctx, num_entries*sizeof(SAM_STR3))))
1659 return NT_STATUS_NO_MEMORY;
1661 ZERO_STRUCTP(sam->sam);
1662 ZERO_STRUCTP(sam->str);
1664 for (i = 0; i < num_entries; i++) {
1665 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1667 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1669 len_sam_name = strlen(grp->name);
1670 len_sam_desc = strlen(grp->comment);
1672 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp->rid);
1674 init_unistr2(&sam->str[i].uni_grp_name, grp->name, len_sam_name);
1675 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, len_sam_desc);
1678 return NT_STATUS_OK;
1681 /*******************************************************************
1682 reads or writes a structure.
1683 ********************************************************************/
1685 static BOOL sam_io_sam_dispinfo_3(char *desc, SAM_DISPINFO_3 * sam,
1686 uint32 num_entries,
1687 prs_struct *ps, int depth)
1689 uint32 i;
1691 if (sam == NULL)
1692 return False;
1694 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1695 depth++;
1697 if(!prs_align(ps))
1698 return False;
1700 if (UNMARSHALLING(ps) && num_entries > 0) {
1702 if ((sam->sam = (SAM_ENTRY3 *)
1703 prs_alloc_mem(ps, sizeof(SAM_ENTRY3) *
1704 num_entries)) == NULL) {
1705 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1706 return False;
1709 if ((sam->str = (SAM_STR3 *)
1710 prs_alloc_mem(ps, sizeof(SAM_STR3) *
1711 num_entries)) == NULL) {
1712 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1713 return False;
1717 for (i = 0; i < num_entries; i++) {
1718 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1719 return False;
1722 for (i = 0; i < num_entries; i++) {
1723 if(!sam_io_sam_str3("", &sam->str[i],
1724 sam->sam[i].hdr_grp_name.buffer,
1725 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1726 return False;
1729 return True;
1732 /*******************************************************************
1733 inits a SAM_DISPINFO_4 structure.
1734 ********************************************************************/
1736 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1737 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1739 uint32 len_sam_name;
1740 uint32 i;
1742 SAM_ACCOUNT *pwd = NULL;
1743 ZERO_STRUCTP(sam);
1745 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1747 if (num_entries==0)
1748 return NT_STATUS_OK;
1750 if (!(sam->sam=(SAM_ENTRY4 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY4))))
1751 return NT_STATUS_NO_MEMORY;
1753 if (!(sam->str=(SAM_STR4 *)talloc(ctx, num_entries*sizeof(SAM_STR4))))
1754 return NT_STATUS_NO_MEMORY;
1756 ZERO_STRUCTP(sam->sam);
1757 ZERO_STRUCTP(sam->str);
1759 for (i = 0; i < num_entries; i++) {
1760 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1761 pwd=disp_user_info[i+start_idx].sam;
1763 len_sam_name = strlen(unix_to_dos_static(pdb_get_username(pwd)));
1765 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1767 init_string2(&sam->str[i].acct_name, unix_to_dos_static(pdb_get_username(pwd)),
1768 len_sam_name+1, len_sam_name);
1771 return NT_STATUS_OK;
1774 /*******************************************************************
1775 reads or writes a structure.
1776 ********************************************************************/
1778 static BOOL sam_io_sam_dispinfo_4(char *desc, SAM_DISPINFO_4 * sam,
1779 uint32 num_entries,
1780 prs_struct *ps, int depth)
1782 uint32 i;
1784 if (sam == NULL)
1785 return False;
1787 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1788 depth++;
1790 if(!prs_align(ps))
1791 return False;
1793 if (UNMARSHALLING(ps) && num_entries > 0) {
1795 if ((sam->sam = (SAM_ENTRY4 *)
1796 prs_alloc_mem(ps, sizeof(SAM_ENTRY4) *
1797 num_entries)) == NULL) {
1798 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1799 return False;
1802 if ((sam->str = (SAM_STR4 *)
1803 prs_alloc_mem(ps, sizeof(SAM_STR4) *
1804 num_entries)) == NULL) {
1805 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1806 return False;
1810 for (i = 0; i < num_entries; i++) {
1811 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1812 return False;
1815 for (i = 0; i < num_entries; i++) {
1816 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1817 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1818 return False;
1821 return True;
1824 /*******************************************************************
1825 inits a SAM_DISPINFO_5 structure.
1826 ********************************************************************/
1828 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1829 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1831 uint32 len_sam_name;
1832 uint32 i;
1834 ZERO_STRUCTP(sam);
1836 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1838 if (num_entries==0)
1839 return NT_STATUS_OK;
1841 if (!(sam->sam=(SAM_ENTRY5 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY5))))
1842 return NT_STATUS_NO_MEMORY;
1844 if (!(sam->str=(SAM_STR5 *)talloc(ctx, num_entries*sizeof(SAM_STR5))))
1845 return NT_STATUS_NO_MEMORY;
1847 ZERO_STRUCTP(sam->sam);
1848 ZERO_STRUCTP(sam->str);
1850 for (i = 0; i < num_entries; i++) {
1851 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1853 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1855 len_sam_name = strlen(grp->name);
1857 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1858 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1861 return NT_STATUS_OK;
1864 /*******************************************************************
1865 reads or writes a structure.
1866 ********************************************************************/
1868 static BOOL sam_io_sam_dispinfo_5(char *desc, SAM_DISPINFO_5 * sam,
1869 uint32 num_entries,
1870 prs_struct *ps, int depth)
1872 uint32 i;
1874 if (sam == NULL)
1875 return False;
1877 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1878 depth++;
1880 if(!prs_align(ps))
1881 return False;
1883 if (UNMARSHALLING(ps) && num_entries > 0) {
1885 if ((sam->sam = (SAM_ENTRY5 *)
1886 prs_alloc_mem(ps, sizeof(SAM_ENTRY5) *
1887 num_entries)) == NULL) {
1888 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1889 return False;
1892 if ((sam->str = (SAM_STR5 *)
1893 prs_alloc_mem(ps, sizeof(SAM_STR5) *
1894 num_entries)) == NULL) {
1895 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1896 return False;
1900 for (i = 0; i < num_entries; i++) {
1901 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1902 return False;
1905 for (i = 0; i < num_entries; i++) {
1906 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1907 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1908 return False;
1911 return True;
1914 /*******************************************************************
1915 inits a SAMR_R_QUERY_DISPINFO structure.
1916 ********************************************************************/
1918 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1919 uint32 num_entries, uint32 total_size, uint32 data_size,
1920 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1921 NTSTATUS status)
1923 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1925 r_u->total_size = total_size;
1927 r_u->data_size = data_size;
1929 r_u->switch_level = switch_level;
1930 r_u->num_entries = num_entries;
1932 if (num_entries==0)
1933 r_u->ptr_entries = 0;
1934 else
1935 r_u->ptr_entries = 1;
1937 r_u->num_entries2 = num_entries;
1938 r_u->ctr = ctr;
1940 r_u->status = status;
1943 /*******************************************************************
1944 reads or writes a structure.
1945 ********************************************************************/
1947 BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1948 prs_struct *ps, int depth)
1950 if (r_u == NULL)
1951 return False;
1953 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
1954 depth++;
1956 if(!prs_align(ps))
1957 return False;
1959 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
1960 return False;
1961 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
1962 return False;
1963 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
1964 return False;
1965 if(!prs_align(ps))
1966 return False;
1968 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
1969 return False;
1970 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
1971 return False;
1973 if (r_u->ptr_entries==0) {
1974 if(!prs_align(ps))
1975 return False;
1976 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1977 return False;
1979 return True;
1982 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1983 return False;
1985 switch (r_u->switch_level) {
1986 case 0x1:
1987 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
1988 r_u->num_entries, ps, depth))
1989 return False;
1990 break;
1991 case 0x2:
1992 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
1993 r_u->num_entries, ps, depth))
1994 return False;
1995 break;
1996 case 0x3:
1997 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
1998 r_u->num_entries, ps, depth))
1999 return False;
2000 break;
2001 case 0x4:
2002 if(!sam_io_sam_dispinfo_4("user list",
2003 r_u->ctr->sam.info4,
2004 r_u->num_entries, ps, depth))
2005 return False;
2006 break;
2007 case 0x5:
2008 if(!sam_io_sam_dispinfo_5("group list",
2009 r_u->ctr->sam.info5,
2010 r_u->num_entries, ps, depth))
2011 return False;
2012 break;
2013 default:
2014 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2015 break;
2018 if(!prs_align(ps))
2019 return False;
2020 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2021 return False;
2023 return True;
2026 /*******************************************************************
2027 inits a SAMR_Q_OPEN_GROUP structure.
2028 ********************************************************************/
2030 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2031 POLICY_HND *hnd,
2032 uint32 access_mask, uint32 rid)
2034 DEBUG(5, ("init_samr_q_open_group\n"));
2036 q_c->domain_pol = *hnd;
2037 q_c->access_mask = access_mask;
2038 q_c->rid_group = rid;
2041 /*******************************************************************
2042 reads or writes a structure.
2043 ********************************************************************/
2045 BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
2046 prs_struct *ps, int depth)
2048 if (q_u == NULL)
2049 return False;
2051 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2052 depth++;
2054 if(!prs_align(ps))
2055 return False;
2057 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2058 return False;
2060 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2061 return False;
2062 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2063 return False;
2065 return True;
2068 /*******************************************************************
2069 reads or writes a structure.
2070 ********************************************************************/
2072 BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
2073 prs_struct *ps, int depth)
2075 if (r_u == NULL)
2076 return False;
2078 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2079 depth++;
2081 if(!prs_align(ps))
2082 return False;
2084 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2085 return False;
2087 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2088 return False;
2090 return True;
2093 /*******************************************************************
2094 inits a GROUP_INFO1 structure.
2095 ********************************************************************/
2097 void init_samr_group_info1(GROUP_INFO1 * gr1,
2098 char *acct_name, char *acct_desc,
2099 uint32 num_members)
2101 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2102 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
2104 DEBUG(5, ("init_samr_group_info1\n"));
2106 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
2108 gr1->unknown_1 = 0x3;
2109 gr1->num_members = num_members;
2111 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
2113 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
2114 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
2117 /*******************************************************************
2118 reads or writes a structure.
2119 ********************************************************************/
2121 BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
2122 prs_struct *ps, int depth)
2124 if (gr1 == NULL)
2125 return False;
2127 prs_debug(ps, depth, desc, "samr_io_group_info1");
2128 depth++;
2130 if(!prs_align(ps))
2131 return False;
2133 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2134 return False;
2136 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2137 return False;
2138 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2139 return False;
2141 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2142 return False;
2144 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2145 gr1->hdr_acct_name.buffer, ps, depth))
2146 return False;
2148 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2149 gr1->hdr_acct_desc.buffer, ps, depth))
2150 return False;
2152 return True;
2155 /*******************************************************************
2156 inits a GROUP_INFO3 structure.
2157 ********************************************************************/
2159 void init_samr_group_info3(GROUP_INFO3 *gr3)
2161 DEBUG(5, ("init_samr_group_info3\n"));
2163 gr3->unknown_1 = 0x3;
2166 /*******************************************************************
2167 reads or writes a structure.
2168 ********************************************************************/
2170 BOOL samr_io_group_info3(char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2172 if (gr3 == NULL)
2173 return False;
2175 prs_debug(ps, depth, desc, "samr_io_group_info3");
2176 depth++;
2178 if(!prs_align(ps))
2179 return False;
2181 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2182 return False;
2184 return True;
2187 /*******************************************************************
2188 inits a GROUP_INFO4 structure.
2189 ********************************************************************/
2191 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2193 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2195 DEBUG(5, ("init_samr_group_info4\n"));
2197 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2198 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2201 /*******************************************************************
2202 reads or writes a structure.
2203 ********************************************************************/
2205 BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
2206 prs_struct *ps, int depth)
2208 if (gr4 == NULL)
2209 return False;
2211 prs_debug(ps, depth, desc, "samr_io_group_info4");
2212 depth++;
2214 if(!prs_align(ps))
2215 return False;
2217 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2218 return False;
2219 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2220 gr4->hdr_acct_desc.buffer, ps, depth))
2221 return False;
2223 return True;
2226 /*******************************************************************
2227 reads or writes a structure.
2228 ********************************************************************/
2230 static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR **ctr,
2231 prs_struct *ps, int depth)
2233 if (UNMARSHALLING(ps))
2234 *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
2236 if (*ctr == NULL)
2237 return False;
2239 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2240 depth++;
2242 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2243 return False;
2245 switch ((*ctr)->switch_value1) {
2246 case 1:
2247 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2248 return False;
2249 break;
2250 case 3:
2251 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2252 return False;
2253 break;
2254 case 4:
2255 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2256 return False;
2257 break;
2258 default:
2259 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2260 break;
2263 return True;
2266 /*******************************************************************
2267 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2268 ********************************************************************/
2270 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2271 POLICY_HND *pol, char *acct_desc,
2272 uint32 access_mask)
2274 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2276 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2278 q_e->pol = *pol;
2280 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2281 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2283 q_e->access_mask = access_mask;
2286 /*******************************************************************
2287 reads or writes a structure.
2288 ********************************************************************/
2290 BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2291 prs_struct *ps, int depth)
2293 if (q_e == NULL)
2294 return False;
2296 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2297 depth++;
2299 if(!prs_align(ps))
2300 return False;
2302 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2303 return False;
2305 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2306 return False;
2307 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2308 q_e->hdr_acct_desc.buffer, ps, depth))
2309 return False;
2311 if(!prs_align(ps))
2312 return False;
2313 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2314 return False;
2316 return True;
2319 /*******************************************************************
2320 reads or writes a structure.
2321 ********************************************************************/
2323 BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2324 prs_struct *ps, int depth)
2326 if (r_u == NULL)
2327 return False;
2329 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2330 depth++;
2332 if(!prs_align(ps))
2333 return False;
2335 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2336 return False;
2338 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2339 return False;
2340 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2341 return False;
2343 return True;
2346 /*******************************************************************
2347 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2348 ********************************************************************/
2350 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2351 POLICY_HND *hnd)
2353 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2355 q_c->group_pol = *hnd;
2358 /*******************************************************************
2359 reads or writes a structure.
2360 ********************************************************************/
2362 BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2363 prs_struct *ps, int depth)
2365 if (q_u == NULL)
2366 return False;
2368 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2369 depth++;
2371 if(!prs_align(ps))
2372 return False;
2374 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2375 return False;
2377 return True;
2380 /*******************************************************************
2381 reads or writes a structure.
2382 ********************************************************************/
2384 BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2385 prs_struct *ps, int depth)
2387 if (r_u == NULL)
2388 return False;
2390 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2391 depth++;
2393 if(!prs_align(ps))
2394 return False;
2396 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2397 return False;
2399 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2400 return False;
2402 return True;
2405 /*******************************************************************
2406 inits a SAMR_Q_DEL_GROUPMEM structure.
2407 ********************************************************************/
2409 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2410 POLICY_HND *pol, uint32 rid)
2412 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2414 q_e->pol = *pol;
2415 q_e->rid = rid;
2418 /*******************************************************************
2419 reads or writes a structure.
2420 ********************************************************************/
2422 BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2423 prs_struct *ps, int depth)
2425 if (q_e == NULL)
2426 return False;
2428 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2429 depth++;
2431 if(!prs_align(ps))
2432 return False;
2434 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2435 return False;
2437 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2438 return False;
2440 return True;
2443 /*******************************************************************
2444 inits a SAMR_R_DEL_GROUPMEM structure.
2445 ********************************************************************/
2447 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2448 NTSTATUS status)
2450 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2452 r_u->status = status;
2455 /*******************************************************************
2456 reads or writes a structure.
2457 ********************************************************************/
2459 BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2460 prs_struct *ps, int depth)
2462 if (r_u == NULL)
2463 return False;
2465 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2466 depth++;
2468 if(!prs_align(ps))
2469 return False;
2471 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2472 return False;
2474 return True;
2477 /*******************************************************************
2478 inits a SAMR_Q_ADD_GROUPMEM structure.
2479 ********************************************************************/
2481 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2482 POLICY_HND *pol, uint32 rid)
2484 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2486 q_e->pol = *pol;
2487 q_e->rid = rid;
2488 q_e->unknown = 0x0005;
2491 /*******************************************************************
2492 reads or writes a structure.
2493 ********************************************************************/
2495 BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2496 prs_struct *ps, int depth)
2498 if (q_e == NULL)
2499 return False;
2501 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2502 depth++;
2504 if(!prs_align(ps))
2505 return False;
2507 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2508 return False;
2510 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2511 return False;
2512 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2513 return False;
2515 return True;
2518 /*******************************************************************
2519 inits a SAMR_R_ADD_GROUPMEM structure.
2520 ********************************************************************/
2522 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2523 NTSTATUS status)
2525 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2527 r_u->status = status;
2530 /*******************************************************************
2531 reads or writes a structure.
2532 ********************************************************************/
2534 BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2535 prs_struct *ps, int depth)
2537 if (r_u == NULL)
2538 return False;
2540 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2541 depth++;
2543 if(!prs_align(ps))
2544 return False;
2546 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2547 return False;
2549 return True;
2552 /*******************************************************************
2553 inits a SAMR_Q_SET_GROUPINFO structure.
2554 ********************************************************************/
2556 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2557 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2559 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2561 q_e->pol = *pol;
2562 q_e->ctr = ctr;
2565 /*******************************************************************
2566 reads or writes a structure.
2567 ********************************************************************/
2569 BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2570 prs_struct *ps, int depth)
2572 if (q_e == NULL)
2573 return False;
2575 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2576 depth++;
2578 if(!prs_align(ps))
2579 return False;
2581 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2582 return False;
2584 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2585 return False;
2587 return True;
2590 /*******************************************************************
2591 inits a SAMR_R_SET_GROUPINFO structure.
2592 ********************************************************************/
2594 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2596 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2598 r_u->status = status;
2601 /*******************************************************************
2602 reads or writes a structure.
2603 ********************************************************************/
2605 BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
2606 prs_struct *ps, int depth)
2608 if (r_u == NULL)
2609 return False;
2611 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2612 depth++;
2614 if(!prs_align(ps))
2615 return False;
2617 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2618 return False;
2620 return True;
2623 /*******************************************************************
2624 inits a SAMR_Q_QUERY_GROUPINFO structure.
2625 ********************************************************************/
2627 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2628 POLICY_HND *pol, uint16 switch_level)
2630 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2632 q_e->pol = *pol;
2634 q_e->switch_level = switch_level;
2637 /*******************************************************************
2638 reads or writes a structure.
2639 ********************************************************************/
2641 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2642 prs_struct *ps, int depth)
2644 if (q_e == NULL)
2645 return False;
2647 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2648 depth++;
2650 if(!prs_align(ps))
2651 return False;
2653 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2654 return False;
2656 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2657 return False;
2659 return True;
2662 /*******************************************************************
2663 inits a SAMR_R_QUERY_GROUPINFO structure.
2664 ********************************************************************/
2666 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2667 GROUP_INFO_CTR * ctr, NTSTATUS status)
2669 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2671 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2672 r_u->ctr = ctr;
2673 r_u->status = status;
2676 /*******************************************************************
2677 reads or writes a structure.
2678 ********************************************************************/
2680 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2681 prs_struct *ps, int depth)
2683 if (r_u == NULL)
2684 return False;
2686 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2687 depth++;
2689 if(!prs_align(ps))
2690 return False;
2692 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2693 return False;
2695 if (r_u->ptr != 0) {
2696 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2697 return False;
2700 if(!prs_align(ps))
2701 return False;
2702 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2703 return False;
2705 return True;
2708 /*******************************************************************
2709 inits a SAMR_Q_QUERY_GROUPMEM structure.
2710 ********************************************************************/
2712 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2714 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2716 q_c->group_pol = *hnd;
2719 /*******************************************************************
2720 reads or writes a structure.
2721 ********************************************************************/
2723 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2724 prs_struct *ps, int depth)
2726 if (q_u == NULL)
2727 return False;
2729 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2730 depth++;
2732 if(!prs_align(ps))
2733 return False;
2735 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2736 return False;
2738 return True;
2741 /*******************************************************************
2742 inits a SAMR_R_QUERY_GROUPMEM structure.
2743 ********************************************************************/
2745 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2746 uint32 num_entries, uint32 *rid,
2747 uint32 *attr, NTSTATUS status)
2749 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2751 if (NT_STATUS_IS_OK(status)) {
2752 r_u->ptr = 1;
2753 r_u->num_entries = num_entries;
2755 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2756 r_u->ptr_rids = rid != NULL ? 1 : 0;
2758 r_u->num_rids = num_entries;
2759 r_u->rid = rid;
2761 r_u->num_attrs = num_entries;
2762 r_u->attr = attr;
2763 } else {
2764 r_u->ptr = 0;
2765 r_u->num_entries = 0;
2768 r_u->status = status;
2771 /*******************************************************************
2772 reads or writes a structure.
2773 ********************************************************************/
2775 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2776 prs_struct *ps, int depth)
2778 uint32 i;
2780 if (r_u == NULL)
2781 return False;
2783 if (UNMARSHALLING(ps))
2784 ZERO_STRUCTP(r_u);
2786 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2787 depth++;
2789 if(!prs_align(ps))
2790 return False;
2792 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2793 return False;
2794 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2795 return False;
2797 if (r_u->ptr != 0) {
2798 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2799 return False;
2800 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2801 return False;
2803 if (r_u->ptr_rids != 0) {
2804 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2805 return False;
2806 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2807 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2808 if (r_u->rid == NULL)
2809 return False;
2812 for (i = 0; i < r_u->num_rids; i++) {
2813 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2814 return False;
2818 if (r_u->ptr_attrs != 0) {
2819 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2820 return False;
2822 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2823 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2824 if (r_u->attr == NULL)
2825 return False;
2828 for (i = 0; i < r_u->num_attrs; i++) {
2829 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2830 return False;
2835 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2836 return False;
2838 return True;
2841 /*******************************************************************
2842 inits a SAMR_Q_QUERY_USERGROUPS structure.
2843 ********************************************************************/
2845 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2846 POLICY_HND *hnd)
2848 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2850 q_u->pol = *hnd;
2853 /*******************************************************************
2854 reads or writes a structure.
2855 ********************************************************************/
2857 BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2858 prs_struct *ps, int depth)
2860 if (q_u == NULL)
2861 return False;
2863 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2864 depth++;
2866 if(!prs_align(ps))
2867 return False;
2869 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2870 return False;
2872 return True;
2875 /*******************************************************************
2876 inits a SAMR_R_QUERY_USERGROUPS structure.
2877 ********************************************************************/
2879 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2880 uint32 num_gids, DOM_GID * gid,
2881 NTSTATUS status)
2883 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2885 if (NT_STATUS_IS_OK(status)) {
2886 r_u->ptr_0 = 1;
2887 r_u->num_entries = num_gids;
2888 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2889 r_u->num_entries2 = num_gids;
2891 r_u->gid = gid;
2892 } else {
2893 r_u->ptr_0 = 0;
2894 r_u->num_entries = 0;
2895 r_u->ptr_1 = 0;
2896 r_u->gid = NULL;
2899 r_u->status = status;
2902 /*******************************************************************
2903 reads or writes a structure.
2904 ********************************************************************/
2906 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
2907 prs_struct *ps, int depth)
2909 uint32 i;
2910 if (gid == NULL)
2911 return False;
2913 prs_debug(ps, depth, desc, "samr_io_gids");
2914 depth++;
2916 if(!prs_align(ps))
2917 return False;
2919 if(!prs_uint32("num_gids", ps, depth, num_gids))
2920 return False;
2922 if ((*num_gids) != 0) {
2923 if (UNMARSHALLING(ps)) {
2924 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
2927 if ((*gid) == NULL) {
2928 return False;
2931 for (i = 0; i < (*num_gids); i++) {
2932 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
2933 return False;
2937 return True;
2940 /*******************************************************************
2941 reads or writes a structure.
2942 ********************************************************************/
2944 BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
2945 prs_struct *ps, int depth)
2947 if (r_u == NULL)
2948 return False;
2950 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
2951 depth++;
2953 if(!prs_align(ps))
2954 return False;
2956 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
2957 return False;
2959 if (r_u->ptr_0 != 0) {
2960 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2961 return False;
2962 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
2963 return False;
2965 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
2966 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
2967 return False;
2971 if(!prs_align(ps))
2972 return False;
2973 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2974 return False;
2976 return True;
2979 /*******************************************************************
2980 inits a SAMR_Q_ENUM_DOMAINS structure.
2981 ********************************************************************/
2983 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
2984 POLICY_HND *pol,
2985 uint32 start_idx, uint32 size)
2987 DEBUG(5, ("init_samr_q_enum_domains\n"));
2989 q_e->pol = *pol;
2991 q_e->start_idx = start_idx;
2992 q_e->max_size = size;
2995 /*******************************************************************
2996 reads or writes a structure.
2997 ********************************************************************/
2999 BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3000 prs_struct *ps, int depth)
3002 if (q_e == NULL)
3003 return False;
3005 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3006 depth++;
3008 if(!prs_align(ps))
3009 return False;
3011 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3012 return False;
3014 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3015 return False;
3016 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3017 return False;
3019 return True;
3022 /*******************************************************************
3023 inits a SAMR_R_ENUM_DOMAINS structure.
3024 ********************************************************************/
3026 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3027 uint32 next_idx, uint32 num_sam_entries)
3029 DEBUG(5, ("init_samr_r_enum_domains\n"));
3031 r_u->next_idx = next_idx;
3033 if (num_sam_entries != 0) {
3034 r_u->ptr_entries1 = 1;
3035 r_u->ptr_entries2 = 1;
3036 r_u->num_entries2 = num_sam_entries;
3037 r_u->num_entries3 = num_sam_entries;
3039 r_u->num_entries4 = num_sam_entries;
3040 } else {
3041 r_u->ptr_entries1 = 0;
3042 r_u->num_entries2 = num_sam_entries;
3043 r_u->ptr_entries2 = 1;
3047 /*******************************************************************
3048 reads or writes a structure.
3049 ********************************************************************/
3051 BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3052 prs_struct *ps, int depth)
3054 uint32 i;
3056 if (r_u == NULL)
3057 return False;
3059 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3060 depth++;
3062 if(!prs_align(ps))
3063 return False;
3065 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3066 return False;
3067 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3068 return False;
3070 if (r_u->ptr_entries1 != 0) {
3071 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3072 return False;
3073 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3074 return False;
3075 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3076 return False;
3078 if (UNMARSHALLING(ps)) {
3079 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3080 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3083 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3084 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3085 r_u->num_entries4 = 0;
3086 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3087 return False;
3090 for (i = 0; i < r_u->num_entries2; i++) {
3091 fstring tmp;
3092 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3093 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3094 return False;
3097 for (i = 0; i < r_u->num_entries2; i++) {
3098 fstring tmp;
3099 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3100 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3101 r_u->sam[i].hdr_name.buffer, ps,
3102 depth))
3103 return False;
3108 if(!prs_align(ps))
3109 return False;
3110 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3111 return False;
3112 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3113 return False;
3115 return True;
3118 /*******************************************************************
3119 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3120 ********************************************************************/
3122 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3123 POLICY_HND *pol,
3124 uint32 start_idx, uint32 size)
3126 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3128 q_e->pol = *pol;
3130 q_e->start_idx = start_idx;
3131 q_e->max_size = size;
3134 /*******************************************************************
3135 reads or writes a structure.
3136 ********************************************************************/
3138 BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3139 prs_struct *ps, int depth)
3141 if (q_e == NULL)
3142 return False;
3144 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3145 depth++;
3147 if(!prs_align(ps))
3148 return False;
3150 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3151 return False;
3153 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3154 return False;
3155 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3156 return False;
3158 return True;
3161 /*******************************************************************
3162 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3163 ********************************************************************/
3165 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3166 uint32 next_idx, uint32 num_sam_entries)
3168 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3170 r_u->next_idx = next_idx;
3172 if (num_sam_entries != 0) {
3173 r_u->ptr_entries1 = 1;
3174 r_u->ptr_entries2 = 1;
3175 r_u->num_entries2 = num_sam_entries;
3176 r_u->num_entries3 = num_sam_entries;
3178 r_u->num_entries4 = num_sam_entries;
3179 } else {
3180 r_u->ptr_entries1 = 0;
3181 r_u->num_entries2 = num_sam_entries;
3182 r_u->ptr_entries2 = 1;
3186 /*******************************************************************
3187 reads or writes a structure.
3188 ********************************************************************/
3190 BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3191 prs_struct *ps, int depth)
3193 uint32 i;
3195 if (r_u == NULL)
3196 return False;
3198 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3199 depth++;
3201 if(!prs_align(ps))
3202 return False;
3204 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3205 return False;
3206 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3207 return False;
3209 if (r_u->ptr_entries1 != 0) {
3210 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3211 return False;
3212 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3213 return False;
3214 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3215 return False;
3217 if (UNMARSHALLING(ps)) {
3218 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3219 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3222 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3223 DEBUG(0,
3224 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3225 r_u->num_entries4 = 0;
3226 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3227 return False;
3230 for (i = 0; i < r_u->num_entries2; i++) {
3231 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3232 return False;
3235 for (i = 0; i < r_u->num_entries2; i++) {
3236 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3237 r_u->sam[i].hdr_name.buffer, ps, depth))
3238 return False;
3242 if(!prs_align(ps))
3243 return False;
3244 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3245 return False;
3246 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3247 return False;
3249 return True;
3252 /*******************************************************************
3253 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3254 ********************************************************************/
3256 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3257 POLICY_HND *pol, uint32 start_idx,
3258 uint32 size)
3260 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3262 q_e->pol = *pol;
3264 q_e->start_idx = start_idx;
3265 q_e->max_size = size;
3269 /*******************************************************************
3270 reads or writes a structure.
3271 ********************************************************************/
3273 BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3274 prs_struct *ps, int depth)
3276 if (q_e == NULL)
3277 return False;
3279 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3280 depth++;
3282 if(!prs_align(ps))
3283 return False;
3285 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3286 return False;
3288 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3289 return False;
3290 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3291 return False;
3293 return True;
3296 /*******************************************************************
3297 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3298 ********************************************************************/
3300 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3302 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3304 r_u->next_idx = next_idx;
3306 if (num_sam_entries != 0) {
3307 r_u->ptr_entries1 = 1;
3308 r_u->ptr_entries2 = 1;
3309 r_u->num_entries2 = num_sam_entries;
3310 r_u->num_entries3 = num_sam_entries;
3312 r_u->num_entries4 = num_sam_entries;
3313 } else {
3314 r_u->ptr_entries1 = 0;
3315 r_u->num_entries2 = num_sam_entries;
3316 r_u->ptr_entries2 = 1;
3320 /*******************************************************************
3321 reads or writes a structure.
3322 ********************************************************************/
3324 BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3325 prs_struct *ps, int depth)
3327 uint32 i;
3329 if (r_u == NULL)
3330 return False;
3332 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3333 depth++;
3335 if(!prs_align(ps))
3336 return False;
3338 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3339 return False;
3340 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3341 return False;
3343 if (r_u->ptr_entries1 != 0) {
3344 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3345 return False;
3346 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3347 return False;
3348 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3349 return False;
3351 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3352 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3353 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3356 if (r_u->num_entries2 != 0 &&
3357 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3358 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3359 r_u->num_entries4 = 0;
3360 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3361 return False;
3364 for (i = 0; i < r_u->num_entries2; i++) {
3365 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3366 return False;
3369 for (i = 0; i < r_u->num_entries2; i++) {
3370 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3371 r_u->sam[i].hdr_name.buffer, ps,
3372 depth))
3373 return False;
3377 if(!prs_align(ps))
3378 return False;
3379 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3380 return False;
3381 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3382 return False;
3384 return True;
3387 /*******************************************************************
3388 inits a ALIAS_INFO1 structure.
3389 ********************************************************************/
3391 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3393 int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0;
3394 int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0;
3396 DEBUG(5, ("init_samr_alias_info1\n"));
3398 init_uni_hdr(&al1->hdr_acct_name, acct_len_name);
3399 init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name);
3401 al1->num_member=num_member;
3403 init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc);
3404 init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc);
3407 /*******************************************************************
3408 reads or writes a structure.
3409 ********************************************************************/
3411 BOOL samr_io_alias_info1(char *desc, ALIAS_INFO1 * al1,
3412 prs_struct *ps, int depth)
3414 if (al1 == NULL)
3415 return False;
3417 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3418 depth++;
3420 if(!prs_align(ps))
3421 return False;
3423 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3424 return False;
3425 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3426 return False;
3427 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3428 return False;
3430 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3431 al1->hdr_acct_name.buffer, ps, depth))
3432 return False;
3434 if(!prs_align(ps))
3435 return False;
3437 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3438 al1->hdr_acct_desc.buffer, ps, depth))
3439 return False;
3441 return True;
3444 /*******************************************************************
3445 inits a ALIAS_INFO3 structure.
3446 ********************************************************************/
3448 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3450 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3452 DEBUG(5, ("init_samr_alias_info3\n"));
3454 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3455 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3458 /*******************************************************************
3459 reads or writes a structure.
3460 ********************************************************************/
3462 BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
3463 prs_struct *ps, int depth)
3465 if (al3 == NULL)
3466 return False;
3468 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3469 depth++;
3471 if(!prs_align(ps))
3472 return False;
3474 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3475 return False;
3476 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3477 al3->hdr_acct_desc.buffer, ps, depth))
3478 return False;
3480 return True;
3483 /*******************************************************************
3484 reads or writes a structure.
3485 ********************************************************************/
3487 BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
3488 prs_struct *ps, int depth)
3490 if (ctr == NULL)
3491 return False;
3493 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3494 depth++;
3496 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3497 return False;
3498 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3499 return False;
3501 switch (ctr->switch_value1) {
3502 case 1:
3503 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3504 return False;
3505 break;
3506 case 3:
3507 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3508 return False;
3509 break;
3510 default:
3511 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3512 break;
3515 return True;
3518 /*******************************************************************
3519 inits a SAMR_Q_QUERY_ALIASINFO structure.
3520 ********************************************************************/
3522 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3523 POLICY_HND *pol, uint16 switch_level)
3525 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3527 q_e->pol = *pol;
3528 q_e->switch_level = switch_level;
3531 /*******************************************************************
3532 reads or writes a structure.
3533 ********************************************************************/
3535 BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3536 prs_struct *ps, int depth)
3538 if (q_e == NULL)
3539 return False;
3541 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3542 depth++;
3544 if(!prs_align(ps))
3545 return False;
3547 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3548 return False;
3550 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3551 return False;
3553 return True;
3556 /*******************************************************************
3557 inits a SAMR_R_QUERY_ALIASINFO structure.
3558 ********************************************************************/
3560 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3561 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3563 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3565 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3566 r_u->ctr = *ctr;
3567 r_u->status = status;
3570 /*******************************************************************
3571 reads or writes a structure.
3572 ********************************************************************/
3574 BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3575 prs_struct *ps, int depth)
3577 if (r_u == NULL)
3578 return False;
3580 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3581 depth++;
3583 if(!prs_align(ps))
3584 return False;
3586 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3587 return False;
3589 if (r_u->ptr != 0) {
3590 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3591 return False;
3594 if(!prs_align(ps))
3595 return False;
3596 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3597 return False;
3599 return True;
3602 /*******************************************************************
3603 inits a SAMR_Q_SET_ALIASINFO structure.
3604 ********************************************************************/
3606 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3607 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3609 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3611 q_u->alias_pol = *hnd;
3612 q_u->ctr = *ctr;
3615 /*******************************************************************
3616 reads or writes a structure.
3617 ********************************************************************/
3619 BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3620 prs_struct *ps, int depth)
3622 if (q_u == NULL)
3623 return False;
3625 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3626 depth++;
3628 if(!prs_align(ps))
3629 return False;
3631 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3632 return False;
3633 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3634 return False;
3636 return True;
3639 /*******************************************************************
3640 reads or writes a structure.
3641 ********************************************************************/
3643 BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
3644 prs_struct *ps, int depth)
3646 if (r_u == NULL)
3647 return False;
3649 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3650 depth++;
3652 if(!prs_align(ps))
3653 return False;
3654 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3655 return False;
3657 return True;
3660 /*******************************************************************
3661 inits a SAMR_Q_QUERY_USERALIASES structure.
3662 ********************************************************************/
3664 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3665 POLICY_HND *hnd,
3666 uint32 num_sids,
3667 uint32 *ptr_sid, DOM_SID2 * sid)
3669 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3671 q_u->pol = *hnd;
3673 q_u->num_sids1 = num_sids;
3674 q_u->ptr = 1;
3675 q_u->num_sids2 = num_sids;
3677 q_u->ptr_sid = ptr_sid;
3678 q_u->sid = sid;
3681 /*******************************************************************
3682 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3683 ********************************************************************/
3685 BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3686 prs_struct *ps, int depth)
3688 fstring tmp;
3689 uint32 i;
3691 if (q_u == NULL)
3692 return False;
3694 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3695 depth++;
3697 if(!prs_align(ps))
3698 return False;
3700 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3701 return False;
3703 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3704 return False;
3705 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3706 return False;
3708 if (q_u->ptr==0)
3709 return True;
3711 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3712 return False;
3714 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3715 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3716 if (q_u->ptr_sid == NULL)
3717 return False;
3719 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3720 if (q_u->sid == NULL)
3721 return False;
3724 for (i = 0; i < q_u->num_sids2; i++) {
3725 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3726 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3727 return False;
3730 for (i = 0; i < q_u->num_sids2; i++) {
3731 if (q_u->ptr_sid[i] != 0) {
3732 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3733 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3734 return False;
3738 return True;
3741 /*******************************************************************
3742 inits a SAMR_R_QUERY_USERALIASES structure.
3743 ********************************************************************/
3745 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3746 uint32 num_rids, uint32 *rid,
3747 NTSTATUS status)
3749 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3751 if (NT_STATUS_IS_OK(status)) {
3752 r_u->num_entries = num_rids;
3753 r_u->ptr = 1;
3754 r_u->num_entries2 = num_rids;
3756 r_u->rid = rid;
3757 } else {
3758 r_u->num_entries = 0;
3759 r_u->ptr = 0;
3760 r_u->num_entries2 = 0;
3763 r_u->status = status;
3766 /*******************************************************************
3767 reads or writes a structure.
3768 ********************************************************************/
3770 BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
3771 prs_struct *ps, int depth)
3773 fstring tmp;
3774 uint32 i;
3775 if (rid == NULL)
3776 return False;
3778 prs_debug(ps, depth, desc, "samr_io_rids");
3779 depth++;
3781 if(!prs_align(ps))
3782 return False;
3784 if(!prs_uint32("num_rids", ps, depth, num_rids))
3785 return False;
3787 if ((*num_rids) != 0) {
3788 if (UNMARSHALLING(ps)) {
3789 /* reading */
3790 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3792 if ((*rid) == NULL)
3793 return False;
3795 for (i = 0; i < (*num_rids); i++) {
3796 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3797 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3798 return False;
3802 return True;
3805 /*******************************************************************
3806 reads or writes a structure.
3807 ********************************************************************/
3809 BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3810 prs_struct *ps, int depth)
3812 if (r_u == NULL)
3813 return False;
3815 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3816 depth++;
3818 if(!prs_align(ps))
3819 return False;
3821 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3822 return False;
3823 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3824 return False;
3826 if (r_u->ptr != 0) {
3827 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3828 return False;
3831 if(!prs_align(ps))
3832 return False;
3833 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3834 return False;
3836 return True;
3839 /*******************************************************************
3840 inits a SAMR_Q_OPEN_ALIAS structure.
3841 ********************************************************************/
3843 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3844 uint32 access_mask, uint32 rid)
3846 DEBUG(5, ("init_samr_q_open_alias\n"));
3848 q_u->dom_pol = *pol;
3849 q_u->access_mask = access_mask;
3850 q_u->rid_alias = rid;
3853 /*******************************************************************
3854 reads or writes a structure.
3855 ********************************************************************/
3857 BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3858 prs_struct *ps, int depth)
3860 if (q_u == NULL)
3861 return False;
3863 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3864 depth++;
3866 if(!prs_align(ps))
3867 return False;
3869 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3870 return False;
3872 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3873 return False;
3874 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3875 return False;
3877 return True;
3880 /*******************************************************************
3881 reads or writes a structure.
3882 ********************************************************************/
3884 BOOL samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS * r_u,
3885 prs_struct *ps, int depth)
3887 if (r_u == NULL)
3888 return False;
3890 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3891 depth++;
3893 if(!prs_align(ps))
3894 return False;
3896 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3897 return False;
3899 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3900 return False;
3902 return True;
3905 /*******************************************************************
3906 inits a SAMR_Q_LOOKUP_RIDS structure.
3907 ********************************************************************/
3909 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3910 POLICY_HND *pol, uint32 flags,
3911 uint32 num_rids, uint32 *rid)
3913 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3915 q_u->pol = *pol;
3917 q_u->num_rids1 = num_rids;
3918 q_u->flags = flags;
3919 q_u->ptr = 0;
3920 q_u->num_rids2 = num_rids;
3921 q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0]));
3922 if (q_u->rid == NULL) {
3923 q_u->num_rids1 = 0;
3924 q_u->num_rids2 = 0;
3925 } else {
3926 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
3930 /*******************************************************************
3931 reads or writes a structure.
3932 ********************************************************************/
3934 BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
3935 prs_struct *ps, int depth)
3937 uint32 i;
3938 fstring tmp;
3940 if (q_u == NULL)
3941 return False;
3943 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
3944 depth++;
3946 if (UNMARSHALLING(ps))
3947 ZERO_STRUCTP(q_u);
3949 if(!prs_align(ps))
3950 return False;
3952 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3953 return False;
3955 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
3956 return False;
3957 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
3958 return False;
3959 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3960 return False;
3961 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
3962 return False;
3964 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
3965 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
3966 if (q_u->rid == NULL)
3967 return False;
3970 for (i = 0; i < q_u->num_rids2; i++) {
3971 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
3972 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
3973 return False;
3976 return True;
3979 /*******************************************************************
3980 inits a SAMR_R_LOOKUP_RIDS structure.
3981 ********************************************************************/
3983 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
3984 uint32 num_names, UNIHDR * hdr_name,
3985 UNISTR2 *uni_name, uint32 *type)
3987 DEBUG(5, ("init_samr_r_lookup_rids\n"));
3989 r_u->hdr_name = NULL;
3990 r_u->uni_name = NULL;
3991 r_u->type = NULL;
3993 if (num_names != 0) {
3994 r_u->num_names1 = num_names;
3995 r_u->ptr_names = 1;
3996 r_u->num_names2 = num_names;
3998 r_u->num_types1 = num_names;
3999 r_u->ptr_types = 1;
4000 r_u->num_types2 = num_names;
4002 r_u->hdr_name = hdr_name;
4003 r_u->uni_name = uni_name;
4004 r_u->type = type;
4005 } else {
4006 r_u->num_names1 = num_names;
4007 r_u->ptr_names = 0;
4008 r_u->num_names2 = num_names;
4010 r_u->num_types1 = num_names;
4011 r_u->ptr_types = 0;
4012 r_u->num_types2 = num_names;
4016 /*******************************************************************
4017 reads or writes a structure.
4018 ********************************************************************/
4020 BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4021 prs_struct *ps, int depth)
4023 uint32 i;
4024 fstring tmp;
4025 if (r_u == NULL)
4026 return False;
4028 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4029 depth++;
4031 if(!prs_align(ps))
4032 return False;
4034 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4035 return False;
4036 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4037 return False;
4039 if (r_u->ptr_names != 0) {
4041 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4042 return False;
4045 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4046 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
4047 if (r_u->hdr_name == NULL)
4048 return False;
4050 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
4051 if (r_u->uni_name == NULL)
4052 return False;
4055 for (i = 0; i < r_u->num_names2; i++) {
4056 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4057 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4058 return False;
4060 for (i = 0; i < r_u->num_names2; i++) {
4061 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4062 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4063 return False;
4068 if(!prs_align(ps))
4069 return False;
4070 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4071 return False;
4072 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4073 return False;
4075 if (r_u->ptr_types != 0) {
4077 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4078 return False;
4080 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4081 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
4082 if (r_u->type == NULL)
4083 return False;
4086 for (i = 0; i < r_u->num_types2; i++) {
4087 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4088 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4089 return False;
4093 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4094 return False;
4096 return True;
4099 /*******************************************************************
4100 inits a SAMR_Q_OPEN_ALIAS structure.
4101 ********************************************************************/
4103 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4105 DEBUG(5, ("init_samr_q_delete_alias\n"));
4107 q_u->alias_pol = *hnd;
4110 /*******************************************************************
4111 reads or writes a structure.
4112 ********************************************************************/
4114 BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4115 prs_struct *ps, int depth)
4117 if (q_u == NULL)
4118 return False;
4120 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4121 depth++;
4123 if(!prs_align(ps))
4124 return False;
4126 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4127 return False;
4129 return True;
4132 /*******************************************************************
4133 reads or writes a structure.
4134 ********************************************************************/
4136 BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4137 prs_struct *ps, int depth)
4139 if (r_u == NULL)
4140 return False;
4142 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4143 depth++;
4145 if(!prs_align(ps))
4146 return False;
4148 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4149 return False;
4150 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4151 return False;
4153 return True;
4156 /*******************************************************************
4157 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4158 ********************************************************************/
4160 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4161 POLICY_HND *hnd, char *acct_desc)
4163 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
4165 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4167 q_u->dom_pol = *hnd;
4169 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
4170 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
4172 q_u->access_mask = 0x001f000f;
4175 /*******************************************************************
4176 reads or writes a structure.
4177 ********************************************************************/
4179 BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4180 prs_struct *ps, int depth)
4182 if (q_u == NULL)
4183 return False;
4185 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4186 depth++;
4188 if(!prs_align(ps))
4189 return False;
4191 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4192 return False;
4194 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4195 return False;
4196 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4197 q_u->hdr_acct_desc.buffer, ps, depth))
4198 return False;
4200 if(!prs_align(ps))
4201 return False;
4202 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4203 return False;
4205 return True;
4208 /*******************************************************************
4209 reads or writes a structure.
4210 ********************************************************************/
4212 BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4213 prs_struct *ps, int depth)
4215 if (r_u == NULL)
4216 return False;
4218 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4219 depth++;
4221 if(!prs_align(ps))
4222 return False;
4224 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4225 return False;
4227 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4228 return False;
4230 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4231 return False;
4233 return True;
4236 /*******************************************************************
4237 inits a SAMR_Q_ADD_ALIASMEM structure.
4238 ********************************************************************/
4240 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4241 DOM_SID *sid)
4243 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4245 q_u->alias_pol = *hnd;
4246 init_dom_sid2(&q_u->sid, sid);
4249 /*******************************************************************
4250 reads or writes a structure.
4251 ********************************************************************/
4253 BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4254 prs_struct *ps, int depth)
4256 if (q_u == NULL)
4257 return False;
4259 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4260 depth++;
4262 if(!prs_align(ps))
4263 return False;
4265 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4266 return False;
4267 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4268 return False;
4270 return True;
4273 /*******************************************************************
4274 reads or writes a structure.
4275 ********************************************************************/
4277 BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4278 prs_struct *ps, int depth)
4280 if (r_u == NULL)
4281 return False;
4283 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4284 depth++;
4286 if(!prs_align(ps))
4287 return False;
4289 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4290 return False;
4292 return True;
4295 /*******************************************************************
4296 inits a SAMR_Q_DEL_ALIASMEM structure.
4297 ********************************************************************/
4299 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4300 DOM_SID *sid)
4302 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4304 q_u->alias_pol = *hnd;
4305 init_dom_sid2(&q_u->sid, sid);
4308 /*******************************************************************
4309 reads or writes a structure.
4310 ********************************************************************/
4312 BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4313 prs_struct *ps, int depth)
4315 if (q_u == NULL)
4316 return False;
4318 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4319 depth++;
4321 if(!prs_align(ps))
4322 return False;
4324 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4325 return False;
4326 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4327 return False;
4329 return True;
4332 /*******************************************************************
4333 reads or writes a structure.
4334 ********************************************************************/
4336 BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4337 prs_struct *ps, int depth)
4339 if (r_u == NULL)
4340 return False;
4342 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4343 depth++;
4345 if(!prs_align(ps))
4346 return False;
4348 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4349 return False;
4351 return True;
4354 /*******************************************************************
4355 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4356 ********************************************************************/
4358 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4359 POLICY_HND *hnd)
4361 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4363 q_c->alias_pol = *hnd;
4366 /*******************************************************************
4367 reads or writes a structure.
4368 ********************************************************************/
4370 BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4371 prs_struct *ps, int depth)
4373 if (q_u == NULL)
4374 return False;
4376 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4377 depth++;
4379 if(!prs_align(ps))
4380 return False;
4382 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4383 return False;
4385 return True;
4388 /*******************************************************************
4389 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4390 ********************************************************************/
4392 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4393 NTSTATUS status)
4395 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4397 r_u->status = status;
4400 /*******************************************************************
4401 reads or writes a structure.
4402 ********************************************************************/
4404 BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4405 prs_struct *ps, int depth)
4407 if (r_u == NULL)
4408 return False;
4410 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4411 depth++;
4413 if(!prs_align(ps))
4414 return False;
4416 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4417 return False;
4419 return True;
4422 /*******************************************************************
4423 inits a SAMR_Q_QUERY_ALIASMEM structure.
4424 ********************************************************************/
4426 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4427 POLICY_HND *hnd)
4429 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4431 q_c->alias_pol = *hnd;
4434 /*******************************************************************
4435 reads or writes a structure.
4436 ********************************************************************/
4438 BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4439 prs_struct *ps, int depth)
4441 if (q_u == NULL)
4442 return False;
4444 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4445 depth++;
4447 if(!prs_align(ps))
4448 return False;
4450 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4451 return False;
4453 return True;
4456 /*******************************************************************
4457 inits a SAMR_R_QUERY_ALIASMEM structure.
4458 ********************************************************************/
4460 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4461 uint32 num_sids, DOM_SID2 * sid,
4462 NTSTATUS status)
4464 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4466 if (NT_STATUS_IS_OK(status)) {
4467 r_u->num_sids = num_sids;
4468 r_u->ptr = (num_sids != 0) ? 1 : 0;
4469 r_u->num_sids1 = num_sids;
4471 r_u->sid = sid;
4472 } else {
4473 r_u->ptr = 0;
4474 r_u->num_sids = 0;
4477 r_u->status = status;
4480 /*******************************************************************
4481 reads or writes a structure.
4482 ********************************************************************/
4484 BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4485 prs_struct *ps, int depth)
4487 uint32 i;
4488 uint32 ptr_sid[MAX_LOOKUP_SIDS];
4490 if (r_u == NULL)
4491 return False;
4493 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4494 depth++;
4496 if(!prs_align(ps))
4497 return False;
4499 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4500 return False;
4501 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4502 return False;
4504 if (r_u->ptr != 0) {
4505 SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids);
4507 if (r_u->num_sids != 0) {
4508 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4509 return False;
4511 for (i = 0; i < r_u->num_sids1; i++) {
4512 ptr_sid[i] = 1;
4513 if(!prs_uint32("", ps, depth, &ptr_sid[i]))
4514 return False;
4517 for (i = 0; i < r_u->num_sids1; i++) {
4518 if (ptr_sid[i] != 0) {
4519 if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth))
4520 return False;
4526 if(!prs_align(ps))
4527 return False;
4528 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4529 return False;
4531 return True;
4534 /*******************************************************************
4535 inits a SAMR_Q_LOOKUP_NAMES structure.
4536 ********************************************************************/
4538 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4539 POLICY_HND *pol, uint32 flags,
4540 uint32 num_names, char **name)
4542 uint32 i;
4544 DEBUG(5, ("init_samr_q_lookup_names\n"));
4546 q_u->pol = *pol;
4548 q_u->num_names1 = num_names;
4549 q_u->flags = flags;
4550 q_u->ptr = 0;
4551 q_u->num_names2 = num_names;
4553 if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR))))
4554 return NT_STATUS_NO_MEMORY;
4556 if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2))))
4557 return NT_STATUS_NO_MEMORY;
4559 for (i = 0; i < num_names; i++) {
4560 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4561 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4562 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4565 return NT_STATUS_OK;
4568 /*******************************************************************
4569 reads or writes a structure.
4570 ********************************************************************/
4572 BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4573 prs_struct *ps, int depth)
4575 uint32 i;
4577 if (q_u == NULL)
4578 return False;
4580 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4581 depth++;
4583 if (UNMARSHALLING(ps))
4584 ZERO_STRUCTP(q_u);
4586 if(!prs_align(ps))
4587 return False;
4589 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4590 return False;
4592 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4593 return False;
4594 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4595 return False;
4596 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4597 return False;
4598 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4599 return False;
4601 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4602 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4603 q_u->num_names2);
4604 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4605 q_u->num_names2);
4606 if (!q_u->hdr_name || !q_u->uni_name)
4607 return False;
4610 for (i = 0; i < q_u->num_names2; i++) {
4611 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4612 return False;
4615 for (i = 0; i < q_u->num_names2; i++) {
4616 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4617 return False;
4620 return True;
4623 /*******************************************************************
4624 inits a SAMR_R_LOOKUP_NAMES structure.
4625 ********************************************************************/
4627 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4628 uint32 num_rids,
4629 uint32 *rid, uint32 *type,
4630 NTSTATUS status)
4632 DEBUG(5, ("init_samr_r_lookup_names\n"));
4634 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4635 uint32 i;
4637 r_u->num_types1 = num_rids;
4638 r_u->ptr_types = 1;
4639 r_u->num_types2 = num_rids;
4641 r_u->num_rids1 = num_rids;
4642 r_u->ptr_rids = 1;
4643 r_u->num_rids2 = num_rids;
4645 if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4646 return NT_STATUS_NO_MEMORY;
4647 if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4648 return NT_STATUS_NO_MEMORY;
4650 if (!r_u->rids || !r_u->types)
4651 goto empty;
4653 for (i = 0; i < num_rids; i++) {
4654 r_u->rids[i] = rid[i];
4655 r_u->types[i] = type[i];
4657 } else {
4659 empty:
4660 r_u->num_types1 = 0;
4661 r_u->ptr_types = 0;
4662 r_u->num_types2 = 0;
4664 r_u->num_rids1 = 0;
4665 r_u->ptr_rids = 0;
4666 r_u->num_rids2 = 0;
4668 r_u->rids = NULL;
4669 r_u->types = NULL;
4672 r_u->status = status;
4674 return NT_STATUS_OK;
4677 /*******************************************************************
4678 reads or writes a structure.
4679 ********************************************************************/
4681 BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4682 prs_struct *ps, int depth)
4684 uint32 i;
4685 fstring tmp;
4687 if (r_u == NULL)
4688 return False;
4690 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4691 depth++;
4693 if (UNMARSHALLING(ps))
4694 ZERO_STRUCTP(r_u);
4696 if(!prs_align(ps))
4697 return False;
4699 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4700 return False;
4701 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4702 return False;
4704 if (r_u->ptr_rids != 0) {
4705 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4706 return False;
4708 if (r_u->num_rids2 != r_u->num_rids1) {
4709 /* RPC fault */
4710 return False;
4713 if (UNMARSHALLING(ps))
4714 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4716 if (!r_u->rids) {
4717 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4718 return False;
4721 for (i = 0; i < r_u->num_rids2; i++) {
4722 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4723 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4724 return False;
4728 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4729 return False;
4730 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4731 return False;
4733 if (r_u->ptr_types != 0) {
4734 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4735 return False;
4737 if (r_u->num_types2 != r_u->num_types1) {
4738 /* RPC fault */
4739 return False;
4742 if (UNMARSHALLING(ps))
4743 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4745 if (!r_u->types) {
4746 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4747 return False;
4750 for (i = 0; i < r_u->num_types2; i++) {
4751 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4752 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4753 return False;
4757 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4758 return False;
4760 return True;
4763 /*******************************************************************
4764 inits a SAMR_Q_DELETE_DOM_USER structure.
4765 ********************************************************************/
4767 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4768 POLICY_HND *hnd)
4770 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4772 q_c->user_pol = *hnd;
4775 /*******************************************************************
4776 reads or writes a structure.
4777 ********************************************************************/
4779 BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4780 prs_struct *ps, int depth)
4782 if (q_u == NULL)
4783 return False;
4785 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4786 depth++;
4788 if(!prs_align(ps))
4789 return False;
4791 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4792 return False;
4794 return True;
4797 /*******************************************************************
4798 reads or writes a structure.
4799 ********************************************************************/
4801 BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4802 prs_struct *ps, int depth)
4804 if (r_u == NULL)
4805 return False;
4807 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4808 depth++;
4810 if(!prs_align(ps))
4811 return False;
4813 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4814 return False;
4815 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4816 return False;
4818 return True;
4821 /*******************************************************************
4822 reads or writes a structure.
4823 ********************************************************************/
4825 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4826 POLICY_HND *pol,
4827 uint32 access_mask, uint32 rid)
4829 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4831 q_u->domain_pol = *pol;
4832 q_u->access_mask = access_mask;
4833 q_u->user_rid = rid;
4836 /*******************************************************************
4837 reads or writes a structure.
4838 ********************************************************************/
4840 BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
4841 prs_struct *ps, int depth)
4843 if (q_u == NULL)
4844 return False;
4846 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4847 depth++;
4849 if(!prs_align(ps))
4850 return False;
4852 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4853 return False;
4855 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4856 return False;
4857 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4858 return False;
4860 return True;
4863 /*******************************************************************
4864 reads or writes a structure.
4865 ********************************************************************/
4867 BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
4868 prs_struct *ps, int depth)
4870 if (r_u == NULL)
4871 return False;
4873 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4874 depth++;
4876 if(!prs_align(ps))
4877 return False;
4879 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4880 return False;
4882 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4883 return False;
4885 return True;
4889 /*******************************************************************
4890 reads or writes a structure.
4891 ********************************************************************/
4893 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4894 POLICY_HND *pol,
4895 const char *name,
4896 uint32 acb_info, uint32 access_mask)
4898 int len_name;
4899 len_name = strlen(name);
4901 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4903 q_u->domain_pol = *pol;
4905 init_uni_hdr(&q_u->hdr_name, len_name);
4906 init_unistr2(&q_u->uni_name, name, len_name);
4908 q_u->acb_info = acb_info;
4909 q_u->access_mask = access_mask;
4912 /*******************************************************************
4913 reads or writes a structure.
4914 ********************************************************************/
4916 BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
4917 prs_struct *ps, int depth)
4919 if (q_u == NULL)
4920 return False;
4922 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4923 depth++;
4925 if(!prs_align(ps))
4926 return False;
4928 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4929 return False;
4931 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
4932 return False;
4933 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
4934 return False;
4936 if(!prs_align(ps))
4937 return False;
4938 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
4939 return False;
4940 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4941 return False;
4943 return True;
4946 /*******************************************************************
4947 reads or writes a structure.
4948 ********************************************************************/
4950 BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
4951 prs_struct *ps, int depth)
4953 if (r_u == NULL)
4954 return False;
4956 prs_debug(ps, depth, desc, "samr_io_r_create_user");
4957 depth++;
4959 if(!prs_align(ps))
4960 return False;
4962 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4963 return False;
4965 if(!prs_uint32("unknown_0", ps, depth, &r_u->unknown_0))
4966 return False;
4967 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
4968 return False;
4969 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4970 return False;
4972 return True;
4975 /*******************************************************************
4976 inits a SAMR_Q_QUERY_USERINFO structure.
4977 ********************************************************************/
4979 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
4980 POLICY_HND *hnd, uint16 switch_value)
4982 DEBUG(5, ("init_samr_q_query_userinfo\n"));
4984 q_u->pol = *hnd;
4985 q_u->switch_value = switch_value;
4988 /*******************************************************************
4989 reads or writes a structure.
4990 ********************************************************************/
4992 BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
4993 prs_struct *ps, int depth)
4995 if (q_u == NULL)
4996 return False;
4998 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
4999 depth++;
5001 if(!prs_align(ps))
5002 return False;
5004 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5005 return False;
5007 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5008 return False;
5010 return True;
5013 /*******************************************************************
5014 reads or writes a LOGON_HRS structure.
5015 ********************************************************************/
5017 static BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs,
5018 prs_struct *ps, int depth)
5020 if (hrs == NULL)
5021 return False;
5023 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5024 depth++;
5026 if(!prs_align(ps))
5027 return False;
5029 if(!prs_uint32("len ", ps, depth, &hrs->len))
5030 return False;
5032 if (hrs->len > sizeof(hrs->hours)) {
5033 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5034 hrs->len = sizeof(hrs->hours);
5037 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5038 return False;
5040 return True;
5043 /*******************************************************************
5044 inits a SAM_USER_INFO_12 structure.
5045 ********************************************************************/
5047 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5048 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5050 DEBUG(5, ("init_sam_user_info12\n"));
5052 usr->lm_pwd_active =
5053 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5054 usr->nt_pwd_active =
5055 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5058 /*******************************************************************
5059 reads or writes a structure.
5060 ********************************************************************/
5062 static BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
5063 prs_struct *ps, int depth)
5065 if (u == NULL)
5066 return False;
5068 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5069 depth++;
5071 if(!prs_align(ps))
5072 return False;
5074 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5075 return False;
5076 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5077 return False;
5079 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5080 return False;
5081 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5082 return False;
5084 return True;
5087 /*******************************************************************
5088 inits a SAM_USER_INFO_10 structure.
5089 ********************************************************************/
5091 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5093 DEBUG(5, ("init_sam_user_info10\n"));
5095 usr->acb_info = acb_info;
5098 /*******************************************************************
5099 reads or writes a structure.
5100 ********************************************************************/
5102 static BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
5103 prs_struct *ps, int depth)
5105 if (usr == NULL)
5106 return False;
5108 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5109 depth++;
5111 if(!prs_align(ps))
5112 return False;
5114 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5115 return False;
5117 return True;
5120 /*******************************************************************
5121 inits a SAM_USER_INFO_11 structure.
5122 ********************************************************************/
5124 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5125 NTTIME * expiry,
5126 char *mach_acct,
5127 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5129 int len_mach_acct;
5131 DEBUG(5, ("init_sam_user_info11\n"));
5133 len_mach_acct = strlen(mach_acct);
5135 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
5136 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5138 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
5139 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5141 usr->ptr_1 = 1; /* pointer */
5142 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5143 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5145 usr->ptr_2 = 1; /* pointer */
5146 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5148 usr->ptr_3 = 1; /* pointer */
5149 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5151 usr->rid_user = rid_user;
5152 usr->rid_group = rid_group;
5154 usr->acct_ctrl = acct_ctrl;
5155 usr->unknown_3 = 0x0000;
5157 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5158 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5160 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5161 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5163 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
5166 /*******************************************************************
5167 reads or writes a structure.
5168 ********************************************************************/
5170 static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
5171 prs_struct *ps, int depth)
5173 if (usr == NULL)
5174 return False;
5176 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5177 depth++;
5179 if(!prs_align(ps))
5180 return False;
5182 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5183 return False;
5185 if(!smb_io_time("time", &usr->expiry, ps, depth))
5186 return False;
5188 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5189 return False;
5191 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5192 return False;
5194 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5195 return False;
5197 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5198 return False;
5199 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5200 return False;
5202 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5203 return False;
5205 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5206 return False;
5207 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5208 return False;
5210 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5211 return False;
5212 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5213 return False;
5215 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5216 return False;
5217 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5218 return False;
5219 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5220 return False;
5221 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5222 return False;
5223 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5224 return False;
5225 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5226 return False;
5228 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5229 return False;
5231 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5232 return False;
5234 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5235 return False;
5237 if(!prs_align(ps))
5238 return False;
5240 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5241 return False;
5243 return True;
5246 /*************************************************************************
5247 init_sam_user_infoa
5249 unknown_3 = 0x09f8 27fa
5250 unknown_5 = 0x0001 0000
5251 unknown_6 = 0x0000 04ec
5253 *************************************************************************/
5255 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5257 DEBUG(10, ("init_sam_user_info24:\n"));
5258 memcpy(usr->pass, newpass, sizeof(usr->pass));
5259 usr->pw_len = pw_len;
5262 /*******************************************************************
5263 reads or writes a structure.
5264 ********************************************************************/
5266 static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
5267 prs_struct *ps, int depth)
5269 if (usr == NULL)
5270 return False;
5272 prs_debug(ps, depth, desc, "sam_io_user_info24");
5273 depth++;
5275 if(!prs_align(ps))
5276 return False;
5278 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5279 sizeof(usr->pass)))
5280 return False;
5282 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5283 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5284 return False;
5286 if(!prs_align(ps))
5287 return False;
5289 return True;
5292 /*************************************************************************
5293 init_sam_user_info23
5295 unknown_3 = 0x09f8 27fa
5296 unknown_5 = 0x0001 0000
5297 unknown_6 = 0x0000 04ec
5299 *************************************************************************/
5301 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5302 NTTIME * logoff_time, /* all zeros */
5303 NTTIME * kickoff_time, /* all zeros */
5304 NTTIME * pass_last_set_time, /* all zeros */
5305 NTTIME * pass_can_change_time, /* all zeros */
5306 NTTIME * pass_must_change_time, /* all zeros */
5307 UNISTR2 *user_name,
5308 UNISTR2 *full_name,
5309 UNISTR2 *home_dir,
5310 UNISTR2 *dir_drive,
5311 UNISTR2 *log_scr,
5312 UNISTR2 *prof_path,
5313 UNISTR2 *desc,
5314 UNISTR2 *wkstas,
5315 UNISTR2 *unk_str,
5316 UNISTR2 *mung_dial,
5317 uint32 user_rid, /* 0x0000 0000 */
5318 uint32 group_rid,
5319 uint32 acb_info,
5320 uint32 unknown_3,
5321 uint16 logon_divs,
5322 LOGON_HRS * hrs,
5323 uint32 unknown_5,
5324 char newpass[516], uint32 unknown_6)
5326 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5327 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5328 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5329 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5330 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5331 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5332 int len_description = desc != NULL ? desc->uni_str_len : 0;
5333 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5334 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5335 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5337 usr->logon_time = *logon_time; /* all zeros */
5338 usr->logoff_time = *logoff_time; /* all zeros */
5339 usr->kickoff_time = *kickoff_time; /* all zeros */
5340 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5341 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5342 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5344 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5345 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5346 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5347 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5348 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5349 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5350 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5351 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5352 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5353 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5355 ZERO_STRUCT(usr->nt_pwd);
5356 ZERO_STRUCT(usr->lm_pwd);
5358 usr->user_rid = user_rid; /* 0x0000 0000 */
5359 usr->group_rid = group_rid;
5360 usr->acb_info = acb_info;
5361 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5363 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5364 usr->ptr_logon_hrs = hrs ? 1 : 0;
5366 ZERO_STRUCT(usr->padding1);
5368 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5370 memcpy(usr->pass, newpass, sizeof(usr->pass));
5372 copy_unistr2(&usr->uni_user_name, user_name);
5373 copy_unistr2(&usr->uni_full_name, full_name);
5374 copy_unistr2(&usr->uni_home_dir, home_dir);
5375 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5376 copy_unistr2(&usr->uni_logon_script, log_scr);
5377 copy_unistr2(&usr->uni_profile_path, prof_path);
5378 copy_unistr2(&usr->uni_acct_desc, desc);
5379 copy_unistr2(&usr->uni_workstations, wkstas);
5380 copy_unistr2(&usr->uni_unknown_str, unk_str);
5381 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5383 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5384 usr->padding4 = 0;
5386 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5389 /*************************************************************************
5390 init_sam_user_info23
5392 unknown_3 = 0x09f8 27fa
5393 unknown_5 = 0x0001 0000
5394 unknown_6 = 0x0000 04ec
5396 *************************************************************************/
5398 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5399 NTTIME * logoff_time, /* all zeros */
5400 NTTIME * kickoff_time, /* all zeros */
5401 NTTIME * pass_last_set_time, /* all zeros */
5402 NTTIME * pass_can_change_time, /* all zeros */
5403 NTTIME * pass_must_change_time, /* all zeros */
5404 char *user_name, /* NULL */
5405 char *full_name,
5406 char *home_dir, char *dir_drive, char *log_scr,
5407 char *prof_path, char *desc, char *wkstas,
5408 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5409 uint32 group_rid, uint32 acb_info,
5410 uint32 unknown_3, uint16 logon_divs,
5411 LOGON_HRS * hrs, uint32 unknown_5,
5412 char newpass[516], uint32 unknown_6)
5414 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5415 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5416 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5417 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5418 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5419 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5420 int len_description = desc != NULL ? strlen(desc) : 0;
5421 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5422 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5423 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5425 usr->logon_time = *logon_time; /* all zeros */
5426 usr->logoff_time = *logoff_time; /* all zeros */
5427 usr->kickoff_time = *kickoff_time; /* all zeros */
5428 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5429 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5430 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5432 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5433 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5434 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5435 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5436 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5437 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5438 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5439 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5440 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5441 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5443 ZERO_STRUCT(usr->nt_pwd);
5444 ZERO_STRUCT(usr->lm_pwd);
5446 usr->user_rid = user_rid; /* 0x0000 0000 */
5447 usr->group_rid = group_rid;
5448 usr->acb_info = acb_info;
5449 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5451 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5452 usr->ptr_logon_hrs = hrs ? 1 : 0;
5454 ZERO_STRUCT(usr->padding1);
5456 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5458 memcpy(usr->pass, newpass, sizeof(usr->pass));
5460 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5461 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5462 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5463 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5464 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5465 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5466 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5467 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5468 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5469 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5471 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5472 usr->padding4 = 0;
5474 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5477 /*******************************************************************
5478 reads or writes a structure.
5479 ********************************************************************/
5481 static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
5482 prs_struct *ps, int depth)
5484 if (usr == NULL)
5485 return False;
5487 prs_debug(ps, depth, desc, "sam_io_user_info23");
5488 depth++;
5490 if(!prs_align(ps))
5491 return False;
5493 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5494 return False;
5495 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5496 return False;
5497 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5498 return False;
5499 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5500 return False;
5501 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5502 return False;
5503 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5504 return False;
5506 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5507 return False;
5508 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5509 return False;
5510 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5511 return False;
5512 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5513 return False;
5514 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5515 return False;
5516 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5517 return False;
5518 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5519 return False;
5520 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5521 return False;
5522 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5523 return False;
5524 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5525 return False;
5527 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5528 return False;
5529 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5530 return False;
5532 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5533 return False;
5534 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5535 return False;
5536 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5537 return False;
5539 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5540 return False;
5541 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5542 return False;
5543 if(!prs_align(ps))
5544 return False;
5545 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5546 return False;
5547 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5548 return False;
5549 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5550 return False;
5552 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5553 return False;
5555 /* here begins pointed-to data */
5557 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5558 return False;
5560 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5561 return False;
5563 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5564 return False;
5566 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5567 return False;
5569 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5570 return False;
5572 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5573 return False;
5575 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5576 return False;
5578 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5579 return False;
5581 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5582 return False;
5584 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5585 return False;
5587 /* ok, this is only guess-work (as usual) */
5588 if (usr->ptr_logon_hrs) {
5589 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5590 return False;
5591 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5592 return False;
5593 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5594 return False;
5595 } else if (UNMARSHALLING(ps)) {
5596 usr->unknown_6 = 0;
5597 usr->padding4 = 0;
5600 return True;
5603 /*******************************************************************
5604 reads or writes a structure.
5605 NB. This structure is *definately* incorrect. It's my best guess
5606 currently for W2K SP2. The password field is encrypted in a different
5607 way than normal... And there are definately other problems. JRA.
5608 ********************************************************************/
5610 static BOOL sam_io_user_info25(char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5612 if (usr == NULL)
5613 return False;
5615 prs_debug(ps, depth, desc, "sam_io_user_info25");
5616 depth++;
5618 if(!prs_align(ps))
5619 return False;
5621 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5622 return False;
5623 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5624 return False;
5625 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5626 return False;
5627 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5628 return False;
5629 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5630 return False;
5631 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5632 return False;
5634 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5635 return False;
5636 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5637 return False;
5638 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5639 return False;
5640 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5641 return False;
5642 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5643 return False;
5644 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5645 return False;
5646 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5647 return False;
5648 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5649 return False;
5650 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5651 return False;
5652 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5653 return False;
5655 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5656 return False;
5657 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5658 return False;
5660 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5661 return False;
5662 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5663 return False;
5664 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5665 return False;
5667 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5668 return False;
5670 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5671 return False;
5673 /* here begins pointed-to data */
5675 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5676 return False;
5678 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5679 return False;
5681 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5682 return False;
5684 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5685 return False;
5687 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5688 return False;
5690 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5691 return False;
5693 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5694 return False;
5696 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5697 return False;
5699 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5700 return False;
5702 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5703 return False;
5705 #if 0 /* JRA - unknown... */
5706 /* ok, this is only guess-work (as usual) */
5707 if (usr->ptr_logon_hrs) {
5708 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5709 return False;
5710 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5711 return False;
5712 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5713 return False;
5714 } else if (UNMARSHALLING(ps)) {
5715 usr->unknown_6 = 0;
5716 usr->padding4 = 0;
5718 #endif
5720 return True;
5724 /*************************************************************************
5725 init_sam_user_info21W
5727 unknown_3 = 0x00ff ffff
5728 unknown_5 = 0x0002 0000
5729 unknown_6 = 0x0000 04ec
5731 *************************************************************************/
5733 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5734 NTTIME * logon_time,
5735 NTTIME * logoff_time,
5736 NTTIME * kickoff_time,
5737 NTTIME * pass_last_set_time,
5738 NTTIME * pass_can_change_time,
5739 NTTIME * pass_must_change_time,
5740 UNISTR2 *user_name,
5741 UNISTR2 *full_name,
5742 UNISTR2 *home_dir,
5743 UNISTR2 *dir_drive,
5744 UNISTR2 *log_scr,
5745 UNISTR2 *prof_path,
5746 UNISTR2 *desc,
5747 UNISTR2 *wkstas,
5748 UNISTR2 *unk_str,
5749 UNISTR2 *mung_dial,
5750 uchar lm_pwd[16],
5751 uchar nt_pwd[16],
5752 uint32 user_rid,
5753 uint32 group_rid,
5754 uint32 acb_info,
5755 uint32 unknown_3,
5756 uint16 logon_divs,
5757 LOGON_HRS * hrs,
5758 uint32 unknown_5, uint32 unknown_6)
5760 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5761 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5762 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5763 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5764 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5765 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5766 int len_description = desc != NULL ? desc->uni_str_len : 0;
5767 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5768 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5769 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5771 usr->logon_time = *logon_time;
5772 usr->logoff_time = *logoff_time;
5773 usr->kickoff_time = *kickoff_time;
5774 usr->pass_last_set_time = *pass_last_set_time;
5775 usr->pass_can_change_time = *pass_can_change_time;
5776 usr->pass_must_change_time = *pass_must_change_time;
5778 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5779 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5780 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5781 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5782 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5783 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5784 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5785 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5786 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5787 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5789 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5790 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5792 usr->user_rid = user_rid;
5793 usr->group_rid = group_rid;
5794 usr->acb_info = acb_info;
5795 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5797 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5798 usr->ptr_logon_hrs = hrs ? 1 : 0;
5799 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5801 ZERO_STRUCT(usr->padding1);
5803 copy_unistr2(&usr->uni_user_name, user_name);
5804 copy_unistr2(&usr->uni_full_name, full_name);
5805 copy_unistr2(&usr->uni_home_dir, home_dir);
5806 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5807 copy_unistr2(&usr->uni_logon_script, log_scr);
5808 copy_unistr2(&usr->uni_profile_path, prof_path);
5809 copy_unistr2(&usr->uni_acct_desc, desc);
5810 copy_unistr2(&usr->uni_workstations, wkstas);
5811 copy_unistr2(&usr->uni_unknown_str, unk_str);
5812 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5814 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5815 usr->padding4 = 0;
5817 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5820 /*************************************************************************
5821 init_sam_user_info21
5823 unknown_3 = 0x00ff ffff
5824 unknown_5 = 0x0002 0000
5825 unknown_6 = 0x0000 04ec
5827 *************************************************************************/
5829 void init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw)
5831 NTTIME logon_time, logoff_time, kickoff_time,
5832 pass_last_set_time, pass_can_change_time,
5833 pass_must_change_time;
5835 int len_user_name, len_full_name, len_home_dir,
5836 len_dir_drive, len_logon_script, len_profile_path,
5837 len_description, len_workstations, len_unknown_str,
5838 len_munged_dial;
5840 const char* user_name = pdb_get_username(pw);
5841 const char* full_name = pdb_get_fullname(pw);
5842 const char* home_dir = pdb_get_homedir(pw);
5843 const char* dir_drive = pdb_get_dirdrive(pw);
5844 const char* logon_script = pdb_get_logon_script(pw);
5845 const char* profile_path = pdb_get_profile_path(pw);
5846 const char* description = pdb_get_acct_desc(pw);
5847 const char* workstations = pdb_get_workstations(pw);
5848 const char* munged_dial = pdb_get_munged_dial(pw);
5850 len_user_name = user_name != NULL ? strlen(unix_to_dos_static(user_name))+1 : 0;
5851 len_full_name = full_name != NULL ? strlen(unix_to_dos_static(full_name))+1 : 0;
5852 len_home_dir = home_dir != NULL ? strlen(unix_to_dos_static(home_dir))+1 : 0;
5853 len_dir_drive = dir_drive != NULL ? strlen(unix_to_dos_static(dir_drive))+1 : 0;
5854 len_logon_script = logon_script != NULL ? strlen(unix_to_dos_static(logon_script))+1 : 0;
5855 len_profile_path = profile_path != NULL ? strlen(unix_to_dos_static(profile_path))+1 : 0;
5856 len_description = description != NULL ? strlen(unix_to_dos_static(description))+1 : 0;
5857 len_workstations = workstations != NULL ? strlen(unix_to_dos_static(workstations))+1 : 0;
5858 len_unknown_str = 0;
5859 len_munged_dial = munged_dial != NULL ? strlen(unix_to_dos_static(munged_dial))+1 : 0;
5862 /* Create NTTIME structs */
5863 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5864 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5865 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5866 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5867 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
5868 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
5870 /* structure assignment */
5871 usr->logon_time = logon_time;
5872 usr->logoff_time = logoff_time;
5873 usr->kickoff_time = kickoff_time;
5874 usr->pass_last_set_time = pass_last_set_time;
5875 usr->pass_can_change_time = pass_can_change_time;
5876 usr->pass_must_change_time = pass_must_change_time;
5878 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5879 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5880 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5881 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5882 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5883 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5884 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5885 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5886 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5887 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5889 ZERO_STRUCT(usr->nt_pwd);
5890 ZERO_STRUCT(usr->lm_pwd);
5892 usr->user_rid = pdb_get_user_rid(pw);
5893 usr->group_rid = pdb_get_group_rid(pw);
5894 usr->acb_info = pdb_get_acct_ctrl(pw);
5895 usr->unknown_3 = pdb_get_unknown3(pw);
5897 usr->logon_divs = pdb_get_logon_divs(pw);
5898 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
5899 usr->unknown_5 = pdb_get_unknown5(pw); /* 0x0002 0000 */
5901 ZERO_STRUCT(usr->padding1);
5903 init_unistr2(&usr->uni_user_name, unix_to_dos_static(user_name), len_user_name);
5904 init_unistr2(&usr->uni_full_name, unix_to_dos_static(full_name), len_full_name);
5905 init_unistr2(&usr->uni_home_dir, unix_to_dos_static(home_dir), len_home_dir);
5906 init_unistr2(&usr->uni_dir_drive, unix_to_dos_static(dir_drive), len_dir_drive);
5907 init_unistr2(&usr->uni_logon_script, unix_to_dos_static(logon_script), len_logon_script);
5908 init_unistr2(&usr->uni_profile_path, unix_to_dos_static(profile_path), len_profile_path);
5909 init_unistr2(&usr->uni_acct_desc, unix_to_dos_static(description), len_description);
5910 init_unistr2(&usr->uni_workstations, unix_to_dos_static(workstations), len_workstations);
5911 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
5912 init_unistr2(&usr->uni_munged_dial, unix_to_dos_static(munged_dial), len_munged_dial);
5914 usr->unknown_6 = pdb_get_unknown6(pw);
5915 usr->padding4 = 0;
5917 if (pdb_get_hours(pw)) {
5918 usr->logon_hrs.len = pdb_get_hours_len(pw);
5919 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
5920 } else
5921 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
5924 /*******************************************************************
5925 reads or writes a structure.
5926 ********************************************************************/
5928 static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
5929 prs_struct *ps, int depth)
5931 if (usr == NULL)
5932 return False;
5934 prs_debug(ps, depth, desc, "sam_io_user_info21");
5935 depth++;
5937 if(!prs_align(ps))
5938 return False;
5940 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5941 return False;
5942 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5943 return False;
5944 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
5945 return False;
5946 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5947 return False;
5948 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
5949 return False;
5950 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5951 return False;
5953 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5954 return False;
5955 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5956 return False;
5957 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5958 return False;
5959 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5960 return False;
5961 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5962 return False;
5963 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5964 return False;
5965 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5966 return False;
5967 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5968 return False;
5969 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5970 return False;
5971 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5972 return False;
5974 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5975 return False;
5976 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5977 return False;
5979 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5980 return False;
5981 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5982 return False;
5983 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5984 return False;
5986 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5987 return False;
5988 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5989 return False;
5990 if(!prs_align(ps))
5991 return False;
5992 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5993 return False;
5994 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5995 return False;
5997 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5998 return False;
6000 /* here begins pointed-to data */
6002 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6003 return False;
6004 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6005 return False;
6006 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6007 return False;
6008 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6009 return False;
6010 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6011 return False;
6012 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6013 return False;
6014 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6015 return False;
6016 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6017 return False;
6018 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6019 return False;
6020 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6021 return False;
6023 /* ok, this is only guess-work (as usual) */
6024 if (usr->ptr_logon_hrs) {
6025 if(!prs_align(ps))
6026 return False;
6027 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6028 return False;
6029 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6030 return False;
6031 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6032 return False;
6033 } else if (UNMARSHALLING(ps)) {
6034 usr->unknown_6 = 0;
6035 usr->padding4 = 0;
6038 return True;
6041 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6043 int len_munged_dial;
6044 const char* munged_dial = pdb_get_munged_dial(pw);
6046 len_munged_dial = munged_dial != NULL ? strlen(unix_to_dos_static(munged_dial))+1 : 0;
6047 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6048 init_unistr2(&usr->uni_munged_dial, unix_to_dos_static(munged_dial), len_munged_dial);
6052 /*******************************************************************
6053 reads or writes a structure.
6054 ********************************************************************/
6056 static BOOL sam_io_user_info20(char *desc, SAM_USER_INFO_20 *usr,
6057 prs_struct *ps, int depth)
6059 if (usr == NULL)
6060 return False;
6062 prs_debug(ps, depth, desc, "sam_io_user_info20");
6063 depth++;
6065 if(!prs_align(ps))
6066 return False;
6068 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6069 return False;
6071 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6072 return False;
6074 return True;
6077 /*******************************************************************
6078 inits a SAM_USERINFO_CTR structure.
6079 ********************************************************************/
6081 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6082 uint16 switch_value,
6083 SAM_USER_INFO_21 * usr)
6085 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6087 ctr->switch_value = switch_value;
6088 ctr->info.id = NULL;
6090 switch (switch_value) {
6091 case 0x10:
6092 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
6093 if (ctr->info.id10 == NULL)
6094 return NT_STATUS_NO_MEMORY;
6096 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6097 break;
6098 #if 0
6099 /* whoops - got this wrong. i think. or don't understand what's happening. */
6100 case 0x11:
6102 NTTIME expire;
6103 info = (void *)&id11;
6105 expire.low = 0xffffffff;
6106 expire.high = 0x7fffffff;
6108 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
6109 init_sam_user_info11(ctr->info.id11, &expire,
6110 "BROOKFIELDS$", /* name */
6111 0x03ef, /* user rid */
6112 0x201, /* group rid */
6113 0x0080); /* acb info */
6115 break;
6117 #endif
6118 case 0x12:
6119 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
6120 if (ctr->info.id12 == NULL)
6121 return NT_STATUS_NO_MEMORY;
6123 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6124 break;
6125 case 21:
6127 SAM_USER_INFO_21 *cusr;
6128 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
6129 ctr->info.id21 = cusr;
6130 if (ctr->info.id21 == NULL)
6131 return NT_STATUS_NO_MEMORY;
6132 memcpy(cusr, usr, sizeof(*usr));
6133 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6134 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6135 break;
6137 default:
6138 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6139 return NT_STATUS_INVALID_INFO_CLASS;
6142 return NT_STATUS_OK;
6145 /*******************************************************************
6146 inits a SAM_USERINFO_CTR structure.
6147 ********************************************************************/
6149 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
6150 uint16 switch_value, void *info)
6152 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6154 ctr->switch_value = switch_value;
6155 ctr->info.id = info;
6157 switch (switch_value) {
6158 case 0x18:
6159 SamOEMhash(ctr->info.id24->pass, sess_key, 516);
6160 dump_data(100, (char *)sess_key, 16);
6161 dump_data(100, (char *)ctr->info.id24->pass, 516);
6162 break;
6163 case 0x17:
6164 SamOEMhash(ctr->info.id23->pass, sess_key, 516);
6165 dump_data(100, (char *)sess_key, 16);
6166 dump_data(100, (char *)ctr->info.id23->pass, 516);
6167 break;
6168 default:
6169 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6173 /*******************************************************************
6174 reads or writes a structure.
6175 ********************************************************************/
6177 static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR **ppctr,
6178 prs_struct *ps, int depth)
6180 BOOL ret;
6181 SAM_USERINFO_CTR *ctr;
6183 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6184 depth++;
6186 if (UNMARSHALLING(ps)) {
6187 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
6188 if (ctr == NULL)
6189 return False;
6190 *ppctr = ctr;
6191 } else {
6192 ctr = *ppctr;
6195 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6197 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6198 return False;
6199 if(!prs_align(ps))
6200 return False;
6202 ret = False;
6204 switch (ctr->switch_value) {
6205 case 0x10:
6206 if (UNMARSHALLING(ps))
6207 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
6208 if (ctr->info.id10 == NULL) {
6209 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6210 return False;
6212 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6213 break;
6214 case 0x11:
6215 if (UNMARSHALLING(ps))
6216 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
6218 if (ctr->info.id11 == NULL) {
6219 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6220 return False;
6222 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6223 break;
6224 case 0x12:
6225 if (UNMARSHALLING(ps))
6226 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
6228 if (ctr->info.id12 == NULL) {
6229 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6230 return False;
6232 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6233 break;
6234 case 20:
6235 if (UNMARSHALLING(ps))
6236 ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20));
6238 if (ctr->info.id20 == NULL) {
6239 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6240 return False;
6242 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6243 break;
6244 case 21:
6245 if (UNMARSHALLING(ps))
6246 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
6248 if (ctr->info.id21 == NULL) {
6249 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6250 return False;
6252 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6253 break;
6254 case 23:
6255 if (UNMARSHALLING(ps))
6256 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
6258 if (ctr->info.id23 == NULL) {
6259 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6260 return False;
6262 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6263 break;
6264 case 24:
6265 if (UNMARSHALLING(ps))
6266 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
6268 if (ctr->info.id24 == NULL) {
6269 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6270 return False;
6272 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6273 break;
6274 case 25:
6275 if (UNMARSHALLING(ps))
6276 ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25));
6278 if (ctr->info.id25 == NULL) {
6279 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6280 return False;
6282 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6283 break;
6284 default:
6285 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6286 ret = False;
6287 break;
6290 return ret;
6293 /*******************************************************************
6294 inits a SAMR_R_QUERY_USERINFO structure.
6295 ********************************************************************/
6297 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6298 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6300 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6302 r_u->ptr = 0;
6303 r_u->ctr = NULL;
6305 if (NT_STATUS_IS_OK(status)) {
6306 r_u->ptr = 1;
6307 r_u->ctr = ctr;
6310 r_u->status = status; /* return status */
6313 /*******************************************************************
6314 reads or writes a structure.
6315 ********************************************************************/
6317 BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
6318 prs_struct *ps, int depth)
6320 if (r_u == NULL)
6321 return False;
6323 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6324 depth++;
6326 if(!prs_align(ps))
6327 return False;
6329 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6330 return False;
6332 if (r_u->ptr != 0) {
6333 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6334 return False;
6337 if(!prs_align(ps))
6338 return False;
6339 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6340 return False;
6342 return True;
6345 /*******************************************************************
6346 inits a SAMR_Q_SET_USERINFO structure.
6347 ********************************************************************/
6349 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6350 POLICY_HND *hnd, unsigned char sess_key[16],
6351 uint16 switch_value, void *info)
6353 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6355 q_u->pol = *hnd;
6356 q_u->switch_value = switch_value;
6357 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6360 /*******************************************************************
6361 reads or writes a structure.
6362 ********************************************************************/
6364 BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
6365 prs_struct *ps, int depth)
6367 if (q_u == NULL)
6368 return False;
6370 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6371 depth++;
6373 if(!prs_align(ps))
6374 return False;
6376 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6378 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6379 return False;
6380 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6381 return False;
6383 return True;
6386 /*******************************************************************
6387 inits a SAMR_R_SET_USERINFO structure.
6388 ********************************************************************/
6390 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6392 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6394 r_u->status = status; /* return status */
6397 /*******************************************************************
6398 reads or writes a structure.
6399 ********************************************************************/
6401 BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
6402 prs_struct *ps, int depth)
6404 if (r_u == NULL)
6405 return False;
6407 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6408 depth++;
6410 if(!prs_align(ps))
6411 return False;
6413 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6414 return False;
6416 return True;
6419 /*******************************************************************
6420 inits a SAMR_Q_SET_USERINFO2 structure.
6421 ********************************************************************/
6423 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6424 POLICY_HND *hnd, unsigned char sess_key[16],
6425 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6427 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6429 q_u->pol = *hnd;
6430 q_u->switch_value = switch_value;
6431 q_u->ctr = ctr;
6433 if (q_u->ctr != NULL)
6434 q_u->ctr->switch_value = switch_value;
6436 switch (switch_value) {
6437 case 0x12:
6438 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16);
6439 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16);
6440 dump_data(100, (char *)sess_key, 16);
6441 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6442 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6443 break;
6447 /*******************************************************************
6448 reads or writes a structure.
6449 ********************************************************************/
6451 BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6452 prs_struct *ps, int depth)
6454 if (q_u == NULL)
6455 return False;
6457 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6458 depth++;
6460 if(!prs_align(ps))
6461 return False;
6463 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6464 return False;
6466 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6467 return False;
6468 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6469 return False;
6471 return True;
6474 /*******************************************************************
6475 inits a SAMR_R_SET_USERINFO2 structure.
6476 ********************************************************************/
6478 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6480 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6482 r_u->status = status; /* return status */
6485 /*******************************************************************
6486 reads or writes a structure.
6487 ********************************************************************/
6489 BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
6490 prs_struct *ps, int depth)
6492 if (r_u == NULL)
6493 return False;
6495 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6496 depth++;
6498 if(!prs_align(ps))
6499 return False;
6501 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6502 return False;
6504 return True;
6507 /*******************************************************************
6508 inits a SAMR_Q_CONNECT structure.
6509 ********************************************************************/
6511 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6512 char *srv_name, uint32 access_mask)
6514 int len_srv_name = strlen(srv_name);
6516 DEBUG(5, ("init_samr_q_connect\n"));
6518 /* make PDC server name \\server */
6519 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6520 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6522 /* example values: 0x0000 0002 */
6523 q_u->access_mask = access_mask;
6526 /*******************************************************************
6527 reads or writes a structure.
6528 ********************************************************************/
6530 BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
6531 prs_struct *ps, int depth)
6533 if (q_u == NULL)
6534 return False;
6536 prs_debug(ps, depth, desc, "samr_io_q_connect");
6537 depth++;
6539 if(!prs_align(ps))
6540 return False;
6542 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6543 return False;
6544 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6545 return False;
6547 if(!prs_align(ps))
6548 return False;
6549 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6550 return False;
6552 return True;
6555 /*******************************************************************
6556 reads or writes a structure.
6557 ********************************************************************/
6559 BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
6560 prs_struct *ps, int depth)
6562 if (r_u == NULL)
6563 return False;
6565 prs_debug(ps, depth, desc, "samr_io_r_connect");
6566 depth++;
6568 if(!prs_align(ps))
6569 return False;
6571 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6572 return False;
6574 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6575 return False;
6577 return True;
6580 /*******************************************************************
6581 inits a SAMR_Q_CONNECT_ANON structure.
6582 ********************************************************************/
6584 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6586 DEBUG(5, ("init_samr_q_connect_anon\n"));
6588 q_u->ptr = 1;
6589 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6590 q_u->unknown_1 = 0x01;
6591 q_u->access_mask = 0x20;
6594 /*******************************************************************
6595 reads or writes a structure.
6596 ********************************************************************/
6598 BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
6599 prs_struct *ps, int depth)
6601 if (q_u == NULL)
6602 return False;
6604 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6605 depth++;
6607 if(!prs_align(ps))
6608 return False;
6610 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6611 return False;
6612 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6613 return False;
6614 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6615 return False;
6616 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6617 return False;
6619 return True;
6622 /*******************************************************************
6623 reads or writes a structure.
6624 ********************************************************************/
6626 BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
6627 prs_struct *ps, int depth)
6629 if (r_u == NULL)
6630 return False;
6632 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6633 depth++;
6635 if(!prs_align(ps))
6636 return False;
6638 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6639 return False;
6641 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6642 return False;
6644 return True;
6647 /*******************************************************************
6648 inits a SAMR_Q_GET_DOM_PWINFO structure.
6649 ********************************************************************/
6651 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6652 char *srv_name)
6654 int len_srv_name = strlen(srv_name);
6656 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6658 q_u->ptr = 1;
6659 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6660 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6663 /*******************************************************************
6664 reads or writes a structure.
6665 ********************************************************************/
6667 BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6668 prs_struct *ps, int depth)
6670 if (q_u == NULL)
6671 return False;
6673 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6674 depth++;
6676 if(!prs_align(ps))
6677 return False;
6679 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6680 return False;
6681 if (q_u->ptr != 0) {
6682 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6683 return False;
6684 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6685 return False;
6688 return True;
6691 /*******************************************************************
6692 reads or writes a structure.
6693 ********************************************************************/
6695 BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6696 prs_struct *ps, int depth)
6698 if (r_u == NULL)
6699 return False;
6701 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6702 depth++;
6704 if(!prs_align(ps))
6705 return False;
6708 * we need 16 bytes herre according to tests. Don't know
6709 * what they are, but the length is important for the singing
6712 if(!prs_uint32("unk_0", ps, depth, &r_u->unk_0))
6713 return False;
6714 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
6715 return False;
6716 if(!prs_uint32("unk_2", ps, depth, &r_u->unk_2))
6717 return False;
6719 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6720 return False;
6722 return True;
6725 /*******************************************************************
6726 make a SAMR_ENC_PASSWD structure.
6727 ********************************************************************/
6729 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
6731 ZERO_STRUCTP(pwd);
6733 if (pass == NULL) {
6734 pwd->ptr = 0;
6735 } else {
6736 pwd->ptr = 1;
6737 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6741 /*******************************************************************
6742 reads or writes a SAMR_ENC_PASSWD structure.
6743 ********************************************************************/
6745 BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
6746 prs_struct *ps, int depth)
6748 if (pwd == NULL)
6749 return False;
6751 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6752 depth++;
6754 if(!prs_align(ps))
6755 return False;
6757 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
6758 return False;
6760 if (pwd->ptr != 0) {
6761 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
6762 return False;
6765 return True;
6768 /*******************************************************************
6769 inits a SAMR_ENC_HASH structure.
6770 ********************************************************************/
6772 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
6774 ZERO_STRUCTP(hsh);
6776 if (hash == NULL) {
6777 hsh->ptr = 0;
6778 } else {
6779 hsh->ptr = 1;
6780 memcpy(hsh->hash, hash, sizeof(hsh->hash));
6784 /*******************************************************************
6785 reads or writes a SAMR_ENC_HASH structure.
6786 ********************************************************************/
6788 BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
6789 prs_struct *ps, int depth)
6791 if (hsh == NULL)
6792 return False;
6794 prs_debug(ps, depth, desc, "samr_io_enc_hash");
6795 depth++;
6797 if(!prs_align(ps))
6798 return False;
6800 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
6801 return False;
6802 if (hsh->ptr != 0) {
6803 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
6804 return False;
6807 return True;
6810 /*******************************************************************
6811 inits a SAMR_R_GET_DOM_PWINFO structure.
6812 ********************************************************************/
6814 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
6815 char *dest_host, char *user_name,
6816 char nt_newpass[516],
6817 uchar nt_oldhash[16],
6818 char lm_newpass[516],
6819 uchar lm_oldhash[16])
6821 int len_dest_host = strlen(dest_host);
6822 int len_user_name = strlen(user_name);
6824 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
6826 q_u->ptr_0 = 1;
6827 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
6828 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
6829 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
6830 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
6832 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
6833 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
6835 q_u->unknown = 0x01;
6837 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
6838 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
6841 /*******************************************************************
6842 reads or writes a structure.
6843 ********************************************************************/
6845 BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
6846 prs_struct *ps, int depth)
6848 if (q_u == NULL)
6849 return False;
6851 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
6852 depth++;
6854 if(!prs_align(ps))
6855 return False;
6857 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
6858 return False;
6860 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
6861 return False;
6862 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
6863 return False;
6865 if(!prs_align(ps))
6866 return False;
6867 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
6868 return False;
6869 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
6870 return False;
6872 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
6873 return False;
6874 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
6875 return False;
6877 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
6878 return False;
6880 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
6881 return False;
6882 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
6883 return False;
6885 return True;
6888 /*******************************************************************
6889 inits a SAMR_R_CHGPASSWD_USER structure.
6890 ********************************************************************/
6892 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
6894 DEBUG(5, ("init_r_chgpasswd_user\n"));
6896 r_u->status = status;
6899 /*******************************************************************
6900 reads or writes a structure.
6901 ********************************************************************/
6903 BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
6904 prs_struct *ps, int depth)
6906 if (r_u == NULL)
6907 return False;
6909 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
6910 depth++;
6912 if(!prs_align(ps))
6913 return False;
6915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6916 return False;
6918 return True;
6921 /*******************************************************************
6922 reads or writes a structure.
6923 ********************************************************************/
6925 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
6926 POLICY_HND *domain_pol, uint16 switch_value)
6928 DEBUG(5, ("init_samr_q_unknown_2e\n"));
6930 q_u->domain_pol = *domain_pol;
6931 q_u->switch_value = switch_value;
6934 /*******************************************************************
6935 reads or writes a structure.
6936 ********************************************************************/
6938 BOOL samr_io_q_unknown_2e(char *desc, SAMR_Q_UNKNOWN_2E *q_u,
6939 prs_struct *ps, int depth)
6941 if (q_u == NULL)
6942 return False;
6944 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
6945 depth++;
6947 if(!prs_align(ps))
6948 return False;
6950 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
6951 return False;
6953 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6954 return False;
6956 return True;
6959 /*******************************************************************
6960 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
6961 ********************************************************************/
6963 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
6964 uint16 switch_value, SAM_UNK_CTR * ctr,
6965 NTSTATUS status)
6967 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
6969 r_u->ptr_0 = 0;
6970 r_u->switch_value = 0;
6971 r_u->status = status; /* return status */
6973 if (NT_STATUS_IS_OK(status)) {
6974 r_u->switch_value = switch_value;
6975 r_u->ptr_0 = 1;
6976 r_u->ctr = ctr;
6980 /*******************************************************************
6981 reads or writes a structure.
6982 ********************************************************************/
6984 BOOL samr_io_r_samr_unknown_2e(char *desc, SAMR_R_UNKNOWN_2E * r_u,
6985 prs_struct *ps, int depth)
6987 if (r_u == NULL)
6988 return False;
6990 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
6991 depth++;
6993 if(!prs_align(ps))
6994 return False;
6996 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
6997 return False;
6999 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7000 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7001 return False;
7002 if(!prs_align(ps))
7003 return False;
7005 switch (r_u->switch_value) {
7006 case 0x0c:
7007 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7008 return False;
7009 break;
7010 case 0x07:
7011 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7012 return False;
7013 break;
7014 case 0x06:
7015 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7016 return False;
7017 break;
7018 case 0x05:
7019 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7020 return False;
7021 break;
7022 case 0x03:
7023 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7024 return False;
7025 break;
7026 case 0x02:
7027 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7028 return False;
7029 break;
7030 case 0x01:
7031 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7032 return False;
7033 break;
7034 default:
7035 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7036 r_u->switch_value));
7037 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7038 return False;
7042 if(!prs_align(ps))
7043 return False;
7045 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7046 return False;
7048 return True;
7052 /*******************************************************************
7053 reads or writes a structure.
7054 ********************************************************************/
7056 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7057 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7059 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7061 q_u->domain_pol = *domain_pol;
7062 q_u->switch_value0 = switch_value;
7064 q_u->switch_value = switch_value;
7065 q_u->ctr = ctr;
7069 /*******************************************************************
7070 reads or writes a structure.
7071 ********************************************************************/
7073 BOOL samr_io_q_set_domain_info(char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7074 prs_struct *ps, int depth)
7076 if (q_u == NULL)
7077 return False;
7079 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7080 depth++;
7082 if(!prs_align(ps))
7083 return False;
7085 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7086 return False;
7088 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7089 return False;
7091 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7092 return False;
7094 if(!prs_align(ps))
7095 return False;
7097 if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL)
7098 return False;
7100 switch (q_u->switch_value) {
7102 case 0x0c:
7103 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7104 return False;
7105 break;
7106 case 0x07:
7107 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7108 return False;
7109 break;
7110 case 0x06:
7111 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7112 return False;
7113 break;
7114 case 0x05:
7115 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7116 return False;
7117 break;
7118 case 0x03:
7119 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7120 return False;
7121 break;
7122 case 0x02:
7123 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7124 return False;
7125 break;
7126 case 0x01:
7127 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7128 return False;
7129 break;
7130 default:
7131 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7132 q_u->switch_value));
7133 return False;
7136 return True;
7139 /*******************************************************************
7140 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7141 ********************************************************************/
7143 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7145 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7147 r_u->status = status; /* return status */
7150 /*******************************************************************
7151 reads or writes a structure.
7152 ********************************************************************/
7154 BOOL samr_io_r_set_domain_info(char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7155 prs_struct *ps, int depth)
7157 if (r_u == NULL)
7158 return False;
7160 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7161 depth++;
7163 if(!prs_align(ps))
7164 return False;
7166 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7167 return False;
7169 return True;