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.
30 #define DBGC_CLASS DBGC_RPC_PARSE
32 /*******************************************************************
33 inits a SAMR_Q_CLOSE_HND structure.
34 ********************************************************************/
36 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
38 DEBUG(5, ("init_samr_q_close_hnd\n"));
43 /*******************************************************************
44 reads or writes a structure.
45 ********************************************************************/
47 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
48 prs_struct *ps, int depth)
53 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
59 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
62 /*******************************************************************
63 reads or writes a structure.
64 ********************************************************************/
66 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
67 prs_struct *ps, int depth)
72 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
78 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
81 if(!prs_ntstatus("status", ps, depth, &r_u->status))
87 /*******************************************************************
88 inits a SAMR_Q_LOOKUP_DOMAIN structure.
89 ********************************************************************/
91 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
92 POLICY_HND *pol, char *dom_name)
94 DEBUG(5, ("init_samr_q_lookup_domain\n"));
96 q_u->connect_pol = *pol;
98 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
99 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
102 /*******************************************************************
103 reads or writes a structure.
104 ********************************************************************/
105 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
106 prs_struct *ps, int depth)
111 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
117 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
120 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
123 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
129 /*******************************************************************
130 inits a SAMR_R_LOOKUP_DOMAIN structure.
131 ********************************************************************/
133 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
134 DOM_SID *dom_sid, NTSTATUS status)
136 DEBUG(5, ("init_samr_r_lookup_domain\n"));
138 r_u->status = status;
140 if (NT_STATUS_IS_OK(status)) {
142 init_dom_sid2(&r_u->dom_sid, dom_sid);
146 /*******************************************************************
147 reads or writes a structure.
148 ********************************************************************/
150 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
151 prs_struct *ps, int depth)
156 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
162 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
165 if (r_u->ptr_sid != 0) {
166 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
172 if(!prs_ntstatus("status", ps, depth, &r_u->status))
178 /*******************************************************************
179 reads or writes a structure.
180 ********************************************************************/
182 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
184 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
186 q_u->dom_pol = *dom_pol;
187 init_dom_sid2(&q_u->sid, sid);
190 /*******************************************************************
191 reads or writes a structure.
192 ********************************************************************/
194 BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
195 prs_struct *ps, int depth)
200 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
206 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
209 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
218 /*******************************************************************
219 reads or writes a structure.
220 ********************************************************************/
222 BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
223 prs_struct *ps, int depth)
228 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
234 if(!prs_ntstatus("status", ps, depth, &r_u->status))
240 /*******************************************************************
241 reads or writes a structure.
242 ********************************************************************/
244 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
245 POLICY_HND *pol, uint32 flags,
248 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
252 init_dom_sid2(&q_u->dom_sid, sid);
255 /*******************************************************************
256 reads or writes a structure.
257 ********************************************************************/
259 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
260 prs_struct *ps, int depth)
265 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
271 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
274 if(!prs_uint32("flags", ps, depth, &q_u->flags))
277 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
283 /*******************************************************************
284 reads or writes a structure.
285 ********************************************************************/
287 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
288 prs_struct *ps, int depth)
293 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
299 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
302 if(!prs_ntstatus("status", ps, depth, &r_u->status))
308 /*******************************************************************
309 reads or writes a structure.
310 ********************************************************************/
312 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
313 POLICY_HND *user_pol)
315 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
317 q_u->user_pol = *user_pol;
320 /*******************************************************************
321 reads or writes a structure.
322 ********************************************************************/
324 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
325 prs_struct *ps, int depth)
330 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
336 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
339 /*******************************************************************
341 ********************************************************************/
343 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
345 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
347 r_u->min_pwd_length = 0x0000;
351 * r_u->unknown_1 = 0x0015;
354 r_u->unknown_1 = 0x01D1;
355 r_u->unknown_1 = 0x0015;
357 r_u->password_properties = 0x00000000;
359 r_u->status = status;
362 /*******************************************************************
363 reads or writes a structure.
364 ********************************************************************/
366 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
367 prs_struct *ps, int depth)
372 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
378 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
380 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
382 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
385 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
392 /*******************************************************************
393 reads or writes a structure.
394 ********************************************************************/
396 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
397 prs_struct *ps, int depth)
402 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
408 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
411 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
414 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
421 /*******************************************************************
422 reads or writes a structure.
423 ********************************************************************/
425 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
426 POLICY_HND *user_pol, uint32 sec_info)
428 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
430 q_u->user_pol = *user_pol;
431 q_u->sec_info = sec_info;
435 /*******************************************************************
436 reads or writes a structure.
437 ********************************************************************/
439 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
440 prs_struct *ps, int depth)
445 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
451 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
454 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
460 /*******************************************************************
461 reads or writes a structure.
462 ********************************************************************/
464 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
465 POLICY_HND *domain_pol, uint16 switch_value)
467 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
469 q_u->domain_pol = *domain_pol;
470 q_u->switch_value = switch_value;
473 /*******************************************************************
474 reads or writes a structure.
475 ********************************************************************/
477 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
478 prs_struct *ps, int depth)
483 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
489 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
492 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
499 /*******************************************************************
501 ********************************************************************/
503 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
505 u_3->logout.low = nt_logout.low;
506 u_3->logout.high = nt_logout.high;
509 /*******************************************************************
510 reads or writes a structure.
511 ********************************************************************/
513 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
514 prs_struct *ps, int depth)
519 prs_debug(ps, depth, desc, "sam_io_unk_info3");
522 if(!smb_io_time("logout", &u_3->logout, ps, depth))
528 /*******************************************************************
530 ********************************************************************/
532 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
534 u_6->unknown_0 = 0x00000000;
536 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
539 /*******************************************************************
540 reads or writes a structure.
541 ********************************************************************/
543 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
544 prs_struct *ps, int depth)
549 prs_debug(ps, depth, desc, "sam_io_unk_info6");
552 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
554 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
556 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
562 /*******************************************************************
564 ********************************************************************/
566 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
568 u_7->server_role = server_role;
571 /*******************************************************************
572 reads or writes a structure.
573 ********************************************************************/
575 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
576 prs_struct *ps, int depth)
581 prs_debug(ps, depth, desc, "sam_io_unk_info7");
584 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
590 /*******************************************************************
592 ********************************************************************/
594 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
596 unix_to_nt_time(&u_8->domain_create_time, 0);
597 u_8->seq_num.low = seq_num;
598 u_8->seq_num.high = 0x0000;
601 /*******************************************************************
602 reads or writes a structure.
603 ********************************************************************/
605 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
606 prs_struct *ps, int depth)
611 prs_debug(ps, depth, desc, "sam_io_unk_info8");
614 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
617 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
624 /*******************************************************************
626 ********************************************************************/
628 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
630 u_12->duration.low = nt_lock_duration.low;
631 u_12->duration.high = nt_lock_duration.high;
632 u_12->reset_count.low = nt_reset_time.low;
633 u_12->reset_count.high = nt_reset_time.high;
635 u_12->bad_attempt_lockout = lockout;
638 /*******************************************************************
639 reads or writes a structure.
640 ********************************************************************/
642 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
643 prs_struct *ps, int depth)
648 prs_debug(ps, depth, desc, "sam_io_unk_info12");
651 if(!smb_io_time("duration", &u_12->duration, ps, depth))
653 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
655 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
661 /*******************************************************************
663 ********************************************************************/
665 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
667 init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE);
668 init_uni_hdr(&u_5->hdr_server, &u_5->uni_server);
671 /*******************************************************************
672 reads or writes a structure.
673 ********************************************************************/
675 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
676 prs_struct *ps, int depth)
681 prs_debug(ps, depth, desc, "sam_io_unk_info5");
684 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
687 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
693 /*******************************************************************
695 ********************************************************************/
697 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
698 const char *comment, const char *domain, const char *server,
699 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
701 u_2->logout.low = nt_logout.low;
702 u_2->logout.high = nt_logout.high;
704 u_2->seq_num.low = seq_num;
705 u_2->seq_num.high = 0x00000000;
708 u_2->unknown_4 = 0x00000001;
709 u_2->server_role = server_role;
710 u_2->unknown_6 = 0x00000001;
711 u_2->num_domain_usrs = num_users;
712 u_2->num_domain_grps = num_groups;
713 u_2->num_local_grps = num_alias;
715 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
717 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
718 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
719 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
720 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
721 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
722 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
725 /*******************************************************************
726 reads or writes a structure.
727 ********************************************************************/
729 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
730 prs_struct *ps, int depth)
735 prs_debug(ps, depth, desc, "sam_io_unk_info2");
738 if(!smb_io_time("logout", &u_2->logout, ps, depth))
740 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
742 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
744 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
747 /* put all the data in here, at the moment, including what the above
748 pointer is referring to
751 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
754 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
756 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
758 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
760 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
762 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
764 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
767 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
769 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
771 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
777 /*******************************************************************
779 ********************************************************************/
781 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
782 uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
784 u_1->min_length_password = min_pass_len;
785 u_1->password_history = pass_hist;
786 u_1->password_properties = password_properties;
788 /* password never expire */
789 u_1->expire.high = nt_expire.high;
790 u_1->expire.low = nt_expire.low;
792 /* can change the password now */
793 u_1->min_passwordage.high = nt_min_age.high;
794 u_1->min_passwordage.low = nt_min_age.low;
798 /*******************************************************************
799 reads or writes a structure.
800 ********************************************************************/
802 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
803 prs_struct *ps, int depth)
808 prs_debug(ps, depth, desc, "sam_io_unk_info1");
811 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
813 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
815 if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
817 if(!smb_io_time("expire", &u_1->expire, ps, depth))
819 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
825 /*******************************************************************
826 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
827 ********************************************************************/
829 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
830 uint16 switch_value, SAM_UNK_CTR * ctr,
833 DEBUG(5, ("init_samr_r_query_dom_info\n"));
836 r_u->switch_value = 0;
837 r_u->status = status; /* return status */
839 if (NT_STATUS_IS_OK(status)) {
840 r_u->switch_value = switch_value;
846 /*******************************************************************
847 reads or writes a structure.
848 ********************************************************************/
850 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
851 prs_struct *ps, int depth)
856 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
862 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
865 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
866 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
871 switch (r_u->switch_value) {
873 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
877 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
881 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
885 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
889 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
893 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
897 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
901 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
905 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
907 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
921 /*******************************************************************
922 reads or writes a SAMR_R_SET_SEC_OBJ structure.
923 ********************************************************************/
925 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
926 prs_struct *ps, int depth)
931 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
937 if(!prs_ntstatus("status", ps, depth, &r_u->status))
943 /*******************************************************************
944 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
945 ********************************************************************/
947 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
948 prs_struct *ps, int depth)
953 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
959 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
962 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
966 if(!prs_ntstatus("status", ps, depth, &r_u->status))
972 /*******************************************************************
973 reads or writes a SAM_STR1 structure.
974 ********************************************************************/
976 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
977 uint32 name_buf, uint32 desc_buf,
978 prs_struct *ps, int depth)
983 prs_debug(ps, depth, desc, "sam_io_sam_str1");
988 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
991 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
994 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1000 /*******************************************************************
1001 inits a SAM_ENTRY1 structure.
1002 ********************************************************************/
1004 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1005 UNISTR2 *sam_name, UNISTR2 *sam_full,
1006 UNISTR2 *sam_desc, uint32 rid_user,
1009 DEBUG(5, ("init_sam_entry1\n"));
1013 sam->user_idx = user_idx;
1014 sam->rid_user = rid_user;
1015 sam->acb_info = acb_info;
1017 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1018 init_uni_hdr(&sam->hdr_user_name, sam_full);
1019 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1022 /*******************************************************************
1023 reads or writes a SAM_ENTRY1 structure.
1024 ********************************************************************/
1026 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1027 prs_struct *ps, int depth)
1032 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1038 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1041 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1043 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1049 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1051 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1053 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1059 /*******************************************************************
1060 reads or writes a SAM_STR2 structure.
1061 ********************************************************************/
1063 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1064 uint32 desc_buf, prs_struct *ps, int depth)
1069 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1075 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1077 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1083 /*******************************************************************
1084 inits a SAM_ENTRY2 structure.
1085 ********************************************************************/
1086 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1087 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1088 uint32 rid_user, uint16 acb_info)
1090 DEBUG(5, ("init_sam_entry2\n"));
1092 sam->user_idx = user_idx;
1093 sam->rid_user = rid_user;
1094 sam->acb_info = acb_info;
1096 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1097 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1100 /*******************************************************************
1101 reads or writes a SAM_ENTRY2 structure.
1102 ********************************************************************/
1104 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1105 prs_struct *ps, int depth)
1110 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1116 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1119 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1121 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1127 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1129 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1135 /*******************************************************************
1136 reads or writes a SAM_STR3 structure.
1137 ********************************************************************/
1139 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1140 uint32 desc_buf, prs_struct *ps, int depth)
1145 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1151 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1153 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1159 /*******************************************************************
1160 inits a SAM_ENTRY3 structure.
1161 ********************************************************************/
1163 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1164 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1167 DEBUG(5, ("init_sam_entry3\n"));
1169 sam->grp_idx = grp_idx;
1170 sam->rid_grp = rid_grp;
1171 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1173 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1174 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1177 /*******************************************************************
1178 reads or writes a SAM_ENTRY3 structure.
1179 ********************************************************************/
1181 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1182 prs_struct *ps, int depth)
1187 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1193 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1196 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1198 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1201 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1203 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1209 /*******************************************************************
1210 inits a SAM_ENTRY4 structure.
1211 ********************************************************************/
1213 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1214 uint32 len_acct_name)
1216 DEBUG(5, ("init_sam_entry4\n"));
1218 sam->user_idx = user_idx;
1219 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1222 /*******************************************************************
1223 reads or writes a SAM_ENTRY4 structure.
1224 ********************************************************************/
1226 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1227 prs_struct *ps, int depth)
1232 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1238 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1240 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1246 /*******************************************************************
1247 inits a SAM_ENTRY5 structure.
1248 ********************************************************************/
1250 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1251 uint32 len_grp_name)
1253 DEBUG(5, ("init_sam_entry5\n"));
1255 sam->grp_idx = grp_idx;
1256 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1260 /*******************************************************************
1261 reads or writes a SAM_ENTRY5 structure.
1262 ********************************************************************/
1264 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1265 prs_struct *ps, int depth)
1270 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1276 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1278 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1284 /*******************************************************************
1285 inits a SAM_ENTRY structure.
1286 ********************************************************************/
1288 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1290 DEBUG(10, ("init_sam_entry: %d\n", rid));
1293 init_uni_hdr(&sam->hdr_name, uni2);
1296 /*******************************************************************
1297 reads or writes a SAM_ENTRY structure.
1298 ********************************************************************/
1300 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1301 prs_struct *ps, int depth)
1306 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1311 if(!prs_uint32("rid", ps, depth, &sam->rid))
1313 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1319 /*******************************************************************
1320 inits a SAMR_Q_ENUM_DOM_USERS structure.
1321 ********************************************************************/
1323 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1325 uint16 acb_mask, uint16 unk_1, uint32 size)
1327 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1331 q_e->start_idx = start_idx; /* zero indicates lots */
1332 q_e->acb_mask = acb_mask;
1333 q_e->unknown_1 = unk_1;
1334 q_e->max_size = size;
1337 /*******************************************************************
1338 reads or writes a structure.
1339 ********************************************************************/
1341 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1342 prs_struct *ps, int depth)
1347 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1353 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1356 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1358 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1360 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1363 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1370 /*******************************************************************
1371 inits a SAMR_R_ENUM_DOM_USERS structure.
1372 ********************************************************************/
1374 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1375 uint32 next_idx, uint32 num_sam_entries)
1377 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1379 r_u->next_idx = next_idx;
1381 if (num_sam_entries != 0) {
1382 r_u->ptr_entries1 = 1;
1383 r_u->ptr_entries2 = 1;
1384 r_u->num_entries2 = num_sam_entries;
1385 r_u->num_entries3 = num_sam_entries;
1387 r_u->num_entries4 = num_sam_entries;
1389 r_u->ptr_entries1 = 0;
1390 r_u->num_entries2 = num_sam_entries;
1391 r_u->ptr_entries2 = 1;
1395 /*******************************************************************
1396 reads or writes a structure.
1397 ********************************************************************/
1399 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1400 prs_struct *ps, int depth)
1407 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1413 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1415 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1418 if (r_u->ptr_entries1 != 0) {
1419 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1421 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1423 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1426 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1427 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1428 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1431 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1432 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1433 r_u->num_entries4 = 0;
1434 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1438 for (i = 0; i < r_u->num_entries2; i++) {
1439 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1443 for (i = 0; i < r_u->num_entries2; i++) {
1444 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1453 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1455 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1461 /*******************************************************************
1462 inits a SAMR_Q_QUERY_DISPINFO structure.
1463 ********************************************************************/
1465 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1466 uint16 switch_level, uint32 start_idx,
1467 uint32 max_entries, uint32 max_size)
1469 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1471 q_e->domain_pol = *pol;
1473 q_e->switch_level = switch_level;
1475 q_e->start_idx = start_idx;
1476 q_e->max_entries = max_entries;
1477 q_e->max_size = max_size;
1480 /*******************************************************************
1481 reads or writes a structure.
1482 ********************************************************************/
1484 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1485 prs_struct *ps, int depth)
1490 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1496 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1499 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1504 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1506 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1508 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1514 /*******************************************************************
1515 inits a SAM_DISPINFO_1 structure.
1516 ********************************************************************/
1518 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1519 uint32 num_entries, uint32 start_idx,
1520 struct samr_displayentry *entries)
1524 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1527 return NT_STATUS_OK;
1529 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1531 return NT_STATUS_NO_MEMORY;
1533 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1534 if ((*sam)->sam == NULL)
1535 return NT_STATUS_NO_MEMORY;
1537 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1538 if ((*sam)->str == NULL)
1539 return NT_STATUS_NO_MEMORY;
1541 for (i = 0; i < num_entries ; i++) {
1542 init_unistr2(&(*sam)->str[i].uni_acct_name,
1543 entries[i].account_name, UNI_FLAGS_NONE);
1544 init_unistr2(&(*sam)->str[i].uni_full_name,
1545 entries[i].fullname, UNI_FLAGS_NONE);
1546 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1547 entries[i].description, UNI_FLAGS_NONE);
1549 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1550 &(*sam)->str[i].uni_acct_name,
1551 &(*sam)->str[i].uni_full_name,
1552 &(*sam)->str[i].uni_acct_desc,
1553 entries[i].rid, entries[i].acct_flags);
1556 return NT_STATUS_OK;
1559 /*******************************************************************
1560 reads or writes a structure.
1561 ********************************************************************/
1563 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1565 prs_struct *ps, int depth)
1569 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1575 if (UNMARSHALLING(ps) && num_entries > 0) {
1577 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1578 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1582 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1583 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1588 for (i = 0; i < num_entries; i++) {
1589 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1593 for (i = 0; i < num_entries; i++) {
1594 if(!sam_io_sam_str1("", &sam->str[i],
1595 sam->sam[i].hdr_acct_name.buffer,
1596 sam->sam[i].hdr_user_name.buffer,
1597 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1604 /*******************************************************************
1605 inits a SAM_DISPINFO_2 structure.
1606 ********************************************************************/
1608 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1609 uint32 num_entries, uint32 start_idx,
1610 struct samr_displayentry *entries)
1614 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1617 return NT_STATUS_OK;
1619 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1621 return NT_STATUS_NO_MEMORY;
1623 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1624 if ((*sam)->sam == NULL)
1625 return NT_STATUS_NO_MEMORY;
1627 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1628 if ((*sam)->str == NULL)
1629 return NT_STATUS_NO_MEMORY;
1631 for (i = 0; i < num_entries; i++) {
1632 init_unistr2(&(*sam)->str[i].uni_srv_name,
1633 entries[i].account_name, UNI_FLAGS_NONE);
1634 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1635 entries[i].description, UNI_FLAGS_NONE);
1637 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1638 &(*sam)->str[i].uni_srv_name,
1639 &(*sam)->str[i].uni_srv_desc,
1640 entries[i].rid, entries[i].acct_flags);
1643 return NT_STATUS_OK;
1646 /*******************************************************************
1647 reads or writes a structure.
1648 ********************************************************************/
1650 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1652 prs_struct *ps, int depth)
1659 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1665 if (UNMARSHALLING(ps) && num_entries > 0) {
1667 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1668 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1672 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1673 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1678 for (i = 0; i < num_entries; i++) {
1679 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1683 for (i = 0; i < num_entries; i++) {
1684 if(!sam_io_sam_str2("", &sam->str[i],
1685 sam->sam[i].hdr_srv_name.buffer,
1686 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1693 /*******************************************************************
1694 inits a SAM_DISPINFO_3 structure.
1695 ********************************************************************/
1697 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1698 uint32 num_entries, uint32 start_idx,
1699 struct samr_displayentry *entries)
1703 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1706 return NT_STATUS_OK;
1708 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1710 return NT_STATUS_NO_MEMORY;
1712 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1713 return NT_STATUS_NO_MEMORY;
1715 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1716 return NT_STATUS_NO_MEMORY;
1718 for (i = 0; i < num_entries; i++) {
1719 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1721 init_unistr2(&(*sam)->str[i].uni_grp_name,
1722 entries[i].account_name, UNI_FLAGS_NONE);
1723 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1724 entries[i].description, UNI_FLAGS_NONE);
1726 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1727 &(*sam)->str[i].uni_grp_name,
1728 &(*sam)->str[i].uni_grp_desc,
1732 return NT_STATUS_OK;
1735 /*******************************************************************
1736 reads or writes a structure.
1737 ********************************************************************/
1739 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1741 prs_struct *ps, int depth)
1748 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1754 if (UNMARSHALLING(ps) && num_entries > 0) {
1756 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1757 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1761 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1762 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1767 for (i = 0; i < num_entries; i++) {
1768 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1772 for (i = 0; i < num_entries; i++) {
1773 if(!sam_io_sam_str3("", &sam->str[i],
1774 sam->sam[i].hdr_grp_name.buffer,
1775 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1782 /*******************************************************************
1783 inits a SAM_DISPINFO_4 structure.
1784 ********************************************************************/
1786 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1787 uint32 num_entries, uint32 start_idx,
1788 struct samr_displayentry *entries)
1792 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1795 return NT_STATUS_OK;
1797 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1799 return NT_STATUS_NO_MEMORY;
1801 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1802 if ((*sam)->sam == NULL)
1803 return NT_STATUS_NO_MEMORY;
1805 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1806 if ((*sam)->str == NULL)
1807 return NT_STATUS_NO_MEMORY;
1809 for (i = 0; i < num_entries; i++) {
1810 size_t len_sam_name = strlen(entries[i].account_name);
1812 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1814 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1817 init_string2(&(*sam)->str[i].acct_name,
1818 entries[i].account_name, len_sam_name+1,
1822 return NT_STATUS_OK;
1825 /*******************************************************************
1826 reads or writes a structure.
1827 ********************************************************************/
1829 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1831 prs_struct *ps, int depth)
1838 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1844 if (UNMARSHALLING(ps) && num_entries > 0) {
1846 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1847 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1851 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1852 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1857 for (i = 0; i < num_entries; i++) {
1858 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1862 for (i = 0; i < num_entries; i++) {
1863 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1864 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1871 /*******************************************************************
1872 inits a SAM_DISPINFO_5 structure.
1873 ********************************************************************/
1875 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1876 uint32 num_entries, uint32 start_idx,
1877 struct samr_displayentry *entries)
1879 uint32 len_sam_name;
1882 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1885 return NT_STATUS_OK;
1887 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1889 return NT_STATUS_NO_MEMORY;
1891 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1892 return NT_STATUS_NO_MEMORY;
1894 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1895 return NT_STATUS_NO_MEMORY;
1897 for (i = 0; i < num_entries; i++) {
1898 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1900 len_sam_name = strlen(entries[i].account_name);
1902 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
1903 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
1904 len_sam_name+1, len_sam_name);
1907 return NT_STATUS_OK;
1910 /*******************************************************************
1911 reads or writes a structure.
1912 ********************************************************************/
1914 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1916 prs_struct *ps, int depth)
1923 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1929 if (UNMARSHALLING(ps) && num_entries > 0) {
1931 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1932 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1936 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1937 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1942 for (i = 0; i < num_entries; i++) {
1943 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1947 for (i = 0; i < num_entries; i++) {
1948 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1949 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1956 /*******************************************************************
1957 inits a SAMR_R_QUERY_DISPINFO structure.
1958 ********************************************************************/
1960 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1961 uint32 num_entries, uint32 total_size, uint32 data_size,
1962 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1965 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1967 r_u->total_size = total_size;
1969 r_u->data_size = data_size;
1971 r_u->switch_level = switch_level;
1972 r_u->num_entries = num_entries;
1975 r_u->ptr_entries = 0;
1977 r_u->ptr_entries = 1;
1979 r_u->num_entries2 = num_entries;
1982 r_u->status = status;
1985 /*******************************************************************
1986 reads or writes a structure.
1987 ********************************************************************/
1989 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1990 prs_struct *ps, int depth)
1995 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2001 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2003 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2005 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2010 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2012 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2015 if (r_u->ptr_entries==0) {
2018 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2024 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2027 switch (r_u->switch_level) {
2029 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2030 r_u->num_entries, ps, depth))
2034 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2035 r_u->num_entries, ps, depth))
2039 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2040 r_u->num_entries, ps, depth))
2044 if(!sam_io_sam_dispinfo_4("user list",
2045 r_u->ctr->sam.info4,
2046 r_u->num_entries, ps, depth))
2050 if(!sam_io_sam_dispinfo_5("group list",
2051 r_u->ctr->sam.info5,
2052 r_u->num_entries, ps, depth))
2056 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2062 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2068 /*******************************************************************
2069 inits a SAMR_Q_OPEN_GROUP structure.
2070 ********************************************************************/
2072 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2074 uint32 access_mask, uint32 rid)
2076 DEBUG(5, ("init_samr_q_open_group\n"));
2078 q_c->domain_pol = *hnd;
2079 q_c->access_mask = access_mask;
2080 q_c->rid_group = rid;
2083 /*******************************************************************
2084 reads or writes a structure.
2085 ********************************************************************/
2087 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2088 prs_struct *ps, int depth)
2093 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2099 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2102 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2104 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2110 /*******************************************************************
2111 reads or writes a structure.
2112 ********************************************************************/
2114 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2115 prs_struct *ps, int depth)
2120 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2126 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2129 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2135 /*******************************************************************
2136 inits a GROUP_INFO1 structure.
2137 ********************************************************************/
2139 void init_samr_group_info1(GROUP_INFO1 * gr1,
2140 char *acct_name, char *acct_desc,
2143 DEBUG(5, ("init_samr_group_info1\n"));
2145 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2146 gr1->num_members = num_members;
2148 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2149 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2150 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2151 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2154 /*******************************************************************
2155 reads or writes a structure.
2156 ********************************************************************/
2158 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2159 prs_struct *ps, int depth)
2166 prs_debug(ps, depth, desc, "samr_io_group_info1");
2169 if(!prs_uint16("level", ps, depth, &dummy))
2175 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2178 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2180 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2183 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2186 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2187 gr1->hdr_acct_name.buffer, ps, depth))
2190 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2191 gr1->hdr_acct_desc.buffer, ps, depth))
2197 /*******************************************************************
2198 inits a GROUP_INFO2 structure.
2199 ********************************************************************/
2201 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2203 DEBUG(5, ("init_samr_group_info2\n"));
2206 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2207 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2210 /*******************************************************************
2211 reads or writes a structure.
2212 ********************************************************************/
2214 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2219 prs_debug(ps, depth, desc, "samr_io_group_info2");
2222 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2225 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2227 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2228 gr2->hdr_acct_name.buffer, ps, depth))
2234 /*******************************************************************
2235 inits a GROUP_INFO3 structure.
2236 ********************************************************************/
2238 void init_samr_group_info3(GROUP_INFO3 *gr3)
2240 DEBUG(5, ("init_samr_group_info3\n"));
2242 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2245 /*******************************************************************
2246 reads or writes a structure.
2247 ********************************************************************/
2249 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2254 prs_debug(ps, depth, desc, "samr_io_group_info3");
2260 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2266 /*******************************************************************
2267 inits a GROUP_INFO4 structure.
2268 ********************************************************************/
2270 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2272 DEBUG(5, ("init_samr_group_info4\n"));
2275 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2276 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2279 /*******************************************************************
2280 reads or writes a structure.
2281 ********************************************************************/
2283 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2284 prs_struct *ps, int depth)
2289 prs_debug(ps, depth, desc, "samr_io_group_info4");
2292 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2294 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2296 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2297 gr4->hdr_acct_desc.buffer, ps, depth))
2303 /*******************************************************************
2304 reads or writes a structure.
2305 ********************************************************************/
2307 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2308 prs_struct *ps, int depth)
2310 if (UNMARSHALLING(ps))
2311 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2316 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2319 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2322 switch ((*ctr)->switch_value1) {
2324 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2328 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2332 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2336 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2340 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2347 /*******************************************************************
2348 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2349 ********************************************************************/
2351 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2352 POLICY_HND *pol, const char *acct_desc,
2355 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2359 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2360 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2362 q_e->access_mask = access_mask;
2365 /*******************************************************************
2366 reads or writes a structure.
2367 ********************************************************************/
2369 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2370 prs_struct *ps, int depth)
2375 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2381 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2384 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2386 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2387 q_e->hdr_acct_desc.buffer, ps, depth))
2392 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2398 /*******************************************************************
2399 reads or writes a structure.
2400 ********************************************************************/
2402 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2403 prs_struct *ps, int depth)
2408 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2414 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2417 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2419 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2425 /*******************************************************************
2426 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2427 ********************************************************************/
2429 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2432 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2434 q_c->group_pol = *hnd;
2437 /*******************************************************************
2438 reads or writes a structure.
2439 ********************************************************************/
2441 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2442 prs_struct *ps, int depth)
2447 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2453 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2459 /*******************************************************************
2460 reads or writes a structure.
2461 ********************************************************************/
2463 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2464 prs_struct *ps, int depth)
2469 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2475 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2478 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2484 /*******************************************************************
2485 inits a SAMR_Q_DEL_GROUPMEM structure.
2486 ********************************************************************/
2488 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2489 POLICY_HND *pol, uint32 rid)
2491 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2497 /*******************************************************************
2498 reads or writes a structure.
2499 ********************************************************************/
2501 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2502 prs_struct *ps, int depth)
2507 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2513 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2516 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2522 /*******************************************************************
2523 inits a SAMR_R_DEL_GROUPMEM structure.
2524 ********************************************************************/
2526 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2529 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2531 r_u->status = status;
2534 /*******************************************************************
2535 reads or writes a structure.
2536 ********************************************************************/
2538 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2539 prs_struct *ps, int depth)
2544 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2550 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2556 /*******************************************************************
2557 inits a SAMR_Q_ADD_GROUPMEM structure.
2558 ********************************************************************/
2560 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2561 POLICY_HND *pol, uint32 rid)
2563 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2567 q_e->unknown = 0x0005;
2570 /*******************************************************************
2571 reads or writes a structure.
2572 ********************************************************************/
2574 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2575 prs_struct *ps, int depth)
2580 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2586 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2589 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2591 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2597 /*******************************************************************
2598 inits a SAMR_R_ADD_GROUPMEM structure.
2599 ********************************************************************/
2601 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2604 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2606 r_u->status = status;
2609 /*******************************************************************
2610 reads or writes a structure.
2611 ********************************************************************/
2613 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2614 prs_struct *ps, int depth)
2619 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2625 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2631 /*******************************************************************
2632 inits a SAMR_Q_SET_GROUPINFO structure.
2633 ********************************************************************/
2635 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2636 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2638 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2644 /*******************************************************************
2645 reads or writes a structure.
2646 ********************************************************************/
2648 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2649 prs_struct *ps, int depth)
2654 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2660 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2663 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2669 /*******************************************************************
2670 inits a SAMR_R_SET_GROUPINFO structure.
2671 ********************************************************************/
2673 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2675 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2677 r_u->status = status;
2680 /*******************************************************************
2681 reads or writes a structure.
2682 ********************************************************************/
2684 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2685 prs_struct *ps, int depth)
2690 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2696 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2702 /*******************************************************************
2703 inits a SAMR_Q_QUERY_GROUPINFO structure.
2704 ********************************************************************/
2706 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2707 POLICY_HND *pol, uint16 switch_level)
2709 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2713 q_e->switch_level = switch_level;
2716 /*******************************************************************
2717 reads or writes a structure.
2718 ********************************************************************/
2720 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2721 prs_struct *ps, int depth)
2726 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2732 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2735 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2741 /*******************************************************************
2742 inits a SAMR_R_QUERY_GROUPINFO structure.
2743 ********************************************************************/
2745 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2746 GROUP_INFO_CTR * ctr, NTSTATUS status)
2748 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2750 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2752 r_u->status = status;
2755 /*******************************************************************
2756 reads or writes a structure.
2757 ********************************************************************/
2759 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2760 prs_struct *ps, int depth)
2765 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2771 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2774 if (r_u->ptr != 0) {
2775 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2781 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2787 /*******************************************************************
2788 inits a SAMR_Q_QUERY_GROUPMEM structure.
2789 ********************************************************************/
2791 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2793 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2795 q_c->group_pol = *hnd;
2798 /*******************************************************************
2799 reads or writes a structure.
2800 ********************************************************************/
2802 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2803 prs_struct *ps, int depth)
2808 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2814 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2820 /*******************************************************************
2821 inits a SAMR_R_QUERY_GROUPMEM structure.
2822 ********************************************************************/
2824 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2825 uint32 num_entries, uint32 *rid,
2826 uint32 *attr, NTSTATUS status)
2828 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2830 if (NT_STATUS_IS_OK(status)) {
2832 r_u->num_entries = num_entries;
2834 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2835 r_u->ptr_rids = rid != NULL ? 1 : 0;
2837 r_u->num_rids = num_entries;
2840 r_u->num_attrs = num_entries;
2844 r_u->num_entries = 0;
2847 r_u->status = status;
2850 /*******************************************************************
2851 reads or writes a structure.
2852 ********************************************************************/
2854 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2855 prs_struct *ps, int depth)
2862 if (UNMARSHALLING(ps))
2865 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2871 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2873 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2876 if (r_u->ptr != 0) {
2877 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2879 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2882 if (r_u->ptr_rids != 0) {
2883 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2885 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2886 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2887 if (r_u->rid == NULL)
2891 for (i = 0; i < r_u->num_rids; i++) {
2892 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2897 if (r_u->ptr_attrs != 0) {
2898 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2901 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2902 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2903 if (r_u->attr == NULL)
2907 for (i = 0; i < r_u->num_attrs; i++) {
2908 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2914 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2920 /*******************************************************************
2921 inits a SAMR_Q_QUERY_USERGROUPS structure.
2922 ********************************************************************/
2924 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2927 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2932 /*******************************************************************
2933 reads or writes a structure.
2934 ********************************************************************/
2936 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2937 prs_struct *ps, int depth)
2942 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2948 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2954 /*******************************************************************
2955 inits a SAMR_R_QUERY_USERGROUPS structure.
2956 ********************************************************************/
2958 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2959 uint32 num_gids, DOM_GID * gid,
2962 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2964 if (NT_STATUS_IS_OK(status)) {
2966 r_u->num_entries = num_gids;
2967 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2968 r_u->num_entries2 = num_gids;
2973 r_u->num_entries = 0;
2978 r_u->status = status;
2981 /*******************************************************************
2982 reads or writes a structure.
2983 ********************************************************************/
2985 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
2986 prs_struct *ps, int depth)
2992 prs_debug(ps, depth, desc, "samr_io_gids");
2998 if(!prs_uint32("num_gids", ps, depth, num_gids))
3001 if ((*num_gids) != 0) {
3002 if (UNMARSHALLING(ps)) {
3003 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3006 if ((*gid) == NULL) {
3010 for (i = 0; i < (*num_gids); i++) {
3011 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3019 /*******************************************************************
3020 reads or writes a structure.
3021 ********************************************************************/
3023 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3024 prs_struct *ps, int depth)
3029 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3035 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3038 if (r_u->ptr_0 != 0) {
3039 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3041 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3044 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3045 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3052 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3058 /*******************************************************************
3059 inits a SAMR_Q_ENUM_DOMAINS structure.
3060 ********************************************************************/
3062 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3064 uint32 start_idx, uint32 size)
3066 DEBUG(5, ("init_samr_q_enum_domains\n"));
3070 q_e->start_idx = start_idx;
3071 q_e->max_size = size;
3074 /*******************************************************************
3075 reads or writes a structure.
3076 ********************************************************************/
3078 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3079 prs_struct *ps, int depth)
3084 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3090 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3093 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3095 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3101 /*******************************************************************
3102 inits a SAMR_R_ENUM_DOMAINS structure.
3103 ********************************************************************/
3105 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3106 uint32 next_idx, uint32 num_sam_entries)
3108 DEBUG(5, ("init_samr_r_enum_domains\n"));
3110 r_u->next_idx = next_idx;
3112 if (num_sam_entries != 0) {
3113 r_u->ptr_entries1 = 1;
3114 r_u->ptr_entries2 = 1;
3115 r_u->num_entries2 = num_sam_entries;
3116 r_u->num_entries3 = num_sam_entries;
3118 r_u->num_entries4 = num_sam_entries;
3120 r_u->ptr_entries1 = 0;
3121 r_u->num_entries2 = num_sam_entries;
3122 r_u->ptr_entries2 = 1;
3126 /*******************************************************************
3127 reads or writes a structure.
3128 ********************************************************************/
3130 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3131 prs_struct *ps, int depth)
3138 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3144 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3146 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3149 if (r_u->ptr_entries1 != 0) {
3150 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3152 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3154 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3157 if (UNMARSHALLING(ps)) {
3158 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3159 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3162 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3163 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3164 r_u->num_entries4 = 0;
3165 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3169 for (i = 0; i < r_u->num_entries2; i++) {
3171 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3172 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3176 for (i = 0; i < r_u->num_entries2; i++) {
3178 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3179 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3180 r_u->sam[i].hdr_name.buffer, ps,
3189 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3191 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3197 /*******************************************************************
3198 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3199 ********************************************************************/
3201 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3203 uint32 start_idx, uint32 size)
3205 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3209 q_e->start_idx = start_idx;
3210 q_e->max_size = size;
3213 /*******************************************************************
3214 reads or writes a structure.
3215 ********************************************************************/
3217 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3218 prs_struct *ps, int depth)
3223 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3229 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3232 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3234 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3240 /*******************************************************************
3241 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3242 ********************************************************************/
3244 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3245 uint32 next_idx, uint32 num_sam_entries)
3247 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3249 r_u->next_idx = next_idx;
3251 if (num_sam_entries != 0) {
3252 r_u->ptr_entries1 = 1;
3253 r_u->ptr_entries2 = 1;
3254 r_u->num_entries2 = num_sam_entries;
3255 r_u->num_entries3 = num_sam_entries;
3257 r_u->num_entries4 = num_sam_entries;
3259 r_u->ptr_entries1 = 0;
3260 r_u->num_entries2 = num_sam_entries;
3261 r_u->ptr_entries2 = 1;
3265 /*******************************************************************
3266 reads or writes a structure.
3267 ********************************************************************/
3269 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3270 prs_struct *ps, int depth)
3277 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3283 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3285 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3288 if (r_u->ptr_entries1 != 0) {
3289 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3291 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3293 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3296 if (UNMARSHALLING(ps)) {
3297 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3298 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3301 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3303 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3304 r_u->num_entries4 = 0;
3305 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3309 for (i = 0; i < r_u->num_entries2; i++) {
3310 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3314 for (i = 0; i < r_u->num_entries2; i++) {
3315 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3316 r_u->sam[i].hdr_name.buffer, ps, depth))
3323 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3325 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3331 /*******************************************************************
3332 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3333 ********************************************************************/
3335 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3336 POLICY_HND *pol, uint32 start_idx,
3339 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3343 q_e->start_idx = start_idx;
3344 q_e->max_size = size;
3348 /*******************************************************************
3349 reads or writes a structure.
3350 ********************************************************************/
3352 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3353 prs_struct *ps, int depth)
3358 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3364 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3367 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3369 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3375 /*******************************************************************
3376 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3377 ********************************************************************/
3379 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3381 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3383 r_u->next_idx = next_idx;
3385 if (num_sam_entries != 0) {
3386 r_u->ptr_entries1 = 1;
3387 r_u->ptr_entries2 = 1;
3388 r_u->num_entries2 = num_sam_entries;
3389 r_u->num_entries3 = num_sam_entries;
3391 r_u->num_entries4 = num_sam_entries;
3393 r_u->ptr_entries1 = 0;
3394 r_u->num_entries2 = num_sam_entries;
3395 r_u->ptr_entries2 = 1;
3399 /*******************************************************************
3400 reads or writes a structure.
3401 ********************************************************************/
3403 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3404 prs_struct *ps, int depth)
3411 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3417 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3419 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3422 if (r_u->ptr_entries1 != 0) {
3423 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3425 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3427 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3430 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3431 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3432 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3435 if (r_u->num_entries2 != 0 &&
3436 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3437 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3438 r_u->num_entries4 = 0;
3439 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3443 for (i = 0; i < r_u->num_entries2; i++) {
3444 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3448 for (i = 0; i < r_u->num_entries2; i++) {
3449 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3450 r_u->sam[i].hdr_name.buffer, ps,
3458 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3460 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3466 /*******************************************************************
3467 inits a ALIAS_INFO1 structure.
3468 ********************************************************************/
3470 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3472 DEBUG(5, ("init_samr_alias_info1\n"));
3474 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3475 al1->num_member = num_member;
3476 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3479 /*******************************************************************
3480 reads or writes a structure.
3481 ********************************************************************/
3483 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3484 prs_struct *ps, int depth)
3489 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3495 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3497 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3499 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3502 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3504 if ( !prs_align(ps) )
3506 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3508 if ( !prs_align(ps) )
3514 /*******************************************************************
3515 inits a ALIAS_INFO3 structure.
3516 ********************************************************************/
3518 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3520 DEBUG(5, ("init_samr_alias_info3\n"));
3522 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3525 /*******************************************************************
3526 reads or writes a structure.
3527 ********************************************************************/
3529 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3530 prs_struct *ps, int depth)
3535 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3541 if (!prs_unistr4("description", ps, depth, &al3->description))
3547 /*******************************************************************
3548 reads or writes a structure.
3549 ********************************************************************/
3551 BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3556 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3559 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3564 switch (ctr->level) {
3566 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3570 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3574 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3581 /*******************************************************************
3582 inits a SAMR_Q_QUERY_ALIASINFO structure.
3583 ********************************************************************/
3585 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3586 POLICY_HND *pol, uint32 switch_level)
3588 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3591 q_e->level = switch_level;
3594 /*******************************************************************
3595 reads or writes a structure.
3596 ********************************************************************/
3598 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3599 prs_struct *ps, int depth)
3604 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3610 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3613 if ( !prs_uint16("level", ps, depth, &in->level) )
3619 /*******************************************************************
3620 inits a SAMR_R_QUERY_ALIASINFO structure.
3621 ********************************************************************/
3623 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3624 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3626 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3629 out->status = status;
3632 /*******************************************************************
3633 reads or writes a structure.
3634 ********************************************************************/
3636 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3637 prs_struct *ps, int depth)
3642 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3648 if ( !prs_pointer("alias", ps, depth, (void**)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3653 if(!prs_ntstatus("status", ps, depth, &out->status))
3659 /*******************************************************************
3660 inits a SAMR_Q_SET_ALIASINFO structure.
3661 ********************************************************************/
3663 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3664 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3666 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3668 q_u->alias_pol = *hnd;
3672 /*******************************************************************
3673 reads or writes a structure.
3674 ********************************************************************/
3676 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3677 prs_struct *ps, int depth)
3682 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3688 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3690 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3696 /*******************************************************************
3697 reads or writes a structure.
3698 ********************************************************************/
3700 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3701 prs_struct *ps, int depth)
3706 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3711 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3717 /*******************************************************************
3718 inits a SAMR_Q_QUERY_USERALIASES structure.
3719 ********************************************************************/
3721 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3724 uint32 *ptr_sid, DOM_SID2 * sid)
3726 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3730 q_u->num_sids1 = num_sids;
3732 q_u->num_sids2 = num_sids;
3734 q_u->ptr_sid = ptr_sid;
3738 /*******************************************************************
3739 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3740 ********************************************************************/
3742 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3743 prs_struct *ps, int depth)
3751 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3757 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3760 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3762 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3768 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3771 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3772 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3773 if (q_u->ptr_sid == NULL)
3776 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3777 if (q_u->sid == NULL)
3781 for (i = 0; i < q_u->num_sids2; i++) {
3782 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3783 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3787 for (i = 0; i < q_u->num_sids2; i++) {
3788 if (q_u->ptr_sid[i] != 0) {
3789 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3790 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3798 /*******************************************************************
3799 inits a SAMR_R_QUERY_USERALIASES structure.
3800 ********************************************************************/
3802 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3803 uint32 num_rids, uint32 *rid,
3806 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3808 if (NT_STATUS_IS_OK(status)) {
3809 r_u->num_entries = num_rids;
3811 r_u->num_entries2 = num_rids;
3815 r_u->num_entries = 0;
3817 r_u->num_entries2 = 0;
3820 r_u->status = status;
3823 /*******************************************************************
3824 reads or writes a structure.
3825 ********************************************************************/
3827 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3828 prs_struct *ps, int depth)
3835 prs_debug(ps, depth, desc, "samr_io_rids");
3841 if(!prs_uint32("num_rids", ps, depth, num_rids))
3844 if ((*num_rids) != 0) {
3845 if (UNMARSHALLING(ps)) {
3847 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3852 for (i = 0; i < (*num_rids); i++) {
3853 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3854 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3862 /*******************************************************************
3863 reads or writes a structure.
3864 ********************************************************************/
3866 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3867 prs_struct *ps, int depth)
3872 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3878 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3880 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3883 if (r_u->ptr != 0) {
3884 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3890 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3896 /*******************************************************************
3897 inits a SAMR_Q_OPEN_ALIAS structure.
3898 ********************************************************************/
3900 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3901 uint32 access_mask, uint32 rid)
3903 DEBUG(5, ("init_samr_q_open_alias\n"));
3905 q_u->dom_pol = *pol;
3906 q_u->access_mask = access_mask;
3907 q_u->rid_alias = rid;
3910 /*******************************************************************
3911 reads or writes a structure.
3912 ********************************************************************/
3914 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3915 prs_struct *ps, int depth)
3920 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3926 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3929 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3931 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3937 /*******************************************************************
3938 reads or writes a structure.
3939 ********************************************************************/
3941 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
3942 prs_struct *ps, int depth)
3947 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3953 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3956 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3962 /*******************************************************************
3963 inits a SAMR_Q_LOOKUP_RIDS structure.
3964 ********************************************************************/
3966 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3967 POLICY_HND *pol, uint32 flags,
3968 uint32 num_rids, uint32 *rid)
3970 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3974 q_u->num_rids1 = num_rids;
3977 q_u->num_rids2 = num_rids;
3978 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
3979 if (q_u->rid == NULL) {