r6369: update release notes
[Samba.git] / source / rpc_parse / parse_samr.c
blobd3f709c352c839add06f539115b64b6693b75f2f
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Paul Ashton 1997-2000,
7 * Copyright (C) Elrond 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Jean François Micouleau 1998-2001,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
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 #undef DBGC_CLASS
32 #define DBGC_CLASS DBGC_RPC_PARSE
34 /*******************************************************************
35 inits a SAMR_Q_CLOSE_HND structure.
36 ********************************************************************/
38 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
40 DEBUG(5, ("init_samr_q_close_hnd\n"));
42 q_c->pol = *hnd;
45 /*******************************************************************
46 reads or writes a structure.
47 ********************************************************************/
49 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
50 prs_struct *ps, int depth)
52 if (q_u == NULL)
53 return False;
55 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
56 depth++;
58 if(!prs_align(ps))
59 return False;
61 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
64 /*******************************************************************
65 reads or writes a structure.
66 ********************************************************************/
68 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
69 prs_struct *ps, int depth)
71 if (r_u == NULL)
72 return False;
74 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
75 depth++;
77 if(!prs_align(ps))
78 return False;
80 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
81 return False;
83 if(!prs_ntstatus("status", ps, depth, &r_u->status))
84 return False;
86 return True;
89 /*******************************************************************
90 inits a SAMR_Q_LOOKUP_DOMAIN structure.
91 ********************************************************************/
93 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
94 POLICY_HND *pol, char *dom_name)
96 DEBUG(5, ("init_samr_q_lookup_domain\n"));
98 q_u->connect_pol = *pol;
100 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
101 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
104 /*******************************************************************
105 reads or writes a structure.
106 ********************************************************************/
107 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
108 prs_struct *ps, int depth)
110 if (q_u == NULL)
111 return False;
113 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
114 depth++;
116 if(!prs_align(ps))
117 return False;
119 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
120 return False;
122 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
123 return False;
125 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
126 return False;
128 return True;
131 /*******************************************************************
132 inits a SAMR_R_LOOKUP_DOMAIN structure.
133 ********************************************************************/
135 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
136 DOM_SID *dom_sid, NTSTATUS status)
138 DEBUG(5, ("init_samr_r_lookup_domain\n"));
140 r_u->status = status;
141 r_u->ptr_sid = 0;
142 if (NT_STATUS_IS_OK(status)) {
143 r_u->ptr_sid = 1;
144 init_dom_sid2(&r_u->dom_sid, dom_sid);
148 /*******************************************************************
149 reads or writes a structure.
150 ********************************************************************/
152 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
153 prs_struct *ps, int depth)
155 if (r_u == NULL)
156 return False;
158 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
159 depth++;
161 if(!prs_align(ps))
162 return False;
164 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
165 return False;
167 if (r_u->ptr_sid != 0) {
168 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
169 return False;
170 if(!prs_align(ps))
171 return False;
174 if(!prs_ntstatus("status", ps, depth, &r_u->status))
175 return False;
177 return True;
180 /*******************************************************************
181 reads or writes a structure.
182 ********************************************************************/
184 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
186 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
188 q_u->dom_pol = *dom_pol;
189 init_dom_sid2(&q_u->sid, sid);
192 /*******************************************************************
193 reads or writes a structure.
194 ********************************************************************/
196 BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
197 prs_struct *ps, int depth)
199 if (q_u == NULL)
200 return False;
202 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
203 depth++;
205 if(!prs_align(ps))
206 return False;
208 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
209 return False;
211 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
212 return False;
214 if(!prs_align(ps))
215 return False;
217 return True;
220 /*******************************************************************
221 reads or writes a structure.
222 ********************************************************************/
224 BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
225 prs_struct *ps, int depth)
227 if (r_u == NULL)
228 return False;
230 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
231 depth++;
233 if(!prs_align(ps))
234 return False;
236 if(!prs_ntstatus("status", ps, depth, &r_u->status))
237 return False;
239 return True;
242 /*******************************************************************
243 reads or writes a structure.
244 ********************************************************************/
246 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
247 POLICY_HND *pol, uint32 flags,
248 const DOM_SID *sid)
250 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
252 q_u->pol = *pol;
253 q_u->flags = flags;
254 init_dom_sid2(&q_u->dom_sid, sid);
257 /*******************************************************************
258 reads or writes a structure.
259 ********************************************************************/
261 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
262 prs_struct *ps, int depth)
264 if (q_u == NULL)
265 return False;
267 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
268 depth++;
270 if(!prs_align(ps))
271 return False;
273 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
274 return False;
276 if(!prs_uint32("flags", ps, depth, &q_u->flags))
277 return False;
279 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
280 return False;
282 return True;
285 /*******************************************************************
286 reads or writes a structure.
287 ********************************************************************/
289 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
290 prs_struct *ps, int depth)
292 if (r_u == NULL)
293 return False;
295 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
296 depth++;
298 if(!prs_align(ps))
299 return False;
301 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
302 return False;
304 if(!prs_ntstatus("status", ps, depth, &r_u->status))
305 return False;
307 return True;
310 /*******************************************************************
311 reads or writes a structure.
312 ********************************************************************/
314 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
315 POLICY_HND *user_pol)
317 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
319 q_u->user_pol = *user_pol;
322 /*******************************************************************
323 reads or writes a structure.
324 ********************************************************************/
326 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
327 prs_struct *ps, int depth)
329 if (q_u == NULL)
330 return False;
332 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
333 depth++;
335 if(!prs_align(ps))
336 return False;
338 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
341 /*******************************************************************
342 Init.
343 ********************************************************************/
345 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
347 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
349 r_u->unknown_0 = 0x0000;
352 * used to be
353 * r_u->unknown_1 = 0x0015;
354 * but for trusts.
356 r_u->unknown_1 = 0x01D1;
357 r_u->unknown_1 = 0x0015;
359 r_u->unknown_2 = 0x00000000;
361 r_u->status = status;
364 /*******************************************************************
365 reads or writes a structure.
366 ********************************************************************/
368 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
369 prs_struct *ps, int depth)
371 if (r_u == NULL)
372 return False;
374 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
375 depth++;
377 if(!prs_align(ps))
378 return False;
380 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
381 return False;
382 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
383 return False;
384 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
385 return False;
386 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
387 return False;
389 return True;
393 /*******************************************************************
394 reads or writes a structure.
395 ********************************************************************/
397 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
398 prs_struct *ps, int depth)
400 if (q_u == NULL)
401 return False;
403 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
404 depth++;
406 if(!prs_align(ps))
407 return False;
409 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
410 return False;
412 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
413 return False;
415 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
416 return False;
418 return True;
422 /*******************************************************************
423 reads or writes a structure.
424 ********************************************************************/
426 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
427 POLICY_HND *user_pol, uint32 sec_info)
429 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
431 q_u->user_pol = *user_pol;
432 q_u->sec_info = sec_info;
436 /*******************************************************************
437 reads or writes a structure.
438 ********************************************************************/
440 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
441 prs_struct *ps, int depth)
443 if (q_u == NULL)
444 return False;
446 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
447 depth++;
449 if(!prs_align(ps))
450 return False;
452 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
453 return False;
455 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
456 return False;
458 return True;
461 /*******************************************************************
462 reads or writes a structure.
463 ********************************************************************/
465 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
466 POLICY_HND *domain_pol, uint16 switch_value)
468 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
470 q_u->domain_pol = *domain_pol;
471 q_u->switch_value = switch_value;
474 /*******************************************************************
475 reads or writes a structure.
476 ********************************************************************/
478 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
479 prs_struct *ps, int depth)
481 if (q_u == NULL)
482 return False;
484 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
485 depth++;
487 if(!prs_align(ps))
488 return False;
490 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
491 return False;
493 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
494 return False;
496 return True;
500 /*******************************************************************
501 inits a structure.
502 ********************************************************************/
504 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
506 u_3->logout.low = nt_logout.low;
507 u_3->logout.high = nt_logout.high;
510 /*******************************************************************
511 reads or writes a structure.
512 ********************************************************************/
514 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
515 prs_struct *ps, int depth)
517 if (u_3 == NULL)
518 return False;
520 prs_debug(ps, depth, desc, "sam_io_unk_info3");
521 depth++;
523 if(!smb_io_time("logout", &u_3->logout, ps, depth))
524 return False;
526 return True;
529 /*******************************************************************
530 inits a structure.
531 ********************************************************************/
533 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
535 u_6->unknown_0 = 0x00000000;
536 u_6->ptr_0 = 1;
537 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
540 /*******************************************************************
541 reads or writes a structure.
542 ********************************************************************/
544 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
545 prs_struct *ps, int depth)
547 if (u_6 == NULL)
548 return False;
550 prs_debug(ps, depth, desc, "sam_io_unk_info6");
551 depth++;
553 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
554 return False;
555 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
556 return False;
557 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
558 return False;
560 return True;
563 /*******************************************************************
564 inits a structure.
565 ********************************************************************/
567 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
569 u_7->server_role = server_role;
572 /*******************************************************************
573 reads or writes a structure.
574 ********************************************************************/
576 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
577 prs_struct *ps, int depth)
579 if (u_7 == NULL)
580 return False;
582 prs_debug(ps, depth, desc, "sam_io_unk_info7");
583 depth++;
585 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
586 return False;
588 return True;
591 /*******************************************************************
592 inits a structure.
593 ********************************************************************/
595 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
597 unix_to_nt_time(&u_8->domain_create_time, 0);
598 u_8->seq_num.low = seq_num;
599 u_8->seq_num.high = 0x0000;
602 /*******************************************************************
603 reads or writes a structure.
604 ********************************************************************/
606 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
607 prs_struct *ps, int depth)
609 if (u_8 == NULL)
610 return False;
612 prs_debug(ps, depth, desc, "sam_io_unk_info8");
613 depth++;
615 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
616 return False;
618 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
619 return False;
621 return True;
625 /*******************************************************************
626 inits a structure.
627 ********************************************************************/
629 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
631 u_12->duration.low = nt_lock_duration.low;
632 u_12->duration.high = nt_lock_duration.high;
633 u_12->reset_count.low = nt_reset_time.low;
634 u_12->reset_count.high = nt_reset_time.high;
636 u_12->bad_attempt_lockout = lockout;
639 /*******************************************************************
640 reads or writes a structure.
641 ********************************************************************/
643 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
644 prs_struct *ps, int depth)
646 if (u_12 == NULL)
647 return False;
649 prs_debug(ps, depth, desc, "sam_io_unk_info12");
650 depth++;
652 if(!smb_io_time("duration", &u_12->duration, ps, depth))
653 return False;
654 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
655 return False;
656 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
657 return False;
659 return True;
662 /*******************************************************************
663 inits a structure.
664 ********************************************************************/
666 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
668 init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE);
669 init_uni_hdr(&u_5->hdr_server, &u_5->uni_server);
672 /*******************************************************************
673 reads or writes a structure.
674 ********************************************************************/
676 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
677 prs_struct *ps, int depth)
679 if (u_5 == NULL)
680 return False;
682 prs_debug(ps, depth, desc, "sam_io_unk_info5");
683 depth++;
685 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
686 return False;
688 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
689 return False;
691 return True;
694 /*******************************************************************
695 inits a structure.
696 ********************************************************************/
698 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
699 const char *comment, const char *domain, const char *server,
700 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
702 u_2->logout.low = nt_logout.low;
703 u_2->logout.high = nt_logout.high;
705 u_2->seq_num.low = seq_num;
706 u_2->seq_num.high = 0x00000000;
709 u_2->unknown_4 = 0x00000001;
710 u_2->server_role = server_role;
711 u_2->unknown_6 = 0x00000001;
712 u_2->num_domain_usrs = num_users;
713 u_2->num_domain_grps = num_groups;
714 u_2->num_local_grps = num_alias;
716 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
718 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
719 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
720 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
721 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
722 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
723 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
726 /*******************************************************************
727 reads or writes a structure.
728 ********************************************************************/
730 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
731 prs_struct *ps, int depth)
733 if (u_2 == NULL)
734 return False;
736 prs_debug(ps, depth, desc, "sam_io_unk_info2");
737 depth++;
739 if(!smb_io_time("logout", &u_2->logout, ps, depth))
740 return False;
741 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
742 return False;
743 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
744 return False;
745 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
746 return False;
748 /* put all the data in here, at the moment, including what the above
749 pointer is referring to
752 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
753 return False;
755 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
756 return False;
757 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
758 return False;
759 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
760 return False;
761 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
762 return False;
763 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
764 return False;
765 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
766 return False;
768 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
769 return False;
770 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
771 return False;
772 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
773 return False;
775 return True;
778 /*******************************************************************
779 inits a structure.
780 ********************************************************************/
782 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
783 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
785 u_1->min_length_password = min_pass_len;
786 u_1->password_history = pass_hist;
787 u_1->flag = flag;
789 /* password never expire */
790 u_1->expire.high = nt_expire.high;
791 u_1->expire.low = nt_expire.low;
793 /* can change the password now */
794 u_1->min_passwordage.high = nt_min_age.high;
795 u_1->min_passwordage.low = nt_min_age.low;
799 /*******************************************************************
800 reads or writes a structure.
801 ********************************************************************/
803 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
804 prs_struct *ps, int depth)
806 if (u_1 == NULL)
807 return False;
809 prs_debug(ps, depth, desc, "sam_io_unk_info1");
810 depth++;
812 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
813 return False;
814 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
815 return False;
816 if(!prs_uint32("flag", ps, depth, &u_1->flag))
817 return False;
818 if(!smb_io_time("expire", &u_1->expire, ps, depth))
819 return False;
820 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
821 return False;
823 return True;
826 /*******************************************************************
827 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
828 ********************************************************************/
830 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
831 uint16 switch_value, SAM_UNK_CTR * ctr,
832 NTSTATUS status)
834 DEBUG(5, ("init_samr_r_query_dom_info\n"));
836 r_u->ptr_0 = 0;
837 r_u->switch_value = 0;
838 r_u->status = status; /* return status */
840 if (NT_STATUS_IS_OK(status)) {
841 r_u->switch_value = switch_value;
842 r_u->ptr_0 = 1;
843 r_u->ctr = ctr;
847 /*******************************************************************
848 reads or writes a structure.
849 ********************************************************************/
851 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
852 prs_struct *ps, int depth)
854 if (r_u == NULL)
855 return False;
857 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
858 depth++;
860 if(!prs_align(ps))
861 return False;
863 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
864 return False;
866 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
867 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
868 return False;
869 if(!prs_align(ps))
870 return False;
872 switch (r_u->switch_value) {
873 case 0x0c:
874 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
875 return False;
876 break;
877 case 0x08:
878 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
879 return False;
880 break;
881 case 0x07:
882 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
883 return False;
884 break;
885 case 0x06:
886 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
887 return False;
888 break;
889 case 0x05:
890 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
891 return False;
892 break;
893 case 0x03:
894 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
895 return False;
896 break;
897 case 0x02:
898 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
899 return False;
900 break;
901 case 0x01:
902 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
903 return False;
904 break;
905 default:
906 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
907 r_u->switch_value));
908 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
909 return False;
913 if(!prs_align(ps))
914 return False;
916 if(!prs_ntstatus("status", ps, depth, &r_u->status))
917 return False;
919 return True;
922 /*******************************************************************
923 reads or writes a SAMR_R_SET_SEC_OBJ structure.
924 ********************************************************************/
926 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
927 prs_struct *ps, int depth)
929 if (r_u == NULL)
930 return False;
932 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
933 depth++;
935 if(!prs_align(ps))
936 return False;
938 if(!prs_ntstatus("status", ps, depth, &r_u->status))
939 return False;
941 return True;
944 /*******************************************************************
945 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
946 ********************************************************************/
948 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
949 prs_struct *ps, int depth)
951 if (r_u == NULL)
952 return False;
954 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
955 depth++;
957 if(!prs_align(ps))
958 return False;
960 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
961 return False;
962 if (r_u->ptr != 0) {
963 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
964 return False;
967 if(!prs_ntstatus("status", ps, depth, &r_u->status))
968 return False;
970 return True;
973 /*******************************************************************
974 reads or writes a SAM_STR1 structure.
975 ********************************************************************/
977 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
978 uint32 name_buf, uint32 desc_buf,
979 prs_struct *ps, int depth)
981 if (sam == NULL)
982 return False;
984 prs_debug(ps, depth, desc, "sam_io_sam_str1");
985 depth++;
987 if(!prs_align(ps))
988 return False;
989 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
990 return False;
992 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
993 return False;
995 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
996 return False;
998 return True;
1001 /*******************************************************************
1002 inits a SAM_ENTRY1 structure.
1003 ********************************************************************/
1005 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1006 UNISTR2 *sam_name, UNISTR2 *sam_full,
1007 UNISTR2 *sam_desc, uint32 rid_user,
1008 uint16 acb_info)
1010 DEBUG(5, ("init_sam_entry1\n"));
1012 ZERO_STRUCTP(sam);
1014 sam->user_idx = user_idx;
1015 sam->rid_user = rid_user;
1016 sam->acb_info = acb_info;
1018 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1019 init_uni_hdr(&sam->hdr_user_name, sam_full);
1020 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1023 /*******************************************************************
1024 reads or writes a SAM_ENTRY1 structure.
1025 ********************************************************************/
1027 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1028 prs_struct *ps, int depth)
1030 if (sam == NULL)
1031 return False;
1033 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1034 depth++;
1036 if(!prs_align(ps))
1037 return False;
1039 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1040 return False;
1042 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1043 return False;
1044 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1045 return False;
1047 if(!prs_align(ps))
1048 return False;
1050 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1051 return False;
1052 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1053 return False;
1054 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1055 return False;
1057 return True;
1060 /*******************************************************************
1061 reads or writes a SAM_STR2 structure.
1062 ********************************************************************/
1064 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1065 uint32 desc_buf, prs_struct *ps, int depth)
1067 if (sam == NULL)
1068 return False;
1070 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1071 depth++;
1073 if(!prs_align(ps))
1074 return False;
1076 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1077 return False;
1078 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1079 return False;
1081 return True;
1084 /*******************************************************************
1085 inits a SAM_ENTRY2 structure.
1086 ********************************************************************/
1087 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1088 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1089 uint32 rid_user, uint16 acb_info)
1091 DEBUG(5, ("init_sam_entry2\n"));
1093 sam->user_idx = user_idx;
1094 sam->rid_user = rid_user;
1095 sam->acb_info = acb_info;
1097 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1098 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1101 /*******************************************************************
1102 reads or writes a SAM_ENTRY2 structure.
1103 ********************************************************************/
1105 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1106 prs_struct *ps, int depth)
1108 if (sam == NULL)
1109 return False;
1111 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1112 depth++;
1114 if(!prs_align(ps))
1115 return False;
1117 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1118 return False;
1120 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1121 return False;
1122 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1123 return False;
1125 if(!prs_align(ps))
1126 return False;
1128 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1129 return False;
1130 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1131 return False;
1133 return True;
1136 /*******************************************************************
1137 reads or writes a SAM_STR3 structure.
1138 ********************************************************************/
1140 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1141 uint32 desc_buf, prs_struct *ps, int depth)
1143 if (sam == NULL)
1144 return False;
1146 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1147 depth++;
1149 if(!prs_align(ps))
1150 return False;
1152 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1153 return False;
1154 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1155 return False;
1157 return True;
1160 /*******************************************************************
1161 inits a SAM_ENTRY3 structure.
1162 ********************************************************************/
1164 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1165 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1166 uint32 rid_grp)
1168 DEBUG(5, ("init_sam_entry3\n"));
1170 sam->grp_idx = grp_idx;
1171 sam->rid_grp = rid_grp;
1172 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1174 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1175 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1178 /*******************************************************************
1179 reads or writes a SAM_ENTRY3 structure.
1180 ********************************************************************/
1182 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1183 prs_struct *ps, int depth)
1185 if (sam == NULL)
1186 return False;
1188 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1189 depth++;
1191 if(!prs_align(ps))
1192 return False;
1194 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1195 return False;
1197 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1198 return False;
1199 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1200 return False;
1202 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1203 return False;
1204 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1205 return False;
1207 return True;
1210 /*******************************************************************
1211 inits a SAM_ENTRY4 structure.
1212 ********************************************************************/
1214 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1215 uint32 len_acct_name)
1217 DEBUG(5, ("init_sam_entry4\n"));
1219 sam->user_idx = user_idx;
1220 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1223 /*******************************************************************
1224 reads or writes a SAM_ENTRY4 structure.
1225 ********************************************************************/
1227 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1228 prs_struct *ps, int depth)
1230 if (sam == NULL)
1231 return False;
1233 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1234 depth++;
1236 if(!prs_align(ps))
1237 return False;
1239 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1240 return False;
1241 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1242 return False;
1244 return True;
1247 /*******************************************************************
1248 inits a SAM_ENTRY5 structure.
1249 ********************************************************************/
1251 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1252 uint32 len_grp_name)
1254 DEBUG(5, ("init_sam_entry5\n"));
1256 sam->grp_idx = grp_idx;
1257 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1258 len_grp_name != 0);
1261 /*******************************************************************
1262 reads or writes a SAM_ENTRY5 structure.
1263 ********************************************************************/
1265 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1266 prs_struct *ps, int depth)
1268 if (sam == NULL)
1269 return False;
1271 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1272 depth++;
1274 if(!prs_align(ps))
1275 return False;
1277 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1278 return False;
1279 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1280 return False;
1282 return True;
1285 /*******************************************************************
1286 inits a SAM_ENTRY structure.
1287 ********************************************************************/
1289 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1291 DEBUG(10, ("init_sam_entry: %d\n", rid));
1293 sam->rid = rid;
1294 init_uni_hdr(&sam->hdr_name, uni2);
1297 /*******************************************************************
1298 reads or writes a SAM_ENTRY structure.
1299 ********************************************************************/
1301 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1302 prs_struct *ps, int depth)
1304 if (sam == NULL)
1305 return False;
1307 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1308 depth++;
1310 if(!prs_align(ps))
1311 return False;
1312 if(!prs_uint32("rid", ps, depth, &sam->rid))
1313 return False;
1314 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1315 return False;
1317 return True;
1320 /*******************************************************************
1321 inits a SAMR_Q_ENUM_DOM_USERS structure.
1322 ********************************************************************/
1324 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1325 uint32 start_idx,
1326 uint16 acb_mask, uint16 unk_1, uint32 size)
1328 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1330 q_e->pol = *pol;
1332 q_e->start_idx = start_idx; /* zero indicates lots */
1333 q_e->acb_mask = acb_mask;
1334 q_e->unknown_1 = unk_1;
1335 q_e->max_size = size;
1338 /*******************************************************************
1339 reads or writes a structure.
1340 ********************************************************************/
1342 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1343 prs_struct *ps, int depth)
1345 if (q_e == NULL)
1346 return False;
1348 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1349 depth++;
1351 if(!prs_align(ps))
1352 return False;
1354 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1355 return False;
1357 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1358 return False;
1359 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1360 return False;
1361 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1362 return False;
1364 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1365 return False;
1367 return True;
1371 /*******************************************************************
1372 inits a SAMR_R_ENUM_DOM_USERS structure.
1373 ********************************************************************/
1375 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1376 uint32 next_idx, uint32 num_sam_entries)
1378 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1380 r_u->next_idx = next_idx;
1382 if (num_sam_entries != 0) {
1383 r_u->ptr_entries1 = 1;
1384 r_u->ptr_entries2 = 1;
1385 r_u->num_entries2 = num_sam_entries;
1386 r_u->num_entries3 = num_sam_entries;
1388 r_u->num_entries4 = num_sam_entries;
1389 } else {
1390 r_u->ptr_entries1 = 0;
1391 r_u->num_entries2 = num_sam_entries;
1392 r_u->ptr_entries2 = 1;
1396 /*******************************************************************
1397 reads or writes a structure.
1398 ********************************************************************/
1400 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1401 prs_struct *ps, int depth)
1403 uint32 i;
1405 if (r_u == NULL)
1406 return False;
1408 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1409 depth++;
1411 if(!prs_align(ps))
1412 return False;
1414 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1415 return False;
1416 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1417 return False;
1419 if (r_u->ptr_entries1 != 0) {
1420 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1421 return False;
1422 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1423 return False;
1424 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1425 return False;
1427 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1428 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1429 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1432 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1433 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1434 r_u->num_entries4 = 0;
1435 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1436 return False;
1439 for (i = 0; i < r_u->num_entries2; i++) {
1440 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1441 return False;
1444 for (i = 0; i < r_u->num_entries2; i++) {
1445 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1446 return False;
1451 if(!prs_align(ps))
1452 return False;
1454 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1455 return False;
1456 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1457 return False;
1459 return True;
1462 /*******************************************************************
1463 inits a SAMR_Q_QUERY_DISPINFO structure.
1464 ********************************************************************/
1466 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1467 uint16 switch_level, uint32 start_idx,
1468 uint32 max_entries, uint32 max_size)
1470 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1472 q_e->domain_pol = *pol;
1474 q_e->switch_level = switch_level;
1476 q_e->start_idx = start_idx;
1477 q_e->max_entries = max_entries;
1478 q_e->max_size = max_size;
1481 /*******************************************************************
1482 reads or writes a structure.
1483 ********************************************************************/
1485 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1486 prs_struct *ps, int depth)
1488 if (q_e == NULL)
1489 return False;
1491 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1492 depth++;
1494 if(!prs_align(ps))
1495 return False;
1497 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1498 return False;
1500 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1501 return False;
1502 if(!prs_align(ps))
1503 return False;
1505 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1506 return False;
1507 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1508 return False;
1509 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1510 return False;
1512 return True;
1515 /*******************************************************************
1516 inits a SAM_DISPINFO_1 structure.
1517 ********************************************************************/
1519 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1520 uint32 num_entries, uint32 start_idx,
1521 struct samr_displayentry *entries)
1523 uint32 i;
1525 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1527 if (num_entries==0)
1528 return NT_STATUS_OK;
1530 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1531 if (*sam == NULL)
1532 return NT_STATUS_NO_MEMORY;
1534 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1535 if ((*sam)->sam == NULL)
1536 return NT_STATUS_NO_MEMORY;
1538 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1539 if ((*sam)->str == NULL)
1540 return NT_STATUS_NO_MEMORY;
1542 for (i = 0; i < num_entries ; i++) {
1543 init_unistr2(&(*sam)->str[i].uni_acct_name,
1544 entries[i].account_name, UNI_FLAGS_NONE);
1545 init_unistr2(&(*sam)->str[i].uni_full_name,
1546 entries[i].fullname, UNI_FLAGS_NONE);
1547 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1548 entries[i].description, UNI_FLAGS_NONE);
1550 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1551 &(*sam)->str[i].uni_acct_name,
1552 &(*sam)->str[i].uni_full_name,
1553 &(*sam)->str[i].uni_acct_desc,
1554 entries[i].rid, entries[i].acct_flags);
1557 return NT_STATUS_OK;
1560 /*******************************************************************
1561 reads or writes a structure.
1562 ********************************************************************/
1564 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1565 uint32 num_entries,
1566 prs_struct *ps, int depth)
1568 uint32 i;
1570 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1571 depth++;
1573 if(!prs_align(ps))
1574 return False;
1576 if (UNMARSHALLING(ps) && num_entries > 0) {
1578 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1579 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1580 return False;
1583 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1584 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1585 return False;
1589 for (i = 0; i < num_entries; i++) {
1590 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1591 return False;
1594 for (i = 0; i < num_entries; i++) {
1595 if(!sam_io_sam_str1("", &sam->str[i],
1596 sam->sam[i].hdr_acct_name.buffer,
1597 sam->sam[i].hdr_user_name.buffer,
1598 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1599 return False;
1602 return True;
1605 /*******************************************************************
1606 inits a SAM_DISPINFO_2 structure.
1607 ********************************************************************/
1609 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1610 uint32 num_entries, uint32 start_idx,
1611 struct samr_displayentry *entries)
1613 uint32 i;
1615 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1617 if (num_entries==0)
1618 return NT_STATUS_OK;
1620 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1621 if (*sam == NULL)
1622 return NT_STATUS_NO_MEMORY;
1624 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1625 if ((*sam)->sam == NULL)
1626 return NT_STATUS_NO_MEMORY;
1628 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1629 if ((*sam)->str == NULL)
1630 return NT_STATUS_NO_MEMORY;
1632 for (i = 0; i < num_entries; i++) {
1633 init_unistr2(&(*sam)->str[i].uni_srv_name,
1634 entries[i].account_name, UNI_FLAGS_NONE);
1635 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1636 entries[i].description, UNI_FLAGS_NONE);
1638 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1639 &(*sam)->str[i].uni_srv_name,
1640 &(*sam)->str[i].uni_srv_desc,
1641 entries[i].rid, entries[i].acct_flags);
1644 return NT_STATUS_OK;
1647 /*******************************************************************
1648 reads or writes a structure.
1649 ********************************************************************/
1651 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1652 uint32 num_entries,
1653 prs_struct *ps, int depth)
1655 uint32 i;
1657 if (sam == NULL)
1658 return False;
1660 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1661 depth++;
1663 if(!prs_align(ps))
1664 return False;
1666 if (UNMARSHALLING(ps) && num_entries > 0) {
1668 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1669 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1670 return False;
1673 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1674 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1675 return False;
1679 for (i = 0; i < num_entries; i++) {
1680 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1681 return False;
1684 for (i = 0; i < num_entries; i++) {
1685 if(!sam_io_sam_str2("", &sam->str[i],
1686 sam->sam[i].hdr_srv_name.buffer,
1687 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1688 return False;
1691 return True;
1694 /*******************************************************************
1695 inits a SAM_DISPINFO_3 structure.
1696 ********************************************************************/
1698 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1699 uint32 num_entries, uint32 start_idx,
1700 struct samr_displayentry *entries)
1702 uint32 i;
1704 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1706 if (num_entries==0)
1707 return NT_STATUS_OK;
1709 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1710 if (*sam == NULL)
1711 return NT_STATUS_NO_MEMORY;
1713 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1714 return NT_STATUS_NO_MEMORY;
1716 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1717 return NT_STATUS_NO_MEMORY;
1719 for (i = 0; i < num_entries; i++) {
1720 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1722 init_unistr2(&(*sam)->str[i].uni_grp_name,
1723 entries[i].account_name, UNI_FLAGS_NONE);
1724 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1725 entries[i].description, UNI_FLAGS_NONE);
1727 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1728 &(*sam)->str[i].uni_grp_name,
1729 &(*sam)->str[i].uni_grp_desc,
1730 entries[i].rid);
1733 return NT_STATUS_OK;
1736 /*******************************************************************
1737 reads or writes a structure.
1738 ********************************************************************/
1740 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1741 uint32 num_entries,
1742 prs_struct *ps, int depth)
1744 uint32 i;
1746 if (sam == NULL)
1747 return False;
1749 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1750 depth++;
1752 if(!prs_align(ps))
1753 return False;
1755 if (UNMARSHALLING(ps) && num_entries > 0) {
1757 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1758 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1759 return False;
1762 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1763 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1764 return False;
1768 for (i = 0; i < num_entries; i++) {
1769 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1770 return False;
1773 for (i = 0; i < num_entries; i++) {
1774 if(!sam_io_sam_str3("", &sam->str[i],
1775 sam->sam[i].hdr_grp_name.buffer,
1776 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1777 return False;
1780 return True;
1783 /*******************************************************************
1784 inits a SAM_DISPINFO_4 structure.
1785 ********************************************************************/
1787 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1788 uint32 num_entries, uint32 start_idx,
1789 struct samr_displayentry *entries)
1791 uint32 i;
1793 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1795 if (num_entries==0)
1796 return NT_STATUS_OK;
1798 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1799 if (*sam == NULL)
1800 return NT_STATUS_NO_MEMORY;
1802 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1803 if ((*sam)->sam == NULL)
1804 return NT_STATUS_NO_MEMORY;
1806 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1807 if ((*sam)->str == NULL)
1808 return NT_STATUS_NO_MEMORY;
1810 for (i = 0; i < num_entries; i++) {
1811 size_t len_sam_name = strlen(entries[i].account_name);
1813 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1815 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1816 len_sam_name);
1818 init_string2(&(*sam)->str[i].acct_name,
1819 entries[i].account_name, len_sam_name+1,
1820 len_sam_name);
1823 return NT_STATUS_OK;
1826 /*******************************************************************
1827 reads or writes a structure.
1828 ********************************************************************/
1830 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1831 uint32 num_entries,
1832 prs_struct *ps, int depth)
1834 uint32 i;
1836 if (sam == NULL)
1837 return False;
1839 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1840 depth++;
1842 if(!prs_align(ps))
1843 return False;
1845 if (UNMARSHALLING(ps) && num_entries > 0) {
1847 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1848 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1849 return False;
1852 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1853 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1854 return False;
1858 for (i = 0; i < num_entries; i++) {
1859 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1860 return False;
1863 for (i = 0; i < num_entries; i++) {
1864 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1865 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1866 return False;
1869 return True;
1872 /*******************************************************************
1873 inits a SAM_DISPINFO_5 structure.
1874 ********************************************************************/
1876 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1877 uint32 num_entries, uint32 start_idx,
1878 struct samr_displayentry *entries)
1880 uint32 len_sam_name;
1881 uint32 i;
1883 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1885 if (num_entries==0)
1886 return NT_STATUS_OK;
1888 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1889 if (*sam == NULL)
1890 return NT_STATUS_NO_MEMORY;
1892 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1893 return NT_STATUS_NO_MEMORY;
1895 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1896 return NT_STATUS_NO_MEMORY;
1898 for (i = 0; i < num_entries; i++) {
1899 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1901 len_sam_name = strlen(entries[i].account_name);
1903 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
1904 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
1905 len_sam_name+1, len_sam_name);
1908 return NT_STATUS_OK;
1911 /*******************************************************************
1912 reads or writes a structure.
1913 ********************************************************************/
1915 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1916 uint32 num_entries,
1917 prs_struct *ps, int depth)
1919 uint32 i;
1921 if (sam == NULL)
1922 return False;
1924 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1925 depth++;
1927 if(!prs_align(ps))
1928 return False;
1930 if (UNMARSHALLING(ps) && num_entries > 0) {
1932 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1933 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1934 return False;
1937 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1938 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1939 return False;
1943 for (i = 0; i < num_entries; i++) {
1944 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1945 return False;
1948 for (i = 0; i < num_entries; i++) {
1949 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1950 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1951 return False;
1954 return True;
1957 /*******************************************************************
1958 inits a SAMR_R_QUERY_DISPINFO structure.
1959 ********************************************************************/
1961 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1962 uint32 num_entries, uint32 total_size, uint32 data_size,
1963 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1964 NTSTATUS status)
1966 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1968 r_u->total_size = total_size;
1970 r_u->data_size = data_size;
1972 r_u->switch_level = switch_level;
1973 r_u->num_entries = num_entries;
1975 if (num_entries==0)
1976 r_u->ptr_entries = 0;
1977 else
1978 r_u->ptr_entries = 1;
1980 r_u->num_entries2 = num_entries;
1981 r_u->ctr = ctr;
1983 r_u->status = status;
1986 /*******************************************************************
1987 reads or writes a structure.
1988 ********************************************************************/
1990 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1991 prs_struct *ps, int depth)
1993 if (r_u == NULL)
1994 return False;
1996 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
1997 depth++;
1999 if(!prs_align(ps))
2000 return False;
2002 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2003 return False;
2004 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2005 return False;
2006 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2007 return False;
2008 if(!prs_align(ps))
2009 return False;
2011 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2012 return False;
2013 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2014 return False;
2016 if (r_u->ptr_entries==0) {
2017 if(!prs_align(ps))
2018 return False;
2019 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2020 return False;
2022 return True;
2025 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2026 return False;
2028 switch (r_u->switch_level) {
2029 case 0x1:
2030 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2031 r_u->num_entries, ps, depth))
2032 return False;
2033 break;
2034 case 0x2:
2035 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2036 r_u->num_entries, ps, depth))
2037 return False;
2038 break;
2039 case 0x3:
2040 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2041 r_u->num_entries, ps, depth))
2042 return False;
2043 break;
2044 case 0x4:
2045 if(!sam_io_sam_dispinfo_4("user list",
2046 r_u->ctr->sam.info4,
2047 r_u->num_entries, ps, depth))
2048 return False;
2049 break;
2050 case 0x5:
2051 if(!sam_io_sam_dispinfo_5("group list",
2052 r_u->ctr->sam.info5,
2053 r_u->num_entries, ps, depth))
2054 return False;
2055 break;
2056 default:
2057 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2058 break;
2061 if(!prs_align(ps))
2062 return False;
2063 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2064 return False;
2066 return True;
2069 /*******************************************************************
2070 inits a SAMR_Q_OPEN_GROUP structure.
2071 ********************************************************************/
2073 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2074 POLICY_HND *hnd,
2075 uint32 access_mask, uint32 rid)
2077 DEBUG(5, ("init_samr_q_open_group\n"));
2079 q_c->domain_pol = *hnd;
2080 q_c->access_mask = access_mask;
2081 q_c->rid_group = rid;
2084 /*******************************************************************
2085 reads or writes a structure.
2086 ********************************************************************/
2088 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2089 prs_struct *ps, int depth)
2091 if (q_u == NULL)
2092 return False;
2094 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2095 depth++;
2097 if(!prs_align(ps))
2098 return False;
2100 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2101 return False;
2103 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2104 return False;
2105 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2106 return False;
2108 return True;
2111 /*******************************************************************
2112 reads or writes a structure.
2113 ********************************************************************/
2115 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2116 prs_struct *ps, int depth)
2118 if (r_u == NULL)
2119 return False;
2121 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2122 depth++;
2124 if(!prs_align(ps))
2125 return False;
2127 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2128 return False;
2130 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2131 return False;
2133 return True;
2136 /*******************************************************************
2137 inits a GROUP_INFO1 structure.
2138 ********************************************************************/
2140 void init_samr_group_info1(GROUP_INFO1 * gr1,
2141 char *acct_name, char *acct_desc,
2142 uint32 num_members)
2144 DEBUG(5, ("init_samr_group_info1\n"));
2146 gr1->unknown_1 = 0x3;
2147 gr1->num_members = num_members;
2149 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2150 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2151 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2152 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2155 /*******************************************************************
2156 reads or writes a structure.
2157 ********************************************************************/
2159 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2160 prs_struct *ps, int depth)
2162 uint16 dummy = 1;
2164 if (gr1 == NULL)
2165 return False;
2167 prs_debug(ps, depth, desc, "samr_io_group_info1");
2168 depth++;
2170 if(!prs_uint16("level", ps, depth, &dummy))
2171 return False;
2173 if(!prs_align(ps))
2174 return False;
2176 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2177 return False;
2179 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2180 return False;
2181 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2182 return False;
2184 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2185 return False;
2187 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2188 gr1->hdr_acct_name.buffer, ps, depth))
2189 return False;
2191 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2192 gr1->hdr_acct_desc.buffer, ps, depth))
2193 return False;
2195 return True;
2198 /*******************************************************************
2199 inits a GROUP_INFO2 structure.
2200 ********************************************************************/
2202 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2204 DEBUG(5, ("init_samr_group_info2\n"));
2206 gr2->level = 2;
2207 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2208 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2211 /*******************************************************************
2212 reads or writes a structure.
2213 ********************************************************************/
2215 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2217 if (gr2 == NULL)
2218 return False;
2220 prs_debug(ps, depth, desc, "samr_io_group_info2");
2221 depth++;
2223 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2224 return False;
2226 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2227 return False;
2228 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2229 gr2->hdr_acct_name.buffer, ps, depth))
2230 return False;
2232 return True;
2235 /*******************************************************************
2236 inits a GROUP_INFO3 structure.
2237 ********************************************************************/
2239 void init_samr_group_info3(GROUP_INFO3 *gr3)
2241 DEBUG(5, ("init_samr_group_info3\n"));
2243 gr3->unknown_1 = 0x3;
2246 /*******************************************************************
2247 reads or writes a structure.
2248 ********************************************************************/
2250 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2252 if (gr3 == NULL)
2253 return False;
2255 prs_debug(ps, depth, desc, "samr_io_group_info3");
2256 depth++;
2258 if(!prs_align(ps))
2259 return False;
2261 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2262 return False;
2264 return True;
2267 /*******************************************************************
2268 inits a GROUP_INFO4 structure.
2269 ********************************************************************/
2271 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2273 DEBUG(5, ("init_samr_group_info4\n"));
2275 gr4->level = 4;
2276 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2277 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2280 /*******************************************************************
2281 reads or writes a structure.
2282 ********************************************************************/
2284 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2285 prs_struct *ps, int depth)
2287 if (gr4 == NULL)
2288 return False;
2290 prs_debug(ps, depth, desc, "samr_io_group_info4");
2291 depth++;
2293 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2294 return False;
2295 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2296 return False;
2297 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2298 gr4->hdr_acct_desc.buffer, ps, depth))
2299 return False;
2301 return True;
2304 /*******************************************************************
2305 reads or writes a structure.
2306 ********************************************************************/
2308 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2309 prs_struct *ps, int depth)
2311 if (UNMARSHALLING(ps))
2312 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2314 if (*ctr == NULL)
2315 return False;
2317 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2318 depth++;
2320 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2321 return False;
2323 switch ((*ctr)->switch_value1) {
2324 case 1:
2325 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2326 return False;
2327 break;
2328 case 2:
2329 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2330 return False;
2331 break;
2332 case 3:
2333 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2334 return False;
2335 break;
2336 case 4:
2337 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2338 return False;
2339 break;
2340 default:
2341 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2342 break;
2345 return True;
2348 /*******************************************************************
2349 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2350 ********************************************************************/
2352 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2353 POLICY_HND *pol, const char *acct_desc,
2354 uint32 access_mask)
2356 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2358 q_e->pol = *pol;
2360 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2361 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2363 q_e->access_mask = access_mask;
2366 /*******************************************************************
2367 reads or writes a structure.
2368 ********************************************************************/
2370 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2371 prs_struct *ps, int depth)
2373 if (q_e == NULL)
2374 return False;
2376 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2377 depth++;
2379 if(!prs_align(ps))
2380 return False;
2382 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2383 return False;
2385 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2386 return False;
2387 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2388 q_e->hdr_acct_desc.buffer, ps, depth))
2389 return False;
2391 if(!prs_align(ps))
2392 return False;
2393 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2394 return False;
2396 return True;
2399 /*******************************************************************
2400 reads or writes a structure.
2401 ********************************************************************/
2403 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2404 prs_struct *ps, int depth)
2406 if (r_u == NULL)
2407 return False;
2409 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2410 depth++;
2412 if(!prs_align(ps))
2413 return False;
2415 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2416 return False;
2418 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2419 return False;
2420 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2421 return False;
2423 return True;
2426 /*******************************************************************
2427 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2428 ********************************************************************/
2430 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2431 POLICY_HND *hnd)
2433 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2435 q_c->group_pol = *hnd;
2438 /*******************************************************************
2439 reads or writes a structure.
2440 ********************************************************************/
2442 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2443 prs_struct *ps, int depth)
2445 if (q_u == NULL)
2446 return False;
2448 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2449 depth++;
2451 if(!prs_align(ps))
2452 return False;
2454 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2455 return False;
2457 return True;
2460 /*******************************************************************
2461 reads or writes a structure.
2462 ********************************************************************/
2464 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2465 prs_struct *ps, int depth)
2467 if (r_u == NULL)
2468 return False;
2470 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2471 depth++;
2473 if(!prs_align(ps))
2474 return False;
2476 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2477 return False;
2479 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2480 return False;
2482 return True;
2485 /*******************************************************************
2486 inits a SAMR_Q_DEL_GROUPMEM structure.
2487 ********************************************************************/
2489 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2490 POLICY_HND *pol, uint32 rid)
2492 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2494 q_e->pol = *pol;
2495 q_e->rid = rid;
2498 /*******************************************************************
2499 reads or writes a structure.
2500 ********************************************************************/
2502 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2503 prs_struct *ps, int depth)
2505 if (q_e == NULL)
2506 return False;
2508 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2509 depth++;
2511 if(!prs_align(ps))
2512 return False;
2514 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2515 return False;
2517 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2518 return False;
2520 return True;
2523 /*******************************************************************
2524 inits a SAMR_R_DEL_GROUPMEM structure.
2525 ********************************************************************/
2527 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2528 NTSTATUS status)
2530 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2532 r_u->status = status;
2535 /*******************************************************************
2536 reads or writes a structure.
2537 ********************************************************************/
2539 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2540 prs_struct *ps, int depth)
2542 if (r_u == NULL)
2543 return False;
2545 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2546 depth++;
2548 if(!prs_align(ps))
2549 return False;
2551 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2552 return False;
2554 return True;
2557 /*******************************************************************
2558 inits a SAMR_Q_ADD_GROUPMEM structure.
2559 ********************************************************************/
2561 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2562 POLICY_HND *pol, uint32 rid)
2564 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2566 q_e->pol = *pol;
2567 q_e->rid = rid;
2568 q_e->unknown = 0x0005;
2571 /*******************************************************************
2572 reads or writes a structure.
2573 ********************************************************************/
2575 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2576 prs_struct *ps, int depth)
2578 if (q_e == NULL)
2579 return False;
2581 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2582 depth++;
2584 if(!prs_align(ps))
2585 return False;
2587 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2588 return False;
2590 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2591 return False;
2592 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2593 return False;
2595 return True;
2598 /*******************************************************************
2599 inits a SAMR_R_ADD_GROUPMEM structure.
2600 ********************************************************************/
2602 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2603 NTSTATUS status)
2605 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2607 r_u->status = status;
2610 /*******************************************************************
2611 reads or writes a structure.
2612 ********************************************************************/
2614 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2615 prs_struct *ps, int depth)
2617 if (r_u == NULL)
2618 return False;
2620 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2621 depth++;
2623 if(!prs_align(ps))
2624 return False;
2626 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2627 return False;
2629 return True;
2632 /*******************************************************************
2633 inits a SAMR_Q_SET_GROUPINFO structure.
2634 ********************************************************************/
2636 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2637 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2639 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2641 q_e->pol = *pol;
2642 q_e->ctr = ctr;
2645 /*******************************************************************
2646 reads or writes a structure.
2647 ********************************************************************/
2649 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2650 prs_struct *ps, int depth)
2652 if (q_e == NULL)
2653 return False;
2655 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2656 depth++;
2658 if(!prs_align(ps))
2659 return False;
2661 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2662 return False;
2664 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2665 return False;
2667 return True;
2670 /*******************************************************************
2671 inits a SAMR_R_SET_GROUPINFO structure.
2672 ********************************************************************/
2674 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2676 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2678 r_u->status = status;
2681 /*******************************************************************
2682 reads or writes a structure.
2683 ********************************************************************/
2685 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2686 prs_struct *ps, int depth)
2688 if (r_u == NULL)
2689 return False;
2691 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2692 depth++;
2694 if(!prs_align(ps))
2695 return False;
2697 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2698 return False;
2700 return True;
2703 /*******************************************************************
2704 inits a SAMR_Q_QUERY_GROUPINFO structure.
2705 ********************************************************************/
2707 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2708 POLICY_HND *pol, uint16 switch_level)
2710 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2712 q_e->pol = *pol;
2714 q_e->switch_level = switch_level;
2717 /*******************************************************************
2718 reads or writes a structure.
2719 ********************************************************************/
2721 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2722 prs_struct *ps, int depth)
2724 if (q_e == NULL)
2725 return False;
2727 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2728 depth++;
2730 if(!prs_align(ps))
2731 return False;
2733 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2734 return False;
2736 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2737 return False;
2739 return True;
2742 /*******************************************************************
2743 inits a SAMR_R_QUERY_GROUPINFO structure.
2744 ********************************************************************/
2746 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2747 GROUP_INFO_CTR * ctr, NTSTATUS status)
2749 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2751 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2752 r_u->ctr = ctr;
2753 r_u->status = status;
2756 /*******************************************************************
2757 reads or writes a structure.
2758 ********************************************************************/
2760 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2761 prs_struct *ps, int depth)
2763 if (r_u == NULL)
2764 return False;
2766 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2767 depth++;
2769 if(!prs_align(ps))
2770 return False;
2772 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2773 return False;
2775 if (r_u->ptr != 0) {
2776 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2777 return False;
2780 if(!prs_align(ps))
2781 return False;
2782 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2783 return False;
2785 return True;
2788 /*******************************************************************
2789 inits a SAMR_Q_QUERY_GROUPMEM structure.
2790 ********************************************************************/
2792 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2794 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2796 q_c->group_pol = *hnd;
2799 /*******************************************************************
2800 reads or writes a structure.
2801 ********************************************************************/
2803 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2804 prs_struct *ps, int depth)
2806 if (q_u == NULL)
2807 return False;
2809 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2810 depth++;
2812 if(!prs_align(ps))
2813 return False;
2815 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2816 return False;
2818 return True;
2821 /*******************************************************************
2822 inits a SAMR_R_QUERY_GROUPMEM structure.
2823 ********************************************************************/
2825 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2826 uint32 num_entries, uint32 *rid,
2827 uint32 *attr, NTSTATUS status)
2829 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2831 if (NT_STATUS_IS_OK(status)) {
2832 r_u->ptr = 1;
2833 r_u->num_entries = num_entries;
2835 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2836 r_u->ptr_rids = rid != NULL ? 1 : 0;
2838 r_u->num_rids = num_entries;
2839 r_u->rid = rid;
2841 r_u->num_attrs = num_entries;
2842 r_u->attr = attr;
2843 } else {
2844 r_u->ptr = 0;
2845 r_u->num_entries = 0;
2848 r_u->status = status;
2851 /*******************************************************************
2852 reads or writes a structure.
2853 ********************************************************************/
2855 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2856 prs_struct *ps, int depth)
2858 uint32 i;
2860 if (r_u == NULL)
2861 return False;
2863 if (UNMARSHALLING(ps))
2864 ZERO_STRUCTP(r_u);
2866 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2867 depth++;
2869 if(!prs_align(ps))
2870 return False;
2872 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2873 return False;
2874 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2875 return False;
2877 if (r_u->ptr != 0) {
2878 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2879 return False;
2880 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2881 return False;
2883 if (r_u->ptr_rids != 0) {
2884 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2885 return False;
2886 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2887 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2888 if (r_u->rid == NULL)
2889 return False;
2892 for (i = 0; i < r_u->num_rids; i++) {
2893 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2894 return False;
2898 if (r_u->ptr_attrs != 0) {
2899 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2900 return False;
2902 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2903 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2904 if (r_u->attr == NULL)
2905 return False;
2908 for (i = 0; i < r_u->num_attrs; i++) {
2909 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2910 return False;
2915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2916 return False;
2918 return True;
2921 /*******************************************************************
2922 inits a SAMR_Q_QUERY_USERGROUPS structure.
2923 ********************************************************************/
2925 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2926 POLICY_HND *hnd)
2928 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2930 q_u->pol = *hnd;
2933 /*******************************************************************
2934 reads or writes a structure.
2935 ********************************************************************/
2937 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2938 prs_struct *ps, int depth)
2940 if (q_u == NULL)
2941 return False;
2943 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2944 depth++;
2946 if(!prs_align(ps))
2947 return False;
2949 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2950 return False;
2952 return True;
2955 /*******************************************************************
2956 inits a SAMR_R_QUERY_USERGROUPS structure.
2957 ********************************************************************/
2959 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2960 uint32 num_gids, DOM_GID * gid,
2961 NTSTATUS status)
2963 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2965 if (NT_STATUS_IS_OK(status)) {
2966 r_u->ptr_0 = 1;
2967 r_u->num_entries = num_gids;
2968 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2969 r_u->num_entries2 = num_gids;
2971 r_u->gid = gid;
2972 } else {
2973 r_u->ptr_0 = 0;
2974 r_u->num_entries = 0;
2975 r_u->ptr_1 = 0;
2976 r_u->gid = NULL;
2979 r_u->status = status;
2982 /*******************************************************************
2983 reads or writes a structure.
2984 ********************************************************************/
2986 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
2987 prs_struct *ps, int depth)
2989 uint32 i;
2990 if (gid == NULL)
2991 return False;
2993 prs_debug(ps, depth, desc, "samr_io_gids");
2994 depth++;
2996 if(!prs_align(ps))
2997 return False;
2999 if(!prs_uint32("num_gids", ps, depth, num_gids))
3000 return False;
3002 if ((*num_gids) != 0) {
3003 if (UNMARSHALLING(ps)) {
3004 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3007 if ((*gid) == NULL) {
3008 return False;
3011 for (i = 0; i < (*num_gids); i++) {
3012 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3013 return False;
3017 return True;
3020 /*******************************************************************
3021 reads or writes a structure.
3022 ********************************************************************/
3024 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3025 prs_struct *ps, int depth)
3027 if (r_u == NULL)
3028 return False;
3030 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3031 depth++;
3033 if(!prs_align(ps))
3034 return False;
3036 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3037 return False;
3039 if (r_u->ptr_0 != 0) {
3040 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3041 return False;
3042 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3043 return False;
3045 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3046 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3047 return False;
3051 if(!prs_align(ps))
3052 return False;
3053 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3054 return False;
3056 return True;
3059 /*******************************************************************
3060 inits a SAMR_Q_ENUM_DOMAINS structure.
3061 ********************************************************************/
3063 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3064 POLICY_HND *pol,
3065 uint32 start_idx, uint32 size)
3067 DEBUG(5, ("init_samr_q_enum_domains\n"));
3069 q_e->pol = *pol;
3071 q_e->start_idx = start_idx;
3072 q_e->max_size = size;
3075 /*******************************************************************
3076 reads or writes a structure.
3077 ********************************************************************/
3079 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3080 prs_struct *ps, int depth)
3082 if (q_e == NULL)
3083 return False;
3085 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3086 depth++;
3088 if(!prs_align(ps))
3089 return False;
3091 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3092 return False;
3094 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3095 return False;
3096 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3097 return False;
3099 return True;
3102 /*******************************************************************
3103 inits a SAMR_R_ENUM_DOMAINS structure.
3104 ********************************************************************/
3106 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3107 uint32 next_idx, uint32 num_sam_entries)
3109 DEBUG(5, ("init_samr_r_enum_domains\n"));
3111 r_u->next_idx = next_idx;
3113 if (num_sam_entries != 0) {
3114 r_u->ptr_entries1 = 1;
3115 r_u->ptr_entries2 = 1;
3116 r_u->num_entries2 = num_sam_entries;
3117 r_u->num_entries3 = num_sam_entries;
3119 r_u->num_entries4 = num_sam_entries;
3120 } else {
3121 r_u->ptr_entries1 = 0;
3122 r_u->num_entries2 = num_sam_entries;
3123 r_u->ptr_entries2 = 1;
3127 /*******************************************************************
3128 reads or writes a structure.
3129 ********************************************************************/
3131 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3132 prs_struct *ps, int depth)
3134 uint32 i;
3136 if (r_u == NULL)
3137 return False;
3139 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3140 depth++;
3142 if(!prs_align(ps))
3143 return False;
3145 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3146 return False;
3147 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3148 return False;
3150 if (r_u->ptr_entries1 != 0) {
3151 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3152 return False;
3153 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3154 return False;
3155 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3156 return False;
3158 if (UNMARSHALLING(ps)) {
3159 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3160 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3163 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3164 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3165 r_u->num_entries4 = 0;
3166 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3167 return False;
3170 for (i = 0; i < r_u->num_entries2; i++) {
3171 fstring tmp;
3172 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3173 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3174 return False;
3177 for (i = 0; i < r_u->num_entries2; i++) {
3178 fstring tmp;
3179 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3180 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3181 r_u->sam[i].hdr_name.buffer, ps,
3182 depth))
3183 return False;
3188 if(!prs_align(ps))
3189 return False;
3190 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3191 return False;
3192 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3193 return False;
3195 return True;
3198 /*******************************************************************
3199 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3200 ********************************************************************/
3202 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3203 POLICY_HND *pol,
3204 uint32 start_idx, uint32 size)
3206 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3208 q_e->pol = *pol;
3210 q_e->start_idx = start_idx;
3211 q_e->max_size = size;
3214 /*******************************************************************
3215 reads or writes a structure.
3216 ********************************************************************/
3218 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3219 prs_struct *ps, int depth)
3221 if (q_e == NULL)
3222 return False;
3224 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3225 depth++;
3227 if(!prs_align(ps))
3228 return False;
3230 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3231 return False;
3233 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3234 return False;
3235 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3236 return False;
3238 return True;
3241 /*******************************************************************
3242 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3243 ********************************************************************/
3245 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3246 uint32 next_idx, uint32 num_sam_entries)
3248 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3250 r_u->next_idx = next_idx;
3252 if (num_sam_entries != 0) {
3253 r_u->ptr_entries1 = 1;
3254 r_u->ptr_entries2 = 1;
3255 r_u->num_entries2 = num_sam_entries;
3256 r_u->num_entries3 = num_sam_entries;
3258 r_u->num_entries4 = num_sam_entries;
3259 } else {
3260 r_u->ptr_entries1 = 0;
3261 r_u->num_entries2 = num_sam_entries;
3262 r_u->ptr_entries2 = 1;
3266 /*******************************************************************
3267 reads or writes a structure.
3268 ********************************************************************/
3270 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3271 prs_struct *ps, int depth)
3273 uint32 i;
3275 if (r_u == NULL)
3276 return False;
3278 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3279 depth++;
3281 if(!prs_align(ps))
3282 return False;
3284 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3285 return False;
3286 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3287 return False;
3289 if (r_u->ptr_entries1 != 0) {
3290 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3291 return False;
3292 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3293 return False;
3294 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3295 return False;
3297 if (UNMARSHALLING(ps)) {
3298 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3299 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3302 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3303 DEBUG(0,
3304 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3305 r_u->num_entries4 = 0;
3306 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3307 return False;
3310 for (i = 0; i < r_u->num_entries2; i++) {
3311 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3312 return False;
3315 for (i = 0; i < r_u->num_entries2; i++) {
3316 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3317 r_u->sam[i].hdr_name.buffer, ps, depth))
3318 return False;
3322 if(!prs_align(ps))
3323 return False;
3324 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3325 return False;
3326 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3327 return False;
3329 return True;
3332 /*******************************************************************
3333 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3334 ********************************************************************/
3336 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3337 POLICY_HND *pol, uint32 start_idx,
3338 uint32 size)
3340 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3342 q_e->pol = *pol;
3344 q_e->start_idx = start_idx;
3345 q_e->max_size = size;
3349 /*******************************************************************
3350 reads or writes a structure.
3351 ********************************************************************/
3353 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3354 prs_struct *ps, int depth)
3356 if (q_e == NULL)
3357 return False;
3359 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3360 depth++;
3362 if(!prs_align(ps))
3363 return False;
3365 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3366 return False;
3368 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3369 return False;
3370 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3371 return False;
3373 return True;
3376 /*******************************************************************
3377 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3378 ********************************************************************/
3380 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3382 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3384 r_u->next_idx = next_idx;
3386 if (num_sam_entries != 0) {
3387 r_u->ptr_entries1 = 1;
3388 r_u->ptr_entries2 = 1;
3389 r_u->num_entries2 = num_sam_entries;
3390 r_u->num_entries3 = num_sam_entries;
3392 r_u->num_entries4 = num_sam_entries;
3393 } else {
3394 r_u->ptr_entries1 = 0;
3395 r_u->num_entries2 = num_sam_entries;
3396 r_u->ptr_entries2 = 1;
3400 /*******************************************************************
3401 reads or writes a structure.
3402 ********************************************************************/
3404 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3405 prs_struct *ps, int depth)
3407 uint32 i;
3409 if (r_u == NULL)
3410 return False;
3412 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3413 depth++;
3415 if(!prs_align(ps))
3416 return False;
3418 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3419 return False;
3420 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3421 return False;
3423 if (r_u->ptr_entries1 != 0) {
3424 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3425 return False;
3426 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3427 return False;
3428 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3429 return False;
3431 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3432 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3433 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3436 if (r_u->num_entries2 != 0 &&
3437 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3438 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3439 r_u->num_entries4 = 0;
3440 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3441 return False;
3444 for (i = 0; i < r_u->num_entries2; i++) {
3445 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3446 return False;
3449 for (i = 0; i < r_u->num_entries2; i++) {
3450 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3451 r_u->sam[i].hdr_name.buffer, ps,
3452 depth))
3453 return False;
3457 if(!prs_align(ps))
3458 return False;
3459 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3460 return False;
3461 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3462 return False;
3464 return True;
3467 /*******************************************************************
3468 inits a ALIAS_INFO1 structure.
3469 ********************************************************************/
3471 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3473 DEBUG(5, ("init_samr_alias_info1\n"));
3475 init_unistr2(&al1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
3476 init_uni_hdr(&al1->hdr_acct_name, &al1->uni_acct_name);
3478 al1->num_member=num_member;
3480 init_unistr2(&al1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3481 init_uni_hdr(&al1->hdr_acct_desc, &al1->uni_acct_name);
3484 /*******************************************************************
3485 reads or writes a structure.
3486 ********************************************************************/
3488 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3489 prs_struct *ps, int depth)
3491 if (al1 == NULL)
3492 return False;
3494 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3495 depth++;
3497 if(!prs_align(ps))
3498 return False;
3500 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3501 return False;
3502 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3503 return False;
3504 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3505 return False;
3507 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3508 al1->hdr_acct_name.buffer, ps, depth))
3509 return False;
3511 if(!prs_align(ps))
3512 return False;
3514 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3515 al1->hdr_acct_desc.buffer, ps, depth))
3516 return False;
3518 return True;
3521 /*******************************************************************
3522 inits a ALIAS_INFO3 structure.
3523 ********************************************************************/
3525 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3527 DEBUG(5, ("init_samr_alias_info3\n"));
3529 init_unistr2(&al3->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3530 init_uni_hdr(&al3->hdr_acct_desc, &al3->uni_acct_desc);
3533 /*******************************************************************
3534 reads or writes a structure.
3535 ********************************************************************/
3537 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
3538 prs_struct *ps, int depth)
3540 if (al3 == NULL)
3541 return False;
3543 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3544 depth++;
3546 if(!prs_align(ps))
3547 return False;
3549 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3550 return False;
3551 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3552 al3->hdr_acct_desc.buffer, ps, depth))
3553 return False;
3555 return True;
3558 /*******************************************************************
3559 reads or writes a structure.
3560 ********************************************************************/
3562 BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr,
3563 prs_struct *ps, int depth)
3565 if (ctr == NULL)
3566 return False;
3568 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3569 depth++;
3571 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3572 return False;
3573 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3574 return False;
3576 switch (ctr->switch_value1) {
3577 case 1:
3578 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3579 return False;
3580 break;
3581 case 3:
3582 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3583 return False;
3584 break;
3585 default:
3586 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3587 break;
3590 return True;
3593 /*******************************************************************
3594 inits a SAMR_Q_QUERY_ALIASINFO structure.
3595 ********************************************************************/
3597 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3598 POLICY_HND *pol, uint16 switch_level)
3600 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3602 q_e->pol = *pol;
3603 q_e->switch_level = switch_level;
3606 /*******************************************************************
3607 reads or writes a structure.
3608 ********************************************************************/
3610 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3611 prs_struct *ps, int depth)
3613 if (q_e == NULL)
3614 return False;
3616 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3617 depth++;
3619 if(!prs_align(ps))
3620 return False;
3622 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3623 return False;
3625 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3626 return False;
3628 return True;
3631 /*******************************************************************
3632 inits a SAMR_R_QUERY_ALIASINFO structure.
3633 ********************************************************************/
3635 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3636 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3638 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3640 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3641 r_u->ctr = *ctr;
3642 r_u->status = status;
3645 /*******************************************************************
3646 reads or writes a structure.
3647 ********************************************************************/
3649 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3650 prs_struct *ps, int depth)
3652 if (r_u == NULL)
3653 return False;
3655 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3656 depth++;
3658 if(!prs_align(ps))
3659 return False;
3661 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3662 return False;
3664 if (r_u->ptr != 0) {
3665 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3666 return False;
3669 if(!prs_align(ps))
3670 return False;
3671 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3672 return False;
3674 return True;
3677 /*******************************************************************
3678 inits a SAMR_Q_SET_ALIASINFO structure.
3679 ********************************************************************/
3681 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3682 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3684 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3686 q_u->alias_pol = *hnd;
3687 q_u->ctr = *ctr;
3690 /*******************************************************************
3691 reads or writes a structure.
3692 ********************************************************************/
3694 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3695 prs_struct *ps, int depth)
3697 if (q_u == NULL)
3698 return False;
3700 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3701 depth++;
3703 if(!prs_align(ps))
3704 return False;
3706 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3707 return False;
3708 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3709 return False;
3711 return True;
3714 /*******************************************************************
3715 reads or writes a structure.
3716 ********************************************************************/
3718 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3719 prs_struct *ps, int depth)
3721 if (r_u == NULL)
3722 return False;
3724 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3725 depth++;
3727 if(!prs_align(ps))
3728 return False;
3729 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3730 return False;
3732 return True;
3735 /*******************************************************************
3736 inits a SAMR_Q_QUERY_USERALIASES structure.
3737 ********************************************************************/
3739 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3740 POLICY_HND *hnd,
3741 uint32 num_sids,
3742 uint32 *ptr_sid, DOM_SID2 * sid)
3744 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3746 q_u->pol = *hnd;
3748 q_u->num_sids1 = num_sids;
3749 q_u->ptr = 1;
3750 q_u->num_sids2 = num_sids;
3752 q_u->ptr_sid = ptr_sid;
3753 q_u->sid = sid;
3756 /*******************************************************************
3757 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3758 ********************************************************************/
3760 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3761 prs_struct *ps, int depth)
3763 fstring tmp;
3764 uint32 i;
3766 if (q_u == NULL)
3767 return False;
3769 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3770 depth++;
3772 if(!prs_align(ps))
3773 return False;
3775 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3776 return False;
3778 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3779 return False;
3780 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3781 return False;
3783 if (q_u->ptr==0)
3784 return True;
3786 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3787 return False;
3789 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3790 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3791 if (q_u->ptr_sid == NULL)
3792 return False;
3794 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3795 if (q_u->sid == NULL)
3796 return False;
3799 for (i = 0; i < q_u->num_sids2; i++) {
3800 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3801 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3802 return False;
3805 for (i = 0; i < q_u->num_sids2; i++) {
3806 if (q_u->ptr_sid[i] != 0) {
3807 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3808 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3809 return False;
3813 return True;
3816 /*******************************************************************
3817 inits a SAMR_R_QUERY_USERALIASES structure.
3818 ********************************************************************/
3820 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3821 uint32 num_rids, uint32 *rid,
3822 NTSTATUS status)
3824 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3826 if (NT_STATUS_IS_OK(status)) {
3827 r_u->num_entries = num_rids;
3828 r_u->ptr = 1;
3829 r_u->num_entries2 = num_rids;
3831 r_u->rid = rid;
3832 } else {
3833 r_u->num_entries = 0;
3834 r_u->ptr = 0;
3835 r_u->num_entries2 = 0;
3838 r_u->status = status;
3841 /*******************************************************************
3842 reads or writes a structure.
3843 ********************************************************************/
3845 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3846 prs_struct *ps, int depth)
3848 fstring tmp;
3849 uint32 i;
3850 if (rid == NULL)
3851 return False;
3853 prs_debug(ps, depth, desc, "samr_io_rids");
3854 depth++;
3856 if(!prs_align(ps))
3857 return False;
3859 if(!prs_uint32("num_rids", ps, depth, num_rids))
3860 return False;
3862 if ((*num_rids) != 0) {
3863 if (UNMARSHALLING(ps)) {
3864 /* reading */
3865 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3867 if ((*rid) == NULL)
3868 return False;
3870 for (i = 0; i < (*num_rids); i++) {
3871 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3872 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3873 return False;
3877 return True;
3880 /*******************************************************************
3881 reads or writes a structure.
3882 ********************************************************************/
3884 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * 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_query_useraliases");
3891 depth++;
3893 if(!prs_align(ps))
3894 return False;
3896 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3897 return False;
3898 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3899 return False;
3901 if (r_u->ptr != 0) {
3902 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3903 return False;
3906 if(!prs_align(ps))
3907 return False;
3908 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3909 return False;
3911 return True;
3914 /*******************************************************************
3915 inits a SAMR_Q_OPEN_ALIAS structure.
3916 ********************************************************************/
3918 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3919 uint32 access_mask, uint32 rid)
3921 DEBUG(5, ("init_samr_q_open_alias\n"));
3923 q_u->dom_pol = *pol;
3924 q_u->access_mask = access_mask;
3925 q_u->rid_alias = rid;
3928 /*******************************************************************
3929 reads or writes a structure.
3930 ********************************************************************/
3932 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3933 prs_struct *ps, int depth)
3935 if (q_u == NULL)
3936 return False;
3938 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3939 depth++;
3941 if(!prs_align(ps))
3942 return False;
3944 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3945 return False;
3947 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3948 return False;
3949 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3950 return False;
3952 return True;
3955 /*******************************************************************
3956 reads or writes a structure.
3957 ********************************************************************/
3959 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
3960 prs_struct *ps, int depth)
3962 if (r_u == NULL)
3963 return False;
3965 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3966 depth++;
3968 if(!prs_align(ps))
3969 return False;
3971 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3972 return False;
3974 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3975 return False;
3977 return True;
3980 /*******************************************************************
3981 inits a SAMR_Q_LOOKUP_RIDS structure.
3982 ********************************************************************/
3984 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3985 POLICY_HND *pol, uint32 flags,
3986 uint32 num_rids, uint32 *rid)
3988 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3990 q_u->pol = *pol;
3992 q_u->num_rids1 = num_rids;
3993 q_u->flags = flags;
3994 q_u->ptr = 0;
3995 q_u->num_rids2 = num_rids;
3996 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
3997 if (q_u->rid == NULL) {
3998 q_u->num_rids1 = 0;
3999 q_u->num_rids2 = 0;
4000 } else {
4001 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4005 /*******************************************************************
4006 reads or writes a structure.
4007 ********************************************************************/
4009 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4010 prs_struct *ps, int depth)
4012 uint32 i;
4013 fstring tmp;
4015 if (q_u == NULL)
4016 return False;
4018 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4019 depth++;
4021 if (UNMARSHALLING(ps))
4022 ZERO_STRUCTP(q_u);
4024 if(!prs_align(ps))
4025 return False;
4027 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4028 return False;
4030 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4031 return False;
4032 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4033 return False;
4034 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4035 return False;
4036 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4037 return False;
4039 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4040 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4041 if (q_u->rid == NULL)
4042 return False;
4045 for (i = 0; i < q_u->num_rids2; i++) {
4046 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4047 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4048 return False;
4051 return True;
4054 /*******************************************************************
4055 inits a SAMR_R_LOOKUP_RIDS structure.
4056 ********************************************************************/
4058 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4059 uint32 num_names, UNIHDR * hdr_name,
4060 UNISTR2 *uni_name, uint32 *type)
4062 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4064 r_u->hdr_name = NULL;
4065 r_u->uni_name = NULL;
4066 r_u->type = NULL;
4068 if (num_names != 0) {
4069 r_u->num_names1 = num_names;
4070 r_u->ptr_names = 1;
4071 r_u->num_names2 = num_names;
4073 r_u->num_types1 = num_names;
4074 r_u->ptr_types = 1;
4075 r_u->num_types2 = num_names;
4077 r_u->hdr_name = hdr_name;
4078 r_u->uni_name = uni_name;
4079 r_u->type = type;
4080 } else {
4081 r_u->num_names1 = num_names;
4082 r_u->ptr_names = 0;
4083 r_u->num_names2 = num_names;
4085 r_u->num_types1 = num_names;
4086 r_u->ptr_types = 0;
4087 r_u->num_types2 = num_names;
4091 /*******************************************************************
4092 reads or writes a structure.
4093 ********************************************************************/
4095 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4096 prs_struct *ps, int depth)
4098 uint32 i;
4099 fstring tmp;
4100 if (r_u == NULL)
4101 return False;
4103 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4104 depth++;
4106 if(!prs_align(ps))
4107 return False;
4109 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4110 return False;
4111 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4112 return False;
4114 if (r_u->ptr_names != 0) {
4116 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4117 return False;
4120 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4121 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4122 if (r_u->hdr_name == NULL)
4123 return False;
4125 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4126 if (r_u->uni_name == NULL)
4127 return False;
4130 for (i = 0; i < r_u->num_names2; i++) {
4131 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4132 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4133 return False;
4135 for (i = 0; i < r_u->num_names2; i++) {
4136 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4137 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4138 return False;
4143 if(!prs_align(ps))
4144 return False;
4145 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4146 return False;
4147 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4148 return False;
4150 if (r_u->ptr_types != 0) {
4152 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4153 return False;
4155 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4156 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4157 if (r_u->type == NULL)
4158 return False;
4161 for (i = 0; i < r_u->num_types2; i++) {
4162 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4163 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4164 return False;
4168 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4169 return False;
4171 return True;
4174 /*******************************************************************
4175 inits a SAMR_Q_OPEN_ALIAS structure.
4176 ********************************************************************/
4178 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4180 DEBUG(5, ("init_samr_q_delete_alias\n"));
4182 q_u->alias_pol = *hnd;
4185 /*******************************************************************
4186 reads or writes a structure.
4187 ********************************************************************/
4189 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4190 prs_struct *ps, int depth)
4192 if (q_u == NULL)
4193 return False;
4195 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4196 depth++;
4198 if(!prs_align(ps))
4199 return False;
4201 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4202 return False;
4204 return True;
4207 /*******************************************************************
4208 reads or writes a structure.
4209 ********************************************************************/
4211 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4212 prs_struct *ps, int depth)
4214 if (r_u == NULL)
4215 return False;
4217 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4218 depth++;
4220 if(!prs_align(ps))
4221 return False;
4223 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4224 return False;
4225 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4226 return False;
4228 return True;
4231 /*******************************************************************
4232 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4233 ********************************************************************/
4235 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4236 POLICY_HND *hnd, const char *acct_desc)
4238 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4240 q_u->dom_pol = *hnd;
4242 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4243 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4245 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4248 /*******************************************************************
4249 reads or writes a structure.
4250 ********************************************************************/
4252 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4253 prs_struct *ps, int depth)
4255 if (q_u == NULL)
4256 return False;
4258 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4259 depth++;
4261 if(!prs_align(ps))
4262 return False;
4264 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4265 return False;
4267 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4268 return False;
4269 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4270 q_u->hdr_acct_desc.buffer, ps, depth))
4271 return False;
4273 if(!prs_align(ps))
4274 return False;
4275 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4276 return False;
4278 return True;
4281 /*******************************************************************
4282 reads or writes a structure.
4283 ********************************************************************/
4285 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4286 prs_struct *ps, int depth)
4288 if (r_u == NULL)
4289 return False;
4291 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4292 depth++;
4294 if(!prs_align(ps))
4295 return False;
4297 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4298 return False;
4300 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4301 return False;
4303 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4304 return False;
4306 return True;
4309 /*******************************************************************
4310 inits a SAMR_Q_ADD_ALIASMEM structure.
4311 ********************************************************************/
4313 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4314 DOM_SID *sid)
4316 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4318 q_u->alias_pol = *hnd;
4319 init_dom_sid2(&q_u->sid, sid);
4322 /*******************************************************************
4323 reads or writes a structure.
4324 ********************************************************************/
4326 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4327 prs_struct *ps, int depth)
4329 if (q_u == NULL)
4330 return False;
4332 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4333 depth++;
4335 if(!prs_align(ps))
4336 return False;
4338 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4339 return False;
4340 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4341 return False;
4343 return True;
4346 /*******************************************************************
4347 reads or writes a structure.
4348 ********************************************************************/
4350 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4351 prs_struct *ps, int depth)
4353 if (r_u == NULL)
4354 return False;
4356 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4357 depth++;
4359 if(!prs_align(ps))
4360 return False;
4362 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4363 return False;
4365 return True;
4368 /*******************************************************************
4369 inits a SAMR_Q_DEL_ALIASMEM structure.
4370 ********************************************************************/
4372 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4373 DOM_SID *sid)
4375 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4377 q_u->alias_pol = *hnd;
4378 init_dom_sid2(&q_u->sid, sid);
4381 /*******************************************************************
4382 reads or writes a structure.
4383 ********************************************************************/
4385 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4386 prs_struct *ps, int depth)
4388 if (q_u == NULL)
4389 return False;
4391 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4392 depth++;
4394 if(!prs_align(ps))
4395 return False;
4397 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4398 return False;
4399 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4400 return False;
4402 return True;
4405 /*******************************************************************
4406 reads or writes a structure.
4407 ********************************************************************/
4409 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4410 prs_struct *ps, int depth)
4412 if (r_u == NULL)
4413 return False;
4415 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4416 depth++;
4418 if(!prs_align(ps))
4419 return False;
4421 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4422 return False;
4424 return True;
4427 /*******************************************************************
4428 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4429 ********************************************************************/
4431 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4432 POLICY_HND *hnd)
4434 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4436 q_c->alias_pol = *hnd;
4439 /*******************************************************************
4440 reads or writes a structure.
4441 ********************************************************************/
4443 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4444 prs_struct *ps, int depth)
4446 if (q_u == NULL)
4447 return False;
4449 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4450 depth++;
4452 if(!prs_align(ps))
4453 return False;
4455 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4456 return False;
4458 return True;
4461 /*******************************************************************
4462 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4463 ********************************************************************/
4465 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4466 NTSTATUS status)
4468 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4470 r_u->status = status;
4473 /*******************************************************************
4474 reads or writes a structure.
4475 ********************************************************************/
4477 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4478 prs_struct *ps, int depth)
4480 if (r_u == NULL)
4481 return False;
4483 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4484 depth++;
4486 if(!prs_align(ps))
4487 return False;
4489 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4490 return False;
4492 return True;
4495 /*******************************************************************
4496 inits a SAMR_Q_QUERY_ALIASMEM structure.
4497 ********************************************************************/
4499 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4500 POLICY_HND *hnd)
4502 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4504 q_c->alias_pol = *hnd;
4507 /*******************************************************************
4508 reads or writes a structure.
4509 ********************************************************************/
4511 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4512 prs_struct *ps, int depth)
4514 if (q_u == NULL)
4515 return False;
4517 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4518 depth++;
4520 if(!prs_align(ps))
4521 return False;
4523 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4524 return False;
4526 return True;
4529 /*******************************************************************
4530 inits a SAMR_R_QUERY_ALIASMEM structure.
4531 ********************************************************************/
4533 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4534 uint32 num_sids, DOM_SID2 * sid,
4535 NTSTATUS status)
4537 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4539 if (NT_STATUS_IS_OK(status)) {
4540 r_u->num_sids = num_sids;
4541 r_u->ptr = (num_sids != 0) ? 1 : 0;
4542 r_u->num_sids1 = num_sids;
4544 r_u->sid = sid;
4545 } else {
4546 r_u->ptr = 0;
4547 r_u->num_sids = 0;
4550 r_u->status = status;
4553 /*******************************************************************
4554 reads or writes a structure.
4555 ********************************************************************/
4557 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4558 prs_struct *ps, int depth)
4560 uint32 i;
4562 if (r_u == NULL)
4563 return False;
4565 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4566 depth++;
4568 if(!prs_align(ps))
4569 return False;
4571 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4572 return False;
4573 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4574 return False;
4576 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4577 uint32 *ptr_sid = NULL;
4579 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4580 return False;
4582 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4583 if (!ptr_sid) {
4584 return False;
4587 for (i = 0; i < r_u->num_sids1; i++) {
4588 ptr_sid[i] = 1;
4589 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4590 return False;
4593 if (UNMARSHALLING(ps)) {
4594 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4597 for (i = 0; i < r_u->num_sids1; i++) {
4598 if (ptr_sid[i] != 0) {
4599 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4600 return False;
4605 if(!prs_align(ps))
4606 return False;
4607 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4608 return False;
4610 return True;
4613 /*******************************************************************
4614 inits a SAMR_Q_LOOKUP_NAMES structure.
4615 ********************************************************************/
4617 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4618 POLICY_HND *pol, uint32 flags,
4619 uint32 num_names, const char **name)
4621 uint32 i;
4623 DEBUG(5, ("init_samr_q_lookup_names\n"));
4625 q_u->pol = *pol;
4627 q_u->num_names1 = num_names;
4628 q_u->flags = flags;
4629 q_u->ptr = 0;
4630 q_u->num_names2 = num_names;
4632 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4633 return NT_STATUS_NO_MEMORY;
4635 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4636 return NT_STATUS_NO_MEMORY;
4638 for (i = 0; i < num_names; i++) {
4639 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4640 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4643 return NT_STATUS_OK;
4646 /*******************************************************************
4647 reads or writes a structure.
4648 ********************************************************************/
4650 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4651 prs_struct *ps, int depth)
4653 uint32 i;
4655 if (q_u == NULL)
4656 return False;
4658 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4659 depth++;
4661 if (UNMARSHALLING(ps))
4662 ZERO_STRUCTP(q_u);
4664 if(!prs_align(ps))
4665 return False;
4667 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4668 return False;
4670 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4671 return False;
4672 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4673 return False;
4674 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4675 return False;
4676 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4677 return False;
4679 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4680 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4681 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4682 if (!q_u->hdr_name || !q_u->uni_name)
4683 return False;
4686 for (i = 0; i < q_u->num_names2; i++) {
4687 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4688 return False;
4691 for (i = 0; i < q_u->num_names2; i++) {
4692 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4693 return False;
4696 return True;
4699 /*******************************************************************
4700 inits a SAMR_R_LOOKUP_NAMES structure.
4701 ********************************************************************/
4703 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4704 uint32 num_rids,
4705 uint32 *rid, uint32 *type,
4706 NTSTATUS status)
4708 DEBUG(5, ("init_samr_r_lookup_names\n"));
4710 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4711 uint32 i;
4713 r_u->num_types1 = num_rids;
4714 r_u->ptr_types = 1;
4715 r_u->num_types2 = num_rids;
4717 r_u->num_rids1 = num_rids;
4718 r_u->ptr_rids = 1;
4719 r_u->num_rids2 = num_rids;
4721 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4722 return NT_STATUS_NO_MEMORY;
4723 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4724 return NT_STATUS_NO_MEMORY;
4726 if (!r_u->rids || !r_u->types)
4727 goto empty;
4729 for (i = 0; i < num_rids; i++) {
4730 r_u->rids[i] = rid[i];
4731 r_u->types[i] = type[i];
4733 } else {
4735 empty:
4736 r_u->num_types1 = 0;
4737 r_u->ptr_types = 0;
4738 r_u->num_types2 = 0;
4740 r_u->num_rids1 = 0;
4741 r_u->ptr_rids = 0;
4742 r_u->num_rids2 = 0;
4744 r_u->rids = NULL;
4745 r_u->types = NULL;
4748 r_u->status = status;
4750 return NT_STATUS_OK;
4753 /*******************************************************************
4754 reads or writes a structure.
4755 ********************************************************************/
4757 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4758 prs_struct *ps, int depth)
4760 uint32 i;
4761 fstring tmp;
4763 if (r_u == NULL)
4764 return False;
4766 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4767 depth++;
4769 if (UNMARSHALLING(ps))
4770 ZERO_STRUCTP(r_u);
4772 if(!prs_align(ps))
4773 return False;
4775 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4776 return False;
4777 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4778 return False;
4780 if (r_u->ptr_rids != 0) {
4781 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4782 return False;
4784 if (r_u->num_rids2 != r_u->num_rids1) {
4785 /* RPC fault */
4786 return False;
4789 if (UNMARSHALLING(ps))
4790 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4792 if (!r_u->rids) {
4793 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4794 return False;
4797 for (i = 0; i < r_u->num_rids2; i++) {
4798 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4799 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4800 return False;
4804 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4805 return False;
4806 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4807 return False;
4809 if (r_u->ptr_types != 0) {
4810 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4811 return False;
4813 if (r_u->num_types2 != r_u->num_types1) {
4814 /* RPC fault */
4815 return False;
4818 if (UNMARSHALLING(ps))
4819 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4821 if (!r_u->types) {
4822 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4823 return False;
4826 for (i = 0; i < r_u->num_types2; i++) {
4827 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4828 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4829 return False;
4833 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4834 return False;
4836 return True;
4839 /*******************************************************************
4840 inits a SAMR_Q_DELETE_DOM_USER structure.
4841 ********************************************************************/
4843 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4844 POLICY_HND *hnd)
4846 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4848 q_c->user_pol = *hnd;
4851 /*******************************************************************
4852 reads or writes a structure.
4853 ********************************************************************/
4855 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4856 prs_struct *ps, int depth)
4858 if (q_u == NULL)
4859 return False;
4861 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4862 depth++;
4864 if(!prs_align(ps))
4865 return False;
4867 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4868 return False;
4870 return True;
4873 /*******************************************************************
4874 reads or writes a structure.
4875 ********************************************************************/
4877 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4878 prs_struct *ps, int depth)
4880 if (r_u == NULL)
4881 return False;
4883 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4884 depth++;
4886 if(!prs_align(ps))
4887 return False;
4889 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4890 return False;
4891 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4892 return False;
4894 return True;
4897 /*******************************************************************
4898 reads or writes a structure.
4899 ********************************************************************/
4901 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4902 POLICY_HND *pol,
4903 uint32 access_mask, uint32 rid)
4905 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4907 q_u->domain_pol = *pol;
4908 q_u->access_mask = access_mask;
4909 q_u->user_rid = rid;
4912 /*******************************************************************
4913 reads or writes a structure.
4914 ********************************************************************/
4916 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_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_open_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(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4932 return False;
4933 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4934 return False;
4936 return True;
4939 /*******************************************************************
4940 reads or writes a structure.
4941 ********************************************************************/
4943 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4944 prs_struct *ps, int depth)
4946 if (r_u == NULL)
4947 return False;
4949 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4950 depth++;
4952 if(!prs_align(ps))
4953 return False;
4955 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4956 return False;
4958 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4959 return False;
4961 return True;
4965 /*******************************************************************
4966 reads or writes a structure.
4967 ********************************************************************/
4969 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4970 POLICY_HND *pol,
4971 const char *name,
4972 uint32 acb_info, uint32 access_mask)
4974 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4976 q_u->domain_pol = *pol;
4978 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
4979 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
4981 q_u->acb_info = acb_info;
4982 q_u->access_mask = access_mask;
4985 /*******************************************************************
4986 reads or writes a structure.
4987 ********************************************************************/
4989 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
4990 prs_struct *ps, int depth)
4992 if (q_u == NULL)
4993 return False;
4995 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4996 depth++;
4998 if(!prs_align(ps))
4999 return False;
5001 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5002 return False;
5004 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5005 return False;
5006 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5007 return False;
5009 if(!prs_align(ps))
5010 return False;
5011 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5012 return False;
5013 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5014 return False;
5016 return True;
5019 /*******************************************************************
5020 reads or writes a structure.
5021 ********************************************************************/
5023 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5024 prs_struct *ps, int depth)
5026 if (r_u == NULL)
5027 return False;
5029 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5030 depth++;
5032 if(!prs_align(ps))
5033 return False;
5035 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5036 return False;
5038 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5039 return False;
5040 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5041 return False;
5042 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5043 return False;
5045 return True;
5048 /*******************************************************************
5049 inits a SAMR_Q_QUERY_USERINFO structure.
5050 ********************************************************************/
5052 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5053 POLICY_HND *hnd, uint16 switch_value)
5055 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5057 q_u->pol = *hnd;
5058 q_u->switch_value = switch_value;
5061 /*******************************************************************
5062 reads or writes a structure.
5063 ********************************************************************/
5065 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5066 prs_struct *ps, int depth)
5068 if (q_u == NULL)
5069 return False;
5071 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5072 depth++;
5074 if(!prs_align(ps))
5075 return False;
5077 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5078 return False;
5080 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5081 return False;
5083 return True;
5086 /*******************************************************************
5087 reads or writes a LOGON_HRS structure.
5088 ********************************************************************/
5090 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5091 prs_struct *ps, int depth)
5093 if (hrs == NULL)
5094 return False;
5096 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5097 depth++;
5099 if(!prs_align(ps))
5100 return False;
5102 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5103 return False;
5105 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5106 return False;
5108 if(!prs_uint32("len ", ps, depth, &hrs->len))
5109 return False;
5111 if (hrs->len > sizeof(hrs->hours)) {
5112 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5113 hrs->len = sizeof(hrs->hours);
5116 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5117 return False;
5119 return True;
5122 /*******************************************************************
5123 inits a SAM_USER_INFO_12 structure.
5124 ********************************************************************/
5126 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5127 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5129 DEBUG(5, ("init_sam_user_info12\n"));
5131 usr->lm_pwd_active =
5132 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5133 usr->nt_pwd_active =
5134 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5137 /*******************************************************************
5138 reads or writes a structure.
5139 ********************************************************************/
5141 static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u,
5142 prs_struct *ps, int depth)
5144 if (u == NULL)
5145 return False;
5147 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5148 depth++;
5150 if(!prs_align(ps))
5151 return False;
5153 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5154 return False;
5155 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5156 return False;
5158 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5159 return False;
5160 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5161 return False;
5163 return True;
5166 /*******************************************************************
5167 inits a SAM_USER_INFO_7 structure.
5168 ********************************************************************/
5170 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5172 DEBUG(5, ("init_sam_user_info7\n"));
5174 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5175 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5179 /*******************************************************************
5180 reads or writes a structure.
5181 ********************************************************************/
5183 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5184 prs_struct *ps, int depth)
5186 if (usr == NULL)
5187 return False;
5189 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5190 depth++;
5192 if(!prs_align(ps))
5193 return False;
5195 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5196 return False;
5198 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5199 return False;
5201 return True;
5204 /*******************************************************************
5205 inits a SAM_USER_INFO_10 structure.
5206 ********************************************************************/
5208 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5210 DEBUG(5, ("init_sam_user_info10\n"));
5212 usr->acb_info = acb_info;
5215 /*******************************************************************
5216 reads or writes a structure.
5217 ********************************************************************/
5219 static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr,
5220 prs_struct *ps, int depth)
5222 if (usr == NULL)
5223 return False;
5225 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5226 depth++;
5228 if(!prs_align(ps))
5229 return False;
5231 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5232 return False;
5234 return True;
5237 /*******************************************************************
5238 inits a SAM_USER_INFO_11 structure.
5239 ********************************************************************/
5241 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5242 NTTIME * expiry,
5243 char *mach_acct,
5244 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5246 DEBUG(5, ("init_sam_user_info11\n"));
5248 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5249 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5251 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5253 usr->ptr_1 = 1; /* pointer */
5254 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5255 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5257 usr->ptr_2 = 1; /* pointer */
5258 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5260 usr->ptr_3 = 1; /* pointer */
5261 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5263 usr->rid_user = rid_user;
5264 usr->rid_group = rid_group;
5266 usr->acct_ctrl = acct_ctrl;
5267 usr->unknown_3 = 0x0000;
5269 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5270 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5272 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5273 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5275 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5276 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5279 /*******************************************************************
5280 reads or writes a structure.
5281 ********************************************************************/
5283 static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr,
5284 prs_struct *ps, int depth)
5286 if (usr == NULL)
5287 return False;
5289 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5290 depth++;
5292 if(!prs_align(ps))
5293 return False;
5295 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5296 return False;
5298 if(!smb_io_time("time", &usr->expiry, ps, depth))
5299 return False;
5301 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5302 return False;
5304 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5305 return False;
5307 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5308 return False;
5310 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5311 return False;
5312 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5313 return False;
5315 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5316 return False;
5318 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5319 return False;
5320 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5321 return False;
5323 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5324 return False;
5325 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5326 return False;
5328 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5329 return False;
5330 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5331 return False;
5332 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5333 return False;
5334 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5335 return False;
5336 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5337 return False;
5338 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5339 return False;
5341 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5342 return False;
5344 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5345 return False;
5347 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5348 return False;
5350 if(!prs_align(ps))
5351 return False;
5353 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5354 return False;
5356 return True;
5359 /*************************************************************************
5360 init_sam_user_infoa
5361 *************************************************************************/
5363 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5365 DEBUG(10, ("init_sam_user_info24:\n"));
5366 memcpy(usr->pass, newpass, sizeof(usr->pass));
5367 usr->pw_len = pw_len;
5370 /*******************************************************************
5371 reads or writes a structure.
5372 ********************************************************************/
5374 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5375 prs_struct *ps, int depth)
5377 if (usr == NULL)
5378 return False;
5380 prs_debug(ps, depth, desc, "sam_io_user_info24");
5381 depth++;
5383 if(!prs_align(ps))
5384 return False;
5386 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5387 sizeof(usr->pass)))
5388 return False;
5390 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5391 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5392 return False;
5394 if(!prs_align(ps))
5395 return False;
5397 return True;
5400 /*************************************************************************
5401 init_sam_user_info23
5403 unknown_6 = 0x0000 04ec
5405 *************************************************************************/
5407 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5408 NTTIME * logoff_time, /* all zeros */
5409 NTTIME * kickoff_time, /* all zeros */
5410 NTTIME * pass_last_set_time, /* all zeros */
5411 NTTIME * pass_can_change_time, /* all zeros */
5412 NTTIME * pass_must_change_time, /* all zeros */
5413 UNISTR2 *user_name,
5414 UNISTR2 *full_name,
5415 UNISTR2 *home_dir,
5416 UNISTR2 *dir_drive,
5417 UNISTR2 *log_scr,
5418 UNISTR2 *prof_path,
5419 UNISTR2 *desc,
5420 UNISTR2 *wkstas,
5421 UNISTR2 *unk_str,
5422 UNISTR2 *mung_dial,
5423 uint32 user_rid, /* 0x0000 0000 */
5424 uint32 group_rid,
5425 uint32 acb_info,
5426 uint32 fields_present,
5427 uint16 logon_divs,
5428 LOGON_HRS * hrs,
5429 uint16 bad_password_count,
5430 uint16 logon_count,
5431 char newpass[516])
5433 usr->logon_time = *logon_time; /* all zeros */
5434 usr->logoff_time = *logoff_time; /* all zeros */
5435 usr->kickoff_time = *kickoff_time; /* all zeros */
5436 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5437 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5438 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5440 ZERO_STRUCT(usr->nt_pwd);
5441 ZERO_STRUCT(usr->lm_pwd);
5443 usr->user_rid = user_rid; /* 0x0000 0000 */
5444 usr->group_rid = group_rid;
5445 usr->acb_info = acb_info;
5446 usr->fields_present = fields_present; /* 09f8 27fa */
5448 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5449 usr->ptr_logon_hrs = hrs ? 1 : 0;
5451 if (nt_time_is_zero(pass_must_change_time)) {
5452 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5453 } else {
5454 usr->passmustchange=0;
5457 ZERO_STRUCT(usr->padding1);
5458 ZERO_STRUCT(usr->padding2);
5460 usr->bad_password_count = bad_password_count;
5461 usr->logon_count = logon_count;
5463 memcpy(usr->pass, newpass, sizeof(usr->pass));
5465 copy_unistr2(&usr->uni_user_name, user_name);
5466 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5468 copy_unistr2(&usr->uni_full_name, full_name);
5469 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5471 copy_unistr2(&usr->uni_home_dir, home_dir);
5472 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5474 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5475 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5477 copy_unistr2(&usr->uni_logon_script, log_scr);
5478 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5480 copy_unistr2(&usr->uni_profile_path, prof_path);
5481 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5483 copy_unistr2(&usr->uni_acct_desc, desc);
5484 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5486 copy_unistr2(&usr->uni_workstations, wkstas);
5487 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5489 copy_unistr2(&usr->uni_unknown_str, unk_str);
5490 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5492 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5493 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5495 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5498 /*************************************************************************
5499 init_sam_user_info23
5501 unknown_6 = 0x0000 04ec
5503 *************************************************************************/
5505 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5506 NTTIME * logoff_time, /* all zeros */
5507 NTTIME * kickoff_time, /* all zeros */
5508 NTTIME * pass_last_set_time, /* all zeros */
5509 NTTIME * pass_can_change_time, /* all zeros */
5510 NTTIME * pass_must_change_time, /* all zeros */
5511 char *user_name, /* NULL */
5512 char *full_name,
5513 char *home_dir, char *dir_drive, char *log_scr,
5514 char *prof_path, const char *desc, char *wkstas,
5515 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5516 uint32 group_rid, uint32 acb_info,
5517 uint32 fields_present, uint16 logon_divs,
5518 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5519 char newpass[516])
5521 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5523 usr->logon_time = *logon_time; /* all zeros */
5524 usr->logoff_time = *logoff_time; /* all zeros */
5525 usr->kickoff_time = *kickoff_time; /* all zeros */
5526 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5527 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5528 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5530 ZERO_STRUCT(usr->nt_pwd);
5531 ZERO_STRUCT(usr->lm_pwd);
5533 usr->user_rid = user_rid; /* 0x0000 0000 */
5534 usr->group_rid = group_rid;
5535 usr->acb_info = acb_info;
5536 usr->fields_present = fields_present; /* 09f8 27fa */
5538 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5539 usr->ptr_logon_hrs = hrs ? 1 : 0;
5541 if (nt_time_is_zero(pass_must_change_time)) {
5542 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5543 } else {
5544 usr->passmustchange=0;
5547 ZERO_STRUCT(usr->padding1);
5548 ZERO_STRUCT(usr->padding2);
5550 usr->bad_password_count = bad_password_count;
5551 usr->logon_count = logon_count;
5553 memcpy(usr->pass, newpass, sizeof(usr->pass));
5555 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5556 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5558 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5559 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5561 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5562 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5564 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5565 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5567 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5568 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5570 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5571 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5573 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5574 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5576 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5577 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5579 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5580 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5582 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5583 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5585 data_blob_free(&blob);
5587 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5590 /*******************************************************************
5591 reads or writes a structure.
5592 ********************************************************************/
5594 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5595 prs_struct *ps, int depth)
5597 if (usr == NULL)
5598 return False;
5600 prs_debug(ps, depth, desc, "sam_io_user_info23");
5601 depth++;
5603 if(!prs_align(ps))
5604 return False;
5606 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5607 return False;
5608 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5609 return False;
5610 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5611 return False;
5612 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5613 return False;
5614 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5615 return False;
5616 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5617 return False;
5619 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5620 return False;
5621 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5622 return False;
5623 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5624 return False;
5625 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5626 return False;
5627 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5628 return False;
5629 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5630 return False;
5631 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5632 return False;
5633 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5634 return False;
5635 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5636 return False;
5637 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5638 return False;
5640 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5641 return False;
5642 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5643 return False;
5645 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5646 return False;
5647 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5648 return False;
5649 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5650 return False;
5652 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5653 return False;
5654 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5655 return False;
5656 if(!prs_align(ps))
5657 return False;
5658 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5659 return False;
5661 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5662 return False;
5663 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5664 return False;
5666 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5667 return False;
5668 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5669 return False;
5670 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5671 return False;
5674 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5675 return False;
5677 /* here begins pointed-to data */
5679 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5680 return False;
5682 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5683 return False;
5685 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5686 return False;
5688 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5689 return False;
5691 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5692 return False;
5694 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5695 return False;
5697 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5698 return False;
5700 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5701 return False;
5703 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5704 return False;
5706 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5707 return False;
5709 /* ok, this is only guess-work (as usual) */
5710 if (usr->ptr_logon_hrs) {
5711 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5712 return False;
5715 return True;
5718 /*******************************************************************
5719 reads or writes a structure.
5720 NB. This structure is *definately* incorrect. It's my best guess
5721 currently for W2K SP2. The password field is encrypted in a different
5722 way than normal... And there are definately other problems. JRA.
5723 ********************************************************************/
5725 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5727 if (usr == NULL)
5728 return False;
5730 prs_debug(ps, depth, desc, "sam_io_user_info25");
5731 depth++;
5733 if(!prs_align(ps))
5734 return False;
5736 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5737 return False;
5738 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5739 return False;
5740 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5741 return False;
5742 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5743 return False;
5744 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5745 return False;
5746 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5747 return False;
5749 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5750 return False;
5751 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5752 return False;
5753 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5754 return False;
5755 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5756 return False;
5757 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5758 return False;
5759 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5760 return False;
5761 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5762 return False;
5763 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5764 return False;
5765 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5766 return False;
5767 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5768 return False;
5770 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5771 return False;
5772 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5773 return False;
5775 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5776 return False;
5777 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5778 return False;
5779 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5780 return False;
5782 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5783 return False;
5785 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5786 return False;
5788 /* here begins pointed-to data */
5790 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5791 return False;
5793 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5794 return False;
5796 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5797 return False;
5799 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5800 return False;
5802 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5803 return False;
5805 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5806 return False;
5808 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5809 return False;
5811 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5812 return False;
5814 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5815 return False;
5817 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5818 return False;
5820 #if 0 /* JRA - unknown... */
5821 /* ok, this is only guess-work (as usual) */
5822 if (usr->ptr_logon_hrs) {
5823 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5824 return False;
5826 #endif
5828 return True;
5832 /*************************************************************************
5833 init_sam_user_info21W
5835 unknown_6 = 0x0000 04ec
5837 *************************************************************************/
5839 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5840 NTTIME * logon_time,
5841 NTTIME * logoff_time,
5842 NTTIME * kickoff_time,
5843 NTTIME * pass_last_set_time,
5844 NTTIME * pass_can_change_time,
5845 NTTIME * pass_must_change_time,
5846 UNISTR2 *user_name,
5847 UNISTR2 *full_name,
5848 UNISTR2 *home_dir,
5849 UNISTR2 *dir_drive,
5850 UNISTR2 *log_scr,
5851 UNISTR2 *prof_path,
5852 UNISTR2 *desc,
5853 UNISTR2 *wkstas,
5854 UNISTR2 *unk_str,
5855 UNISTR2 *mung_dial,
5856 uchar lm_pwd[16],
5857 uchar nt_pwd[16],
5858 uint32 user_rid,
5859 uint32 group_rid,
5860 uint32 acb_info,
5861 uint32 fields_present,
5862 uint16 logon_divs,
5863 LOGON_HRS * hrs,
5864 uint16 bad_password_count,
5865 uint16 logon_count)
5867 usr->logon_time = *logon_time;
5868 usr->logoff_time = *logoff_time;
5869 usr->kickoff_time = *kickoff_time;
5870 usr->pass_last_set_time = *pass_last_set_time;
5871 usr->pass_can_change_time = *pass_can_change_time;
5872 usr->pass_must_change_time = *pass_must_change_time;
5874 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5875 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5877 usr->user_rid = user_rid;
5878 usr->group_rid = group_rid;
5879 usr->acb_info = acb_info;
5880 usr->fields_present = fields_present; /* 0x00ff ffff */
5882 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5883 usr->ptr_logon_hrs = hrs ? 1 : 0;
5884 usr->bad_password_count = bad_password_count;
5885 usr->logon_count = logon_count;
5887 if (nt_time_is_zero(pass_must_change_time)) {
5888 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5889 } else {
5890 usr->passmustchange=0;
5893 ZERO_STRUCT(usr->padding1);
5894 ZERO_STRUCT(usr->padding2);
5896 copy_unistr2(&usr->uni_user_name, user_name);
5897 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5899 copy_unistr2(&usr->uni_full_name, full_name);
5900 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5902 copy_unistr2(&usr->uni_home_dir, home_dir);
5903 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5905 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5906 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5908 copy_unistr2(&usr->uni_logon_script, log_scr);
5909 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5911 copy_unistr2(&usr->uni_profile_path, prof_path);
5912 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5914 copy_unistr2(&usr->uni_acct_desc, desc);
5915 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5917 copy_unistr2(&usr->uni_workstations, wkstas);
5918 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5920 copy_unistr2(&usr->uni_unknown_str, unk_str);
5921 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5923 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5924 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5926 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5929 /*************************************************************************
5930 init_sam_user_info21
5932 unknown_6 = 0x0000 04ec
5934 *************************************************************************/
5936 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5938 NTTIME logon_time, logoff_time, kickoff_time,
5939 pass_last_set_time, pass_can_change_time,
5940 pass_must_change_time;
5942 const char* user_name = pdb_get_username(pw);
5943 const char* full_name = pdb_get_fullname(pw);
5944 const char* home_dir = pdb_get_homedir(pw);
5945 const char* dir_drive = pdb_get_dir_drive(pw);
5946 const char* logon_script = pdb_get_logon_script(pw);
5947 const char* profile_path = pdb_get_profile_path(pw);
5948 const char* description = pdb_get_acct_desc(pw);
5949 const char* workstations = pdb_get_workstations(pw);
5950 const char* munged_dial = pdb_get_munged_dial(pw);
5951 DATA_BLOB munged_dial_blob;
5953 uint32 user_rid;
5954 const DOM_SID *user_sid;
5956 uint32 group_rid;
5957 const DOM_SID *group_sid;
5959 if (munged_dial) {
5960 munged_dial_blob = base64_decode_data_blob(munged_dial);
5961 } else {
5962 munged_dial_blob = data_blob(NULL, 0);
5965 /* Create NTTIME structs */
5966 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5967 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5968 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5969 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5970 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
5971 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
5973 /* structure assignment */
5974 usr->logon_time = logon_time;
5975 usr->logoff_time = logoff_time;
5976 usr->kickoff_time = kickoff_time;
5977 usr->pass_last_set_time = pass_last_set_time;
5978 usr->pass_can_change_time = pass_can_change_time;
5979 usr->pass_must_change_time = pass_must_change_time;
5981 ZERO_STRUCT(usr->nt_pwd);
5982 ZERO_STRUCT(usr->lm_pwd);
5984 user_sid = pdb_get_user_sid(pw);
5986 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
5987 fstring user_sid_string;
5988 fstring domain_sid_string;
5989 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
5990 "the domain sid %s. Failing operation.\n",
5991 user_name,
5992 sid_to_string(user_sid_string, user_sid),
5993 sid_to_string(domain_sid_string, domain_sid)));
5994 data_blob_free(&munged_dial_blob);
5995 return NT_STATUS_UNSUCCESSFUL;
5998 group_sid = pdb_get_group_sid(pw);
6000 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6001 fstring group_sid_string;
6002 fstring domain_sid_string;
6003 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6004 "which conflicts with the domain sid %s. Failing operation.\n",
6005 user_name,
6006 sid_to_string(group_sid_string, group_sid),
6007 sid_to_string(domain_sid_string, domain_sid)));
6008 data_blob_free(&munged_dial_blob);
6009 return NT_STATUS_UNSUCCESSFUL;
6012 usr->user_rid = user_rid;
6013 usr->group_rid = group_rid;
6014 usr->acb_info = pdb_get_acct_ctrl(pw);
6017 Look at a user on a real NT4 PDC with usrmgr, press
6018 'ok'. Then you will see that fields_present is set to
6019 0x08f827fa. Look at the user immediately after that again,
6020 and you will see that 0x00fffff is returned. This solves
6021 the problem that you get access denied after having looked
6022 at the user.
6023 -- Volker
6025 usr->fields_present = pdb_build_fields_present(pw);
6027 usr->logon_divs = pdb_get_logon_divs(pw);
6028 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6029 usr->bad_password_count = pdb_get_bad_password_count(pw);
6030 usr->logon_count = pdb_get_logon_count(pw);
6032 if (pdb_get_pass_must_change_time(pw) == 0) {
6033 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6034 } else {
6035 usr->passmustchange=0;
6038 ZERO_STRUCT(usr->padding1);
6039 ZERO_STRUCT(usr->padding2);
6041 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6042 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6044 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6045 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6047 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6048 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6050 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6051 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6053 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6054 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6056 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6057 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6059 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6060 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6062 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6063 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6065 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6066 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6068 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6069 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6070 data_blob_free(&munged_dial_blob);
6072 if (pdb_get_hours(pw)) {
6073 usr->logon_hrs.max_len = 1260;
6074 usr->logon_hrs.offset = 0;
6075 usr->logon_hrs.len = pdb_get_hours_len(pw);
6076 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6077 } else {
6078 usr->logon_hrs.max_len = 1260;
6079 usr->logon_hrs.offset = 0;
6080 usr->logon_hrs.len = 0;
6081 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6084 return NT_STATUS_OK;
6087 /*******************************************************************
6088 reads or writes a structure.
6089 ********************************************************************/
6091 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6092 prs_struct *ps, int depth)
6094 if (usr == NULL)
6095 return False;
6097 prs_debug(ps, depth, desc, "sam_io_user_info21");
6098 depth++;
6100 if(!prs_align(ps))
6101 return False;
6103 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6104 return False;
6105 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6106 return False;
6107 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6108 return False;
6109 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6110 return False;
6111 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6112 return False;
6113 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6114 return False;
6116 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6117 return False;
6118 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6119 return False;
6120 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6121 return False;
6122 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6123 return False;
6124 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6125 return False;
6126 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6127 return False;
6128 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6129 return False;
6130 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6131 return False;
6132 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6133 return False;
6134 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6135 return False;
6137 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6138 return False;
6139 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6140 return False;
6142 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6143 return False;
6144 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6145 return False;
6146 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6147 return False;
6149 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6150 return False;
6151 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6152 return False;
6153 if(!prs_align(ps))
6154 return False;
6155 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6156 return False;
6158 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6159 return False;
6160 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6161 return False;
6163 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6164 return False;
6165 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6166 return False;
6167 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6168 return False;
6170 /* here begins pointed-to data */
6172 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6173 return False;
6174 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6175 return False;
6176 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6177 return False;
6178 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6179 return False;
6180 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6181 return False;
6182 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6183 return False;
6184 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6185 return False;
6186 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6187 return False;
6188 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6189 return False;
6190 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6191 return False;
6193 /* ok, this is only guess-work (as usual) */
6194 if (usr->ptr_logon_hrs) {
6195 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6196 return False;
6199 return True;
6202 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6204 const char *munged_dial = pdb_get_munged_dial(pw);
6205 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6207 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6208 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6209 data_blob_free(&blob);
6212 /*******************************************************************
6213 reads or writes a structure.
6214 ********************************************************************/
6216 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6217 prs_struct *ps, int depth)
6219 if (usr == NULL)
6220 return False;
6222 prs_debug(ps, depth, desc, "sam_io_user_info20");
6223 depth++;
6225 if(!prs_align(ps))
6226 return False;
6228 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6229 return False;
6231 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6232 return False;
6234 return True;
6237 /*******************************************************************
6238 inits a SAM_USERINFO_CTR structure.
6239 ********************************************************************/
6241 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6242 uint16 switch_value,
6243 SAM_USER_INFO_21 * usr)
6245 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6247 ctr->switch_value = switch_value;
6248 ctr->info.id = NULL;
6250 switch (switch_value) {
6251 case 0x10:
6252 ctr->info.id10 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_10);
6253 if (ctr->info.id10 == NULL)
6254 return NT_STATUS_NO_MEMORY;
6256 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6257 break;
6258 #if 0
6259 /* whoops - got this wrong. i think. or don't understand what's happening. */
6260 case 0x11:
6262 NTTIME expire;
6263 info = (void *)&id11;
6265 expire.low = 0xffffffff;
6266 expire.high = 0x7fffffff;
6268 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_11);
6269 init_sam_user_info11(ctr->info.id11, &expire,
6270 "BROOKFIELDS$", /* name */
6271 0x03ef, /* user rid */
6272 0x201, /* group rid */
6273 0x0080); /* acb info */
6275 break;
6277 #endif
6278 case 0x12:
6279 ctr->info.id12 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_12);
6280 if (ctr->info.id12 == NULL)
6281 return NT_STATUS_NO_MEMORY;
6283 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6284 break;
6285 case 21:
6287 SAM_USER_INFO_21 *cusr;
6288 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6289 ctr->info.id21 = cusr;
6290 if (ctr->info.id21 == NULL)
6291 return NT_STATUS_NO_MEMORY;
6292 memcpy(cusr, usr, sizeof(*usr));
6293 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6294 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6295 break;
6297 default:
6298 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6299 return NT_STATUS_INVALID_INFO_CLASS;
6302 return NT_STATUS_OK;
6305 /*******************************************************************
6306 inits a SAM_USERINFO_CTR structure.
6307 ********************************************************************/
6309 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6310 uint16 switch_value, void *info)
6312 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6314 ctr->switch_value = switch_value;
6315 ctr->info.id = info;
6317 switch (switch_value) {
6318 case 0x18:
6319 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6320 dump_data(100, (char *)sess_key->data, sess_key->length);
6321 dump_data(100, (char *)ctr->info.id24->pass, 516);
6322 break;
6323 case 0x17:
6324 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6325 dump_data(100, (char *)sess_key->data, sess_key->length);
6326 dump_data(100, (char *)ctr->info.id23->pass, 516);
6327 break;
6328 case 0x07:
6329 break;
6330 default:
6331 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6335 /*******************************************************************
6336 reads or writes a structure.
6337 ********************************************************************/
6339 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6340 prs_struct *ps, int depth)
6342 BOOL ret;
6343 SAM_USERINFO_CTR *ctr;
6345 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6346 depth++;
6348 if (UNMARSHALLING(ps)) {
6349 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6350 if (ctr == NULL)
6351 return False;
6352 *ppctr = ctr;
6353 } else {
6354 ctr = *ppctr;
6357 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6359 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6360 return False;
6361 if(!prs_align(ps))
6362 return False;
6364 ret = False;
6366 switch (ctr->switch_value) {
6367 case 0x07:
6368 if (UNMARSHALLING(ps))
6369 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6370 if (ctr->info.id7 == NULL) {
6371 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6372 return False;
6374 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6375 break;
6376 case 0x10:
6377 if (UNMARSHALLING(ps))
6378 ctr->info.id10 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_10,1);
6379 if (ctr->info.id10 == NULL) {
6380 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6381 return False;
6383 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6384 break;
6385 case 0x11:
6386 if (UNMARSHALLING(ps))
6387 ctr->info.id11 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_11,1);
6389 if (ctr->info.id11 == NULL) {
6390 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6391 return False;
6393 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6394 break;
6395 case 0x12:
6396 if (UNMARSHALLING(ps))
6397 ctr->info.id12 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_12,1);
6399 if (ctr->info.id12 == NULL) {
6400 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6401 return False;
6403 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6404 break;
6405 case 20:
6406 if (UNMARSHALLING(ps))
6407 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6409 if (ctr->info.id20 == NULL) {
6410 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6411 return False;
6413 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6414 break;
6415 case 21:
6416 if (UNMARSHALLING(ps))
6417 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6419 if (ctr->info.id21 == NULL) {
6420 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6421 return False;
6423 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6424 break;
6425 case 23:
6426 if (UNMARSHALLING(ps))
6427 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6429 if (ctr->info.id23 == NULL) {
6430 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6431 return False;
6433 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6434 break;
6435 case 24:
6436 if (UNMARSHALLING(ps))
6437 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6439 if (ctr->info.id24 == NULL) {
6440 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6441 return False;
6443 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6444 break;
6445 case 25:
6446 if (UNMARSHALLING(ps))
6447 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6449 if (ctr->info.id25 == NULL) {
6450 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6451 return False;
6453 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6454 break;
6455 default:
6456 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6457 ret = False;
6458 break;
6461 return ret;
6464 /*******************************************************************
6465 inits a SAMR_R_QUERY_USERINFO structure.
6466 ********************************************************************/
6468 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6469 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6471 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6473 r_u->ptr = 0;
6474 r_u->ctr = NULL;
6476 if (NT_STATUS_IS_OK(status)) {
6477 r_u->ptr = 1;
6478 r_u->ctr = ctr;
6481 r_u->status = status; /* return status */
6484 /*******************************************************************
6485 reads or writes a structure.
6486 ********************************************************************/
6488 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6489 prs_struct *ps, int depth)
6491 if (r_u == NULL)
6492 return False;
6494 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6495 depth++;
6497 if(!prs_align(ps))
6498 return False;
6500 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6501 return False;
6503 if (r_u->ptr != 0) {
6504 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6505 return False;
6508 if(!prs_align(ps))
6509 return False;
6510 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6511 return False;
6513 return True;
6516 /*******************************************************************
6517 inits a SAMR_Q_SET_USERINFO structure.
6518 ********************************************************************/
6520 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6521 POLICY_HND *hnd, DATA_BLOB *sess_key,
6522 uint16 switch_value, void *info)
6524 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6526 q_u->pol = *hnd;
6527 q_u->switch_value = switch_value;
6528 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6531 /*******************************************************************
6532 reads or writes a structure.
6533 ********************************************************************/
6535 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6536 prs_struct *ps, int depth)
6538 if (q_u == NULL)
6539 return False;
6541 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6542 depth++;
6544 if(!prs_align(ps))
6545 return False;
6547 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6549 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6550 return False;
6551 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6552 return False;
6554 return True;
6557 /*******************************************************************
6558 inits a SAMR_R_SET_USERINFO structure.
6559 ********************************************************************/
6561 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6563 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6565 r_u->status = status; /* return status */
6568 /*******************************************************************
6569 reads or writes a structure.
6570 ********************************************************************/
6572 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6573 prs_struct *ps, int depth)
6575 if (r_u == NULL)
6576 return False;
6578 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6579 depth++;
6581 if(!prs_align(ps))
6582 return False;
6584 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6585 return False;
6587 return True;
6590 /*******************************************************************
6591 inits a SAMR_Q_SET_USERINFO2 structure.
6592 ********************************************************************/
6594 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6595 POLICY_HND *hnd, DATA_BLOB *sess_key,
6596 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6598 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6600 q_u->pol = *hnd;
6601 q_u->switch_value = switch_value;
6602 q_u->ctr = ctr;
6604 if (q_u->ctr != NULL)
6605 q_u->ctr->switch_value = switch_value;
6607 switch (switch_value) {
6608 case 0x12:
6609 SamOEMhashBlob(ctr->info.id12->lm_pwd, 16, sess_key);
6610 SamOEMhashBlob(ctr->info.id12->nt_pwd, 16, sess_key);
6611 dump_data(100, (char *)sess_key->data, sess_key->length);
6612 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6613 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6614 break;
6618 /*******************************************************************
6619 reads or writes a structure.
6620 ********************************************************************/
6622 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6623 prs_struct *ps, int depth)
6625 if (q_u == NULL)
6626 return False;
6628 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6629 depth++;
6631 if(!prs_align(ps))
6632 return False;
6634 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6635 return False;
6637 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6638 return False;
6639 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6640 return False;
6642 return True;
6645 /*******************************************************************
6646 inits a SAMR_R_SET_USERINFO2 structure.
6647 ********************************************************************/
6649 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6651 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6653 r_u->status = status; /* return status */
6656 /*******************************************************************
6657 reads or writes a structure.
6658 ********************************************************************/
6660 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6661 prs_struct *ps, int depth)
6663 if (r_u == NULL)
6664 return False;
6666 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6667 depth++;
6669 if(!prs_align(ps))
6670 return False;
6672 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6673 return False;
6675 return True;
6678 /*******************************************************************
6679 inits a SAMR_Q_CONNECT structure.
6680 ********************************************************************/
6682 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6683 char *srv_name, uint32 access_mask)
6685 DEBUG(5, ("init_samr_q_connect\n"));
6687 /* make PDC server name \\server */
6688 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6689 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6691 /* example values: 0x0000 0002 */
6692 q_u->access_mask = access_mask;
6695 /*******************************************************************
6696 reads or writes a structure.
6697 ********************************************************************/
6699 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6700 prs_struct *ps, int depth)
6702 if (q_u == NULL)
6703 return False;
6705 prs_debug(ps, depth, desc, "samr_io_q_connect");
6706 depth++;
6708 if(!prs_align(ps))
6709 return False;
6711 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6712 return False;
6713 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6714 return False;
6716 if(!prs_align(ps))
6717 return False;
6718 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6719 return False;
6721 return True;
6724 /*******************************************************************
6725 reads or writes a structure.
6726 ********************************************************************/
6728 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6729 prs_struct *ps, int depth)
6731 if (r_u == NULL)
6732 return False;
6734 prs_debug(ps, depth, desc, "samr_io_r_connect");
6735 depth++;
6737 if(!prs_align(ps))
6738 return False;
6740 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6741 return False;
6743 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6744 return False;
6746 return True;
6749 /*******************************************************************
6750 inits a SAMR_Q_CONNECT4 structure.
6751 ********************************************************************/
6753 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6754 char *srv_name, uint32 access_mask)
6756 DEBUG(5, ("init_samr_q_connect\n"));
6758 /* make PDC server name \\server */
6759 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6760 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6762 /* Only value we've seen, possibly an address type ? */
6763 q_u->unk_0 = 2;
6765 /* example values: 0x0000 0002 */
6766 q_u->access_mask = access_mask;
6769 /*******************************************************************
6770 reads or writes a structure.
6771 ********************************************************************/
6773 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6774 prs_struct *ps, int depth)
6776 if (q_u == NULL)
6777 return False;
6779 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6780 depth++;
6782 if(!prs_align(ps))
6783 return False;
6785 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6786 return False;
6787 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6788 return False;
6790 if(!prs_align(ps))
6791 return False;
6792 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6793 return False;
6794 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6795 return False;
6797 return True;
6800 /*******************************************************************
6801 reads or writes a structure.
6802 ********************************************************************/
6804 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6805 prs_struct *ps, int depth)
6807 if (r_u == NULL)
6808 return False;
6810 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6811 depth++;
6813 if(!prs_align(ps))
6814 return False;
6816 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6817 return False;
6819 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6820 return False;
6822 return True;
6825 /*******************************************************************
6826 inits a SAMR_Q_CONNECT_ANON structure.
6827 ********************************************************************/
6829 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6831 DEBUG(5, ("init_samr_q_connect_anon\n"));
6833 q_u->ptr = 1;
6834 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6835 q_u->unknown_1 = 0x01;
6836 q_u->access_mask = 0x20;
6839 /*******************************************************************
6840 reads or writes a structure.
6841 ********************************************************************/
6843 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6844 prs_struct *ps, int depth)
6846 if (q_u == NULL)
6847 return False;
6849 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6850 depth++;
6852 if(!prs_align(ps))
6853 return False;
6855 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6856 return False;
6857 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6858 return False;
6859 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6860 return False;
6861 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6862 return False;
6864 return True;
6867 /*******************************************************************
6868 reads or writes a structure.
6869 ********************************************************************/
6871 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6872 prs_struct *ps, int depth)
6874 if (r_u == NULL)
6875 return False;
6877 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6878 depth++;
6880 if(!prs_align(ps))
6881 return False;
6883 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6884 return False;
6886 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6887 return False;
6889 return True;
6892 /*******************************************************************
6893 inits a SAMR_Q_GET_DOM_PWINFO structure.
6894 ********************************************************************/
6896 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6897 char *srv_name)
6899 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6901 q_u->ptr = 1;
6902 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
6903 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
6906 /*******************************************************************
6907 reads or writes a structure.
6908 ********************************************************************/
6910 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6911 prs_struct *ps, int depth)
6913 if (q_u == NULL)
6914 return False;
6916 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6917 depth++;
6919 if(!prs_align(ps))
6920 return False;
6922 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6923 return False;
6924 if (q_u->ptr != 0) {
6925 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6926 return False;
6927 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6928 return False;
6931 return True;
6934 /*******************************************************************
6935 reads or writes a structure.
6936 ********************************************************************/
6938 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6939 prs_struct *ps, int depth)
6941 if (r_u == NULL)
6942 return False;
6944 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6945 depth++;
6947 if(!prs_align(ps))
6948 return False;
6951 * see the Samba4 IDL for what these actually are.
6954 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
6955 return False;
6956 if(!prs_align(ps))
6957 return False;
6958 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
6959 return False;
6961 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6962 return False;
6964 return True;
6967 /*******************************************************************
6968 make a SAMR_ENC_PASSWD structure.
6969 ********************************************************************/
6971 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
6973 ZERO_STRUCTP(pwd);
6975 if (pass == NULL) {
6976 pwd->ptr = 0;
6977 } else {
6978 pwd->ptr = 1;
6979 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6983 /*******************************************************************
6984 reads or writes a SAMR_ENC_PASSWD structure.
6985 ********************************************************************/
6987 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
6988 prs_struct *ps, int depth)
6990 if (pwd == NULL)
6991 return False;
6993 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6994 depth++;
6996 if(!prs_align(ps))
6997 return False;
6999 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7000 return False;
7002 if (pwd->ptr != 0) {
7003 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7004 return False;
7007 return True;
7010 /*******************************************************************
7011 inits a SAMR_ENC_HASH structure.
7012 ********************************************************************/
7014 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7016 ZERO_STRUCTP(hsh);
7018 if (hash == NULL) {
7019 hsh->ptr = 0;
7020 } else {
7021 hsh->ptr = 1;
7022 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7026 /*******************************************************************
7027 reads or writes a SAMR_ENC_HASH structure.
7028 ********************************************************************/
7030 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7031 prs_struct *ps, int depth)
7033 if (hsh == NULL)
7034 return False;
7036 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7037 depth++;
7039 if(!prs_align(ps))
7040 return False;
7042 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7043 return False;
7044 if (hsh->ptr != 0) {
7045 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7046 return False;
7049 return True;
7052 /*******************************************************************
7053 inits a SAMR_R_GET_DOM_PWINFO structure.
7054 ********************************************************************/
7056 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7057 const char *dest_host, const char *user_name,
7058 const char nt_newpass[516],
7059 const uchar nt_oldhash[16],
7060 const char lm_newpass[516],
7061 const uchar lm_oldhash[16])
7063 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7065 q_u->ptr_0 = 1;
7066 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7067 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7069 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7070 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7072 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7073 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7075 q_u->unknown = 0x01;
7077 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7078 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7081 /*******************************************************************
7082 reads or writes a structure.
7083 ********************************************************************/
7085 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7086 prs_struct *ps, int depth)
7088 if (q_u == NULL)
7089 return False;
7091 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7092 depth++;
7094 if(!prs_align(ps))
7095 return False;
7097 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7098 return False;
7100 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7101 return False;
7102 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7103 return False;
7105 if(!prs_align(ps))
7106 return False;
7107 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7108 return False;
7109 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7110 return False;
7112 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7113 return False;
7114 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7115 return False;
7117 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7118 return False;
7120 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7121 return False;
7122 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7123 return False;
7125 return True;
7128 /*******************************************************************
7129 inits a SAMR_R_CHGPASSWD_USER structure.
7130 ********************************************************************/
7132 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7134 DEBUG(5, ("init_r_chgpasswd_user\n"));
7136 r_u->status = status;
7139 /*******************************************************************
7140 reads or writes a structure.
7141 ********************************************************************/
7143 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7144 prs_struct *ps, int depth)
7146 if (r_u == NULL)
7147 return False;
7149 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7150 depth++;
7152 if(!prs_align(ps))
7153 return False;
7155 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7156 return False;
7158 return True;
7161 /*******************************************************************
7162 reads or writes a structure.
7163 ********************************************************************/
7165 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7166 POLICY_HND *domain_pol, uint16 switch_value)
7168 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7170 q_u->domain_pol = *domain_pol;
7171 q_u->switch_value = switch_value;
7174 /*******************************************************************
7175 reads or writes a structure.
7176 ********************************************************************/
7178 BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7179 prs_struct *ps, int depth)
7181 if (q_u == NULL)
7182 return False;
7184 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7185 depth++;
7187 if(!prs_align(ps))
7188 return False;
7190 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7191 return False;
7193 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7194 return False;
7196 return True;
7199 /*******************************************************************
7200 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7201 ********************************************************************/
7203 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7204 uint16 switch_value, SAM_UNK_CTR * ctr,
7205 NTSTATUS status)
7207 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7209 r_u->ptr_0 = 0;
7210 r_u->switch_value = 0;
7211 r_u->status = status; /* return status */
7213 if (NT_STATUS_IS_OK(status)) {
7214 r_u->switch_value = switch_value;
7215 r_u->ptr_0 = 1;
7216 r_u->ctr = ctr;
7220 /*******************************************************************
7221 reads or writes a structure.
7222 ********************************************************************/
7224 BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u,
7225 prs_struct *ps, int depth)
7227 if (r_u == NULL)
7228 return False;
7230 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7231 depth++;
7233 if(!prs_align(ps))
7234 return False;
7236 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7237 return False;
7239 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7240 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7241 return False;
7242 if(!prs_align(ps))
7243 return False;
7245 switch (r_u->switch_value) {
7246 case 0x0c:
7247 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7248 return False;
7249 break;
7250 case 0x07:
7251 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7252 return False;
7253 break;
7254 case 0x06:
7255 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7256 return False;
7257 break;
7258 case 0x05:
7259 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7260 return False;
7261 break;
7262 case 0x03:
7263 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7264 return False;
7265 break;
7266 case 0x02:
7267 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7268 return False;
7269 break;
7270 case 0x01:
7271 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7272 return False;
7273 break;
7274 default:
7275 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7276 r_u->switch_value));
7277 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7278 return False;
7282 if(!prs_align(ps))
7283 return False;
7285 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7286 return False;
7288 return True;
7292 /*******************************************************************
7293 reads or writes a structure.
7294 ********************************************************************/
7296 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7297 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7299 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7301 q_u->domain_pol = *domain_pol;
7302 q_u->switch_value0 = switch_value;
7304 q_u->switch_value = switch_value;
7305 q_u->ctr = ctr;
7309 /*******************************************************************
7310 reads or writes a structure.
7311 ********************************************************************/
7313 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7314 prs_struct *ps, int depth)
7316 if (q_u == NULL)
7317 return False;
7319 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7320 depth++;
7322 if(!prs_align(ps))
7323 return False;
7325 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7326 return False;
7328 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7329 return False;
7331 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7332 return False;
7334 if(!prs_align(ps))
7335 return False;
7337 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7338 return False;
7340 switch (q_u->switch_value) {
7342 case 0x0c:
7343 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7344 return False;
7345 break;
7346 case 0x07:
7347 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7348 return False;
7349 break;
7350 case 0x06:
7351 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7352 return False;
7353 break;
7354 case 0x05:
7355 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7356 return False;
7357 break;
7358 case 0x03:
7359 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7360 return False;
7361 break;
7362 case 0x02:
7363 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7364 return False;
7365 break;
7366 case 0x01:
7367 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7368 return False;
7369 break;
7370 default:
7371 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7372 q_u->switch_value));
7373 return False;
7376 return True;
7379 /*******************************************************************
7380 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7381 ********************************************************************/
7383 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7385 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7387 r_u->status = status; /* return status */
7390 /*******************************************************************
7391 reads or writes a structure.
7392 ********************************************************************/
7394 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7395 prs_struct *ps, int depth)
7397 if (r_u == NULL)
7398 return False;
7400 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7401 depth++;
7403 if(!prs_align(ps))
7404 return False;
7406 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7407 return False;
7409 return True;