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, const char *server)
534 init_unistr2(&u_6->uni_server, server, UNI_FLAGS_NONE);
535 init_uni_hdr(&u_6->hdr_server, &u_6->uni_server);
538 /*******************************************************************
539 reads or writes a structure.
540 ********************************************************************/
542 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
543 prs_struct *ps, int depth)
548 prs_debug(ps, depth, desc, "sam_io_unk_info6");
551 if(!smb_io_unihdr("hdr_server", &u_6->hdr_server, ps, depth))
554 if(!smb_io_unistr2("uni_server", &u_6->uni_server, u_6->hdr_server.buffer, ps, depth))
560 /*******************************************************************
562 ********************************************************************/
564 void init_unk_info4(SAM_UNK_INFO_4 * u_4,const char *comment)
566 init_unistr2(&u_4->uni_comment, comment, UNI_FLAGS_NONE);
567 init_uni_hdr(&u_4->hdr_comment, &u_4->uni_comment);
570 /*******************************************************************
571 reads or writes a structure.
572 ********************************************************************/
574 static BOOL sam_io_unk_info4(const char *desc, SAM_UNK_INFO_4 * u_4,
575 prs_struct *ps, int depth)
580 prs_debug(ps, depth, desc, "sam_io_unk_info4");
583 if(!smb_io_unihdr("hdr_comment", &u_4->hdr_comment, ps, depth))
586 if(!smb_io_unistr2("uni_comment", &u_4->uni_comment, u_4->hdr_comment.buffer, ps, depth))
592 /*******************************************************************
594 ********************************************************************/
596 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
598 u_7->server_role = server_role;
601 /*******************************************************************
602 reads or writes a structure.
603 ********************************************************************/
605 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
606 prs_struct *ps, int depth)
611 prs_debug(ps, depth, desc, "sam_io_unk_info7");
614 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
620 /*******************************************************************
622 ********************************************************************/
624 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
626 unix_to_nt_time(&u_8->domain_create_time, 0);
627 u_8->seq_num.low = seq_num;
628 u_8->seq_num.high = 0x0000;
631 /*******************************************************************
632 reads or writes a structure.
633 ********************************************************************/
635 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
636 prs_struct *ps, int depth)
641 prs_debug(ps, depth, desc, "sam_io_unk_info8");
644 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
647 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
653 /*******************************************************************
655 ********************************************************************/
657 void init_unk_info9(SAM_UNK_INFO_9 * u_9, uint32 unknown)
659 u_9->unknown = unknown;
662 /*******************************************************************
663 reads or writes a structure.
664 ********************************************************************/
666 static BOOL sam_io_unk_info9(const char *desc, SAM_UNK_INFO_9 * u_9,
667 prs_struct *ps, int depth)
672 prs_debug(ps, depth, desc, "sam_io_unk_info9");
675 if (!prs_uint32("unknown", ps, depth, &u_9->unknown))
681 /*******************************************************************
683 ********************************************************************/
685 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
687 u_12->duration.low = nt_lock_duration.low;
688 u_12->duration.high = nt_lock_duration.high;
689 u_12->reset_count.low = nt_reset_time.low;
690 u_12->reset_count.high = nt_reset_time.high;
692 u_12->bad_attempt_lockout = lockout;
695 /*******************************************************************
696 reads or writes a structure.
697 ********************************************************************/
699 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
700 prs_struct *ps, int depth)
705 prs_debug(ps, depth, desc, "sam_io_unk_info12");
708 if(!smb_io_time("duration", &u_12->duration, ps, depth))
710 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
712 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
718 /*******************************************************************
720 ********************************************************************/
722 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *domain)
724 init_unistr2(&u_5->uni_domain, domain, UNI_FLAGS_NONE);
725 init_uni_hdr(&u_5->hdr_domain, &u_5->uni_domain);
728 /*******************************************************************
729 reads or writes a structure.
730 ********************************************************************/
732 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
733 prs_struct *ps, int depth)
738 prs_debug(ps, depth, desc, "sam_io_unk_info5");
741 if(!smb_io_unihdr("hdr_domain", &u_5->hdr_domain, ps, depth))
744 if(!smb_io_unistr2("uni_domain", &u_5->uni_domain, u_5->hdr_domain.buffer, ps, depth))
750 /*******************************************************************
752 ********************************************************************/
754 void init_unk_info13(SAM_UNK_INFO_13 * u_13, uint32 seq_num)
756 unix_to_nt_time(&u_13->domain_create_time, 0);
757 u_13->seq_num.low = seq_num;
758 u_13->seq_num.high = 0x0000;
763 /*******************************************************************
764 reads or writes a structure.
765 ********************************************************************/
767 static BOOL sam_io_unk_info13(const char *desc, SAM_UNK_INFO_13 * u_13,
768 prs_struct *ps, int depth)
773 prs_debug(ps, depth, desc, "sam_io_unk_info13");
776 if (!prs_uint64("seq_num", ps, depth, &u_13->seq_num))
779 if(!smb_io_time("domain_create_time", &u_13->domain_create_time, ps, depth))
782 if (!prs_uint32("unknown1", ps, depth, &u_13->unknown1))
784 if (!prs_uint32("unknown2", ps, depth, &u_13->unknown2))
792 /*******************************************************************
794 ********************************************************************/
796 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
797 const char *comment, const char *domain, const char *server,
798 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
800 u_2->logout.low = nt_logout.low;
801 u_2->logout.high = nt_logout.high;
803 u_2->seq_num.low = seq_num;
804 u_2->seq_num.high = 0x00000000;
807 u_2->unknown_4 = 0x00000001;
808 u_2->server_role = server_role;
809 u_2->unknown_6 = 0x00000001;
810 u_2->num_domain_usrs = num_users;
811 u_2->num_domain_grps = num_groups;
812 u_2->num_local_grps = num_alias;
814 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
815 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
816 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
817 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
818 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
819 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
822 /*******************************************************************
823 reads or writes a structure.
824 ********************************************************************/
826 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
827 prs_struct *ps, int depth)
832 prs_debug(ps, depth, desc, "sam_io_unk_info2");
835 if(!smb_io_time("logout", &u_2->logout, ps, depth))
837 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
839 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
841 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
844 /* put all the data in here, at the moment, including what the above
845 pointer is referring to
848 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
851 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
853 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
855 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
857 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
859 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
861 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
864 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
866 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
868 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
874 /*******************************************************************
876 ********************************************************************/
878 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
879 uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
881 u_1->min_length_password = min_pass_len;
882 u_1->password_history = pass_hist;
883 u_1->password_properties = password_properties;
885 /* password never expire */
886 u_1->expire.high = nt_expire.high;
887 u_1->expire.low = nt_expire.low;
889 /* can change the password now */
890 u_1->min_passwordage.high = nt_min_age.high;
891 u_1->min_passwordage.low = nt_min_age.low;
895 /*******************************************************************
896 reads or writes a structure.
897 ********************************************************************/
899 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
900 prs_struct *ps, int depth)
905 prs_debug(ps, depth, desc, "sam_io_unk_info1");
908 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
910 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
912 if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
914 if(!smb_io_time("expire", &u_1->expire, ps, depth))
916 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
922 /*******************************************************************
923 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
924 ********************************************************************/
926 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
927 uint16 switch_value, SAM_UNK_CTR * ctr,
930 DEBUG(5, ("init_samr_r_query_dom_info\n"));
933 r_u->switch_value = 0;
934 r_u->status = status; /* return status */
936 if (NT_STATUS_IS_OK(status)) {
937 r_u->switch_value = switch_value;
943 /*******************************************************************
944 reads or writes a structure.
945 ********************************************************************/
947 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
948 prs_struct *ps, int depth)
953 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
959 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
962 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
963 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
968 switch (r_u->switch_value) {
970 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
974 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
978 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
982 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
986 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
990 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
994 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
998 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
1002 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
1006 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
1010 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
1014 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
1015 r_u->switch_value));
1016 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
1024 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1030 /*******************************************************************
1031 reads or writes a structure.
1032 ********************************************************************/
1034 void init_samr_q_set_sec_obj(SAMR_Q_SET_SEC_OBJ * q_u,
1035 POLICY_HND *pol, uint32 sec_info, SEC_DESC_BUF *buf)
1037 DEBUG(5, ("samr_init_samr_q_set_sec_obj\n"));
1040 q_u->sec_info = sec_info;
1045 /*******************************************************************
1046 reads or writes a SAMR_R_SET_SEC_OBJ structure.
1047 ********************************************************************/
1049 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
1050 prs_struct *ps, int depth)
1055 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
1061 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1067 /*******************************************************************
1068 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
1069 ********************************************************************/
1071 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
1072 prs_struct *ps, int depth)
1077 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
1083 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
1085 if (r_u->ptr != 0) {
1086 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
1090 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1096 /*******************************************************************
1097 reads or writes a SAM_STR1 structure.
1098 ********************************************************************/
1100 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
1101 uint32 name_buf, uint32 desc_buf,
1102 prs_struct *ps, int depth)
1107 prs_debug(ps, depth, desc, "sam_io_sam_str1");
1112 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
1115 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
1118 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1124 /*******************************************************************
1125 inits a SAM_ENTRY1 structure.
1126 ********************************************************************/
1128 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1129 UNISTR2 *sam_name, UNISTR2 *sam_full,
1130 UNISTR2 *sam_desc, uint32 rid_user,
1133 DEBUG(5, ("init_sam_entry1\n"));
1137 sam->user_idx = user_idx;
1138 sam->rid_user = rid_user;
1139 sam->acb_info = acb_info;
1141 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1142 init_uni_hdr(&sam->hdr_user_name, sam_full);
1143 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1146 /*******************************************************************
1147 reads or writes a SAM_ENTRY1 structure.
1148 ********************************************************************/
1150 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1151 prs_struct *ps, int depth)
1156 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1162 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1165 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1167 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1170 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1172 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1174 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1180 /*******************************************************************
1181 reads or writes a SAM_STR2 structure.
1182 ********************************************************************/
1184 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1185 uint32 desc_buf, prs_struct *ps, int depth)
1190 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1196 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1198 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1204 /*******************************************************************
1205 inits a SAM_ENTRY2 structure.
1206 ********************************************************************/
1207 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1208 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1209 uint32 rid_user, uint32 acb_info)
1211 DEBUG(5, ("init_sam_entry2\n"));
1213 sam->user_idx = user_idx;
1214 sam->rid_user = rid_user;
1215 sam->acb_info = acb_info;
1217 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1218 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1221 /*******************************************************************
1222 reads or writes a SAM_ENTRY2 structure.
1223 ********************************************************************/
1225 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1226 prs_struct *ps, int depth)
1231 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1237 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1240 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1242 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1245 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1247 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1253 /*******************************************************************
1254 reads or writes a SAM_STR3 structure.
1255 ********************************************************************/
1257 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1258 uint32 desc_buf, prs_struct *ps, int depth)
1263 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1269 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1271 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1277 /*******************************************************************
1278 inits a SAM_ENTRY3 structure.
1279 ********************************************************************/
1281 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1282 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1285 DEBUG(5, ("init_sam_entry3\n"));
1287 sam->grp_idx = grp_idx;
1288 sam->rid_grp = rid_grp;
1289 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1291 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1292 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1295 /*******************************************************************
1296 reads or writes a SAM_ENTRY3 structure.
1297 ********************************************************************/
1299 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1300 prs_struct *ps, int depth)
1305 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1311 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1314 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1316 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1319 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1321 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1327 /*******************************************************************
1328 inits a SAM_ENTRY4 structure.
1329 ********************************************************************/
1331 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1332 uint32 len_acct_name)
1334 DEBUG(5, ("init_sam_entry4\n"));
1336 sam->user_idx = user_idx;
1337 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1340 /*******************************************************************
1341 reads or writes a SAM_ENTRY4 structure.
1342 ********************************************************************/
1344 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1345 prs_struct *ps, int depth)
1350 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1356 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1358 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1364 /*******************************************************************
1365 inits a SAM_ENTRY5 structure.
1366 ********************************************************************/
1368 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1369 uint32 len_grp_name)
1371 DEBUG(5, ("init_sam_entry5\n"));
1373 sam->grp_idx = grp_idx;
1374 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1378 /*******************************************************************
1379 reads or writes a SAM_ENTRY5 structure.
1380 ********************************************************************/
1382 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1383 prs_struct *ps, int depth)
1388 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1394 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1396 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1402 /*******************************************************************
1403 inits a SAM_ENTRY structure.
1404 ********************************************************************/
1406 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1408 DEBUG(10, ("init_sam_entry: %d\n", rid));
1411 init_uni_hdr(&sam->hdr_name, uni2);
1414 /*******************************************************************
1415 reads or writes a SAM_ENTRY structure.
1416 ********************************************************************/
1418 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1419 prs_struct *ps, int depth)
1424 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1429 if(!prs_uint32("rid", ps, depth, &sam->rid))
1431 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1437 /*******************************************************************
1438 inits a SAMR_Q_ENUM_DOM_USERS structure.
1439 ********************************************************************/
1441 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1443 uint32 acb_mask, uint32 size)
1445 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1449 q_e->start_idx = start_idx; /* zero indicates lots */
1450 q_e->acb_mask = acb_mask;
1451 q_e->max_size = size;
1454 /*******************************************************************
1455 reads or writes a structure.
1456 ********************************************************************/
1458 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1459 prs_struct *ps, int depth)
1464 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1470 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1473 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1475 if(!prs_uint32("acb_mask ", ps, depth, &q_e->acb_mask))
1478 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1485 /*******************************************************************
1486 inits a SAMR_R_ENUM_DOM_USERS structure.
1487 ********************************************************************/
1489 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1490 uint32 next_idx, uint32 num_sam_entries)
1492 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1494 r_u->next_idx = next_idx;
1496 if (num_sam_entries != 0) {
1497 r_u->ptr_entries1 = 1;
1498 r_u->ptr_entries2 = 1;
1499 r_u->num_entries2 = num_sam_entries;
1500 r_u->num_entries3 = num_sam_entries;
1502 r_u->num_entries4 = num_sam_entries;
1504 r_u->ptr_entries1 = 0;
1505 r_u->num_entries2 = num_sam_entries;
1506 r_u->ptr_entries2 = 1;
1510 /*******************************************************************
1511 reads or writes a structure.
1512 ********************************************************************/
1514 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1515 prs_struct *ps, int depth)
1522 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1528 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1530 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1533 if (r_u->ptr_entries1 != 0) {
1534 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1536 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1538 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1541 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1542 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1543 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1546 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1547 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1548 r_u->num_entries4 = 0;
1549 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1553 for (i = 0; i < r_u->num_entries2; i++) {
1554 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1558 for (i = 0; i < r_u->num_entries2; i++) {
1559 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1568 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1570 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1576 /*******************************************************************
1577 inits a SAMR_Q_QUERY_DISPINFO structure.
1578 ********************************************************************/
1580 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1581 uint16 switch_level, uint32 start_idx,
1582 uint32 max_entries, uint32 max_size)
1584 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1586 q_e->domain_pol = *pol;
1588 q_e->switch_level = switch_level;
1590 q_e->start_idx = start_idx;
1591 q_e->max_entries = max_entries;
1592 q_e->max_size = max_size;
1595 /*******************************************************************
1596 reads or writes a structure.
1597 ********************************************************************/
1599 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1600 prs_struct *ps, int depth)
1605 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1611 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1614 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1619 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1621 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1623 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1629 /*******************************************************************
1630 inits a SAM_DISPINFO_1 structure.
1631 ********************************************************************/
1633 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1634 uint32 num_entries, uint32 start_idx,
1635 struct samr_displayentry *entries)
1639 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1642 return NT_STATUS_OK;
1644 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1646 return NT_STATUS_NO_MEMORY;
1648 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1649 if ((*sam)->sam == NULL)
1650 return NT_STATUS_NO_MEMORY;
1652 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1653 if ((*sam)->str == NULL)
1654 return NT_STATUS_NO_MEMORY;
1656 for (i = 0; i < num_entries ; i++) {
1657 init_unistr2(&(*sam)->str[i].uni_acct_name,
1658 entries[i].account_name, UNI_FLAGS_NONE);
1659 init_unistr2(&(*sam)->str[i].uni_full_name,
1660 entries[i].fullname, UNI_FLAGS_NONE);
1661 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1662 entries[i].description, UNI_FLAGS_NONE);
1664 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1665 &(*sam)->str[i].uni_acct_name,
1666 &(*sam)->str[i].uni_full_name,
1667 &(*sam)->str[i].uni_acct_desc,
1668 entries[i].rid, entries[i].acct_flags);
1671 return NT_STATUS_OK;
1674 /*******************************************************************
1675 reads or writes a structure.
1676 ********************************************************************/
1678 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1680 prs_struct *ps, int depth)
1684 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1690 if (UNMARSHALLING(ps) && num_entries > 0) {
1692 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1693 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1697 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1698 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1703 for (i = 0; i < num_entries; i++) {
1704 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1708 for (i = 0; i < num_entries; i++) {
1709 if(!sam_io_sam_str1("", &sam->str[i],
1710 sam->sam[i].hdr_acct_name.buffer,
1711 sam->sam[i].hdr_user_name.buffer,
1712 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1719 /*******************************************************************
1720 inits a SAM_DISPINFO_2 structure.
1721 ********************************************************************/
1723 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1724 uint32 num_entries, uint32 start_idx,
1725 struct samr_displayentry *entries)
1729 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1732 return NT_STATUS_OK;
1734 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1736 return NT_STATUS_NO_MEMORY;
1738 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1739 if ((*sam)->sam == NULL)
1740 return NT_STATUS_NO_MEMORY;
1742 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1743 if ((*sam)->str == NULL)
1744 return NT_STATUS_NO_MEMORY;
1746 for (i = 0; i < num_entries; i++) {
1747 init_unistr2(&(*sam)->str[i].uni_srv_name,
1748 entries[i].account_name, UNI_FLAGS_NONE);
1749 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1750 entries[i].description, UNI_FLAGS_NONE);
1752 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1753 &(*sam)->str[i].uni_srv_name,
1754 &(*sam)->str[i].uni_srv_desc,
1755 entries[i].rid, entries[i].acct_flags);
1758 return NT_STATUS_OK;
1761 /*******************************************************************
1762 reads or writes a structure.
1763 ********************************************************************/
1765 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1767 prs_struct *ps, int depth)
1774 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1780 if (UNMARSHALLING(ps) && num_entries > 0) {
1782 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1783 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1787 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1788 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1793 for (i = 0; i < num_entries; i++) {
1794 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1798 for (i = 0; i < num_entries; i++) {
1799 if(!sam_io_sam_str2("", &sam->str[i],
1800 sam->sam[i].hdr_srv_name.buffer,
1801 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1808 /*******************************************************************
1809 inits a SAM_DISPINFO_3 structure.
1810 ********************************************************************/
1812 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1813 uint32 num_entries, uint32 start_idx,
1814 struct samr_displayentry *entries)
1818 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1821 return NT_STATUS_OK;
1823 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1825 return NT_STATUS_NO_MEMORY;
1827 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1828 return NT_STATUS_NO_MEMORY;
1830 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1831 return NT_STATUS_NO_MEMORY;
1833 for (i = 0; i < num_entries; i++) {
1834 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1836 init_unistr2(&(*sam)->str[i].uni_grp_name,
1837 entries[i].account_name, UNI_FLAGS_NONE);
1838 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1839 entries[i].description, UNI_FLAGS_NONE);
1841 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1842 &(*sam)->str[i].uni_grp_name,
1843 &(*sam)->str[i].uni_grp_desc,
1847 return NT_STATUS_OK;
1850 /*******************************************************************
1851 reads or writes a structure.
1852 ********************************************************************/
1854 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1856 prs_struct *ps, int depth)
1863 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1869 if (UNMARSHALLING(ps) && num_entries > 0) {
1871 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1872 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1876 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1877 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1882 for (i = 0; i < num_entries; i++) {
1883 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1887 for (i = 0; i < num_entries; i++) {
1888 if(!sam_io_sam_str3("", &sam->str[i],
1889 sam->sam[i].hdr_grp_name.buffer,
1890 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1897 /*******************************************************************
1898 inits a SAM_DISPINFO_4 structure.
1899 ********************************************************************/
1901 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1902 uint32 num_entries, uint32 start_idx,
1903 struct samr_displayentry *entries)
1907 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1910 return NT_STATUS_OK;
1912 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1914 return NT_STATUS_NO_MEMORY;
1916 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1917 if ((*sam)->sam == NULL)
1918 return NT_STATUS_NO_MEMORY;
1920 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1921 if ((*sam)->str == NULL)
1922 return NT_STATUS_NO_MEMORY;
1924 for (i = 0; i < num_entries; i++) {
1925 size_t len_sam_name = strlen(entries[i].account_name);
1927 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1929 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1932 init_string2(&(*sam)->str[i].acct_name,
1933 entries[i].account_name, len_sam_name+1,
1937 return NT_STATUS_OK;
1940 /*******************************************************************
1941 reads or writes a structure.
1942 ********************************************************************/
1944 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1946 prs_struct *ps, int depth)
1953 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1959 if (UNMARSHALLING(ps) && num_entries > 0) {
1961 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1962 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1966 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1967 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1972 for (i = 0; i < num_entries; i++) {
1973 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1977 for (i = 0; i < num_entries; i++) {
1978 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1979 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1986 /*******************************************************************
1987 inits a SAM_DISPINFO_5 structure.
1988 ********************************************************************/
1990 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1991 uint32 num_entries, uint32 start_idx,
1992 struct samr_displayentry *entries)
1994 uint32 len_sam_name;
1997 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
2000 return NT_STATUS_OK;
2002 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
2004 return NT_STATUS_NO_MEMORY;
2006 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
2007 return NT_STATUS_NO_MEMORY;
2009 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
2010 return NT_STATUS_NO_MEMORY;
2012 for (i = 0; i < num_entries; i++) {
2013 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
2015 len_sam_name = strlen(entries[i].account_name);
2017 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
2018 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
2019 len_sam_name+1, len_sam_name);
2022 return NT_STATUS_OK;
2025 /*******************************************************************
2026 reads or writes a structure.
2027 ********************************************************************/
2029 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
2031 prs_struct *ps, int depth)
2038 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
2044 if (UNMARSHALLING(ps) && num_entries > 0) {
2046 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
2047 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
2051 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
2052 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2057 for (i = 0; i < num_entries; i++) {
2058 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2062 for (i = 0; i < num_entries; i++) {
2063 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
2064 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2071 /*******************************************************************
2072 inits a SAMR_R_QUERY_DISPINFO structure.
2073 ********************************************************************/
2075 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2076 uint32 num_entries, uint32 total_size, uint32 data_size,
2077 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2080 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2082 r_u->total_size = total_size;
2084 r_u->data_size = data_size;
2086 r_u->switch_level = switch_level;
2087 r_u->num_entries = num_entries;
2090 r_u->ptr_entries = 0;
2092 r_u->ptr_entries = 1;
2094 r_u->num_entries2 = num_entries;
2097 r_u->status = status;
2100 /*******************************************************************
2101 reads or writes a structure.
2102 ********************************************************************/
2104 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2105 prs_struct *ps, int depth)
2110 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2116 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2118 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2120 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2125 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2127 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2130 if (r_u->ptr_entries==0) {
2133 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2139 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2142 switch (r_u->switch_level) {
2144 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2145 r_u->num_entries, ps, depth))
2149 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2150 r_u->num_entries, ps, depth))
2154 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2155 r_u->num_entries, ps, depth))
2159 if(!sam_io_sam_dispinfo_4("user list",
2160 r_u->ctr->sam.info4,
2161 r_u->num_entries, ps, depth))
2165 if(!sam_io_sam_dispinfo_5("group list",
2166 r_u->ctr->sam.info5,
2167 r_u->num_entries, ps, depth))
2171 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2177 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2183 /*******************************************************************
2184 inits a SAMR_Q_OPEN_GROUP structure.
2185 ********************************************************************/
2187 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2189 uint32 access_mask, uint32 rid)
2191 DEBUG(5, ("init_samr_q_open_group\n"));
2193 q_c->domain_pol = *hnd;
2194 q_c->access_mask = access_mask;
2195 q_c->rid_group = rid;
2198 /*******************************************************************
2199 reads or writes a structure.
2200 ********************************************************************/
2202 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2203 prs_struct *ps, int depth)
2208 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2214 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2217 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2219 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2225 /*******************************************************************
2226 reads or writes a structure.
2227 ********************************************************************/
2229 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2230 prs_struct *ps, int depth)
2235 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2241 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2244 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2250 /*******************************************************************
2251 inits a GROUP_INFO1 structure.
2252 ********************************************************************/
2254 void init_samr_group_info1(GROUP_INFO1 * gr1,
2255 char *acct_name, char *acct_desc,
2258 DEBUG(5, ("init_samr_group_info1\n"));
2260 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2261 gr1->num_members = num_members;
2263 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2264 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2265 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2266 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2269 /*******************************************************************
2270 reads or writes a structure.
2271 ********************************************************************/
2273 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2274 prs_struct *ps, int depth)
2281 prs_debug(ps, depth, desc, "samr_io_group_info1");
2284 if(!prs_uint16("level", ps, depth, &dummy))
2290 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2293 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2295 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2298 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2301 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2302 gr1->hdr_acct_name.buffer, ps, depth))
2305 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2306 gr1->hdr_acct_desc.buffer, ps, depth))
2312 /*******************************************************************
2313 inits a GROUP_INFO2 structure.
2314 ********************************************************************/
2316 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2318 DEBUG(5, ("init_samr_group_info2\n"));
2321 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2322 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2325 /*******************************************************************
2326 reads or writes a structure.
2327 ********************************************************************/
2329 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2334 prs_debug(ps, depth, desc, "samr_io_group_info2");
2337 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2340 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2342 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2343 gr2->hdr_acct_name.buffer, ps, depth))
2349 /*******************************************************************
2350 inits a GROUP_INFO3 structure.
2351 ********************************************************************/
2353 void init_samr_group_info3(GROUP_INFO3 *gr3)
2355 DEBUG(5, ("init_samr_group_info3\n"));
2357 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2360 /*******************************************************************
2361 reads or writes a structure.
2362 ********************************************************************/
2364 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2369 prs_debug(ps, depth, desc, "samr_io_group_info3");
2375 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2381 /*******************************************************************
2382 inits a GROUP_INFO4 structure.
2383 ********************************************************************/
2385 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2387 DEBUG(5, ("init_samr_group_info4\n"));
2390 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2391 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2394 /*******************************************************************
2395 reads or writes a structure.
2396 ********************************************************************/
2398 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2399 prs_struct *ps, int depth)
2404 prs_debug(ps, depth, desc, "samr_io_group_info4");
2407 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2409 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2411 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2412 gr4->hdr_acct_desc.buffer, ps, depth))
2418 /*******************************************************************
2419 inits a GROUP_INFO5 structure.
2420 ********************************************************************/
2422 void init_samr_group_info5(GROUP_INFO5 * gr5,
2423 char *acct_name, char *acct_desc,
2426 DEBUG(5, ("init_samr_group_info5\n"));
2428 gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2429 gr5->num_members = num_members;
2431 init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2432 init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
2433 init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2434 init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
2437 /*******************************************************************
2438 reads or writes a structure.
2439 ********************************************************************/
2441 BOOL samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
2442 prs_struct *ps, int depth)
2449 prs_debug(ps, depth, desc, "samr_io_group_info5");
2452 if(!prs_uint16("level", ps, depth, &dummy))
2458 if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
2461 if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
2463 if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
2466 if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
2469 if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
2470 gr5->hdr_acct_name.buffer, ps, depth))
2473 if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
2474 gr5->hdr_acct_desc.buffer, ps, depth))
2481 /*******************************************************************
2482 reads or writes a structure.
2483 ********************************************************************/
2485 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2486 prs_struct *ps, int depth)
2488 if (UNMARSHALLING(ps))
2489 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2494 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2497 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2500 switch ((*ctr)->switch_value1) {
2502 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2506 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2510 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2514 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2518 if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
2522 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2529 /*******************************************************************
2530 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2531 ********************************************************************/
2533 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2534 POLICY_HND *pol, const char *acct_desc,
2537 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2541 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2542 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2544 q_e->access_mask = access_mask;
2547 /*******************************************************************
2548 reads or writes a structure.
2549 ********************************************************************/
2551 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2552 prs_struct *ps, int depth)
2557 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2563 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2566 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2568 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2569 q_e->hdr_acct_desc.buffer, ps, depth))
2574 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2580 /*******************************************************************
2581 reads or writes a structure.
2582 ********************************************************************/
2584 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2585 prs_struct *ps, int depth)
2590 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2596 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2599 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2601 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2607 /*******************************************************************
2608 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2609 ********************************************************************/
2611 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2614 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2616 q_c->group_pol = *hnd;
2619 /*******************************************************************
2620 reads or writes a structure.
2621 ********************************************************************/
2623 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2624 prs_struct *ps, int depth)
2629 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2635 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2641 /*******************************************************************
2642 reads or writes a structure.
2643 ********************************************************************/
2645 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2646 prs_struct *ps, int depth)
2651 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2657 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2660 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2666 /*******************************************************************
2667 inits a SAMR_Q_DEL_GROUPMEM structure.
2668 ********************************************************************/
2670 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2671 POLICY_HND *pol, uint32 rid)
2673 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2679 /*******************************************************************
2680 reads or writes a structure.
2681 ********************************************************************/
2683 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2684 prs_struct *ps, int depth)
2689 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2695 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2698 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2704 /*******************************************************************
2705 inits a SAMR_R_DEL_GROUPMEM structure.
2706 ********************************************************************/
2708 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2711 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2713 r_u->status = status;
2716 /*******************************************************************
2717 reads or writes a structure.
2718 ********************************************************************/
2720 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2721 prs_struct *ps, int depth)
2726 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2732 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2738 /*******************************************************************
2739 inits a SAMR_Q_ADD_GROUPMEM structure.
2740 ********************************************************************/
2742 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2743 POLICY_HND *pol, uint32 rid)
2745 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2749 q_e->unknown = 0x0005;
2752 /*******************************************************************
2753 reads or writes a structure.
2754 ********************************************************************/
2756 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2757 prs_struct *ps, int depth)
2762 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2768 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2771 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2773 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2779 /*******************************************************************
2780 inits a SAMR_R_ADD_GROUPMEM structure.
2781 ********************************************************************/
2783 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2786 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2788 r_u->status = status;
2791 /*******************************************************************
2792 reads or writes a structure.
2793 ********************************************************************/
2795 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2796 prs_struct *ps, int depth)
2801 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2807 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2813 /*******************************************************************
2814 inits a SAMR_Q_SET_GROUPINFO structure.
2815 ********************************************************************/
2817 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2818 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2820 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2826 /*******************************************************************
2827 reads or writes a structure.
2828 ********************************************************************/
2830 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2831 prs_struct *ps, int depth)
2836 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2842 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2845 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2851 /*******************************************************************
2852 inits a SAMR_R_SET_GROUPINFO structure.
2853 ********************************************************************/
2855 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2857 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2859 r_u->status = status;
2862 /*******************************************************************
2863 reads or writes a structure.
2864 ********************************************************************/
2866 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2867 prs_struct *ps, int depth)
2872 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2878 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2884 /*******************************************************************
2885 inits a SAMR_Q_QUERY_GROUPINFO structure.
2886 ********************************************************************/
2888 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2889 POLICY_HND *pol, uint16 switch_level)
2891 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2895 q_e->switch_level = switch_level;
2898 /*******************************************************************
2899 reads or writes a structure.
2900 ********************************************************************/
2902 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2903 prs_struct *ps, int depth)
2908 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2914 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2917 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2923 /*******************************************************************
2924 inits a SAMR_R_QUERY_GROUPINFO structure.
2925 ********************************************************************/
2927 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2928 GROUP_INFO_CTR * ctr, NTSTATUS status)
2930 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2932 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2934 r_u->status = status;
2937 /*******************************************************************
2938 reads or writes a structure.
2939 ********************************************************************/
2941 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2942 prs_struct *ps, int depth)
2947 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2953 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2956 if (r_u->ptr != 0) {
2957 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2963 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2969 /*******************************************************************
2970 inits a SAMR_Q_QUERY_GROUPMEM structure.
2971 ********************************************************************/
2973 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2975 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2977 q_c->group_pol = *hnd;
2980 /*******************************************************************
2981 reads or writes a structure.
2982 ********************************************************************/
2984 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2985 prs_struct *ps, int depth)
2990 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2996 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
3002 /*******************************************************************
3003 inits a SAMR_R_QUERY_GROUPMEM structure.
3004 ********************************************************************/
3006 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
3007 uint32 num_entries, uint32 *rid,
3008 uint32 *attr, NTSTATUS status)
3010 DEBUG(5, ("init_samr_r_query_groupmem\n"));
3012 if (NT_STATUS_IS_OK(status)) {
3014 r_u->num_entries = num_entries;
3016 r_u->ptr_attrs = attr != NULL ? 1 : 0;
3017 r_u->ptr_rids = rid != NULL ? 1 : 0;
3019 r_u->num_rids = num_entries;
3022 r_u->num_attrs = num_entries;
3026 r_u->num_entries = 0;
3029 r_u->status = status;
3032 /*******************************************************************
3033 reads or writes a structure.
3034 ********************************************************************/
3036 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
3037 prs_struct *ps, int depth)
3044 if (UNMARSHALLING(ps))
3047 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
3053 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3055 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3058 if (r_u->ptr != 0) {
3059 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
3061 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
3064 if (r_u->ptr_rids != 0) {
3065 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
3067 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
3068 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
3069 if (r_u->rid == NULL)
3073 for (i = 0; i < r_u->num_rids; i++) {
3074 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
3079 if (r_u->ptr_attrs != 0) {
3080 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
3083 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
3084 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
3085 if (r_u->attr == NULL)
3089 for (i = 0; i < r_u->num_attrs; i++) {
3090 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
3096 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3102 /*******************************************************************
3103 inits a SAMR_Q_QUERY_USERGROUPS structure.
3104 ********************************************************************/
3106 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
3109 DEBUG(5, ("init_samr_q_query_usergroups\n"));
3114 /*******************************************************************
3115 reads or writes a structure.
3116 ********************************************************************/
3118 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
3119 prs_struct *ps, int depth)
3124 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
3130 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3136 /*******************************************************************
3137 inits a SAMR_R_QUERY_USERGROUPS structure.
3138 ********************************************************************/
3140 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3141 uint32 num_gids, DOM_GID * gid,
3144 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3146 if (NT_STATUS_IS_OK(status)) {
3148 r_u->num_entries = num_gids;
3149 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3150 r_u->num_entries2 = num_gids;
3155 r_u->num_entries = 0;
3160 r_u->status = status;
3163 /*******************************************************************
3164 reads or writes a structure.
3165 ********************************************************************/
3167 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3168 prs_struct *ps, int depth)
3174 prs_debug(ps, depth, desc, "samr_io_gids");
3180 if(!prs_uint32("num_gids", ps, depth, num_gids))
3183 if ((*num_gids) != 0) {
3184 if (UNMARSHALLING(ps)) {
3185 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3188 if ((*gid) == NULL) {
3192 for (i = 0; i < (*num_gids); i++) {
3193 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3201 /*******************************************************************
3202 reads or writes a structure.
3203 ********************************************************************/
3205 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3206 prs_struct *ps, int depth)
3211 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3217 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3220 if (r_u->ptr_0 != 0) {
3221 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3223 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3226 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3227 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3234 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3240 /*******************************************************************
3241 inits a SAMR_Q_ENUM_DOMAINS structure.
3242 ********************************************************************/
3244 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3246 uint32 start_idx, uint32 size)
3248 DEBUG(5, ("init_samr_q_enum_domains\n"));
3252 q_e->start_idx = start_idx;
3253 q_e->max_size = size;
3256 /*******************************************************************
3257 reads or writes a structure.
3258 ********************************************************************/
3260 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3261 prs_struct *ps, int depth)
3266 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3272 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3275 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3277 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3283 /*******************************************************************
3284 inits a SAMR_R_ENUM_DOMAINS structure.
3285 ********************************************************************/
3287 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3288 uint32 next_idx, uint32 num_sam_entries)
3290 DEBUG(5, ("init_samr_r_enum_domains\n"));
3292 r_u->next_idx = next_idx;
3294 if (num_sam_entries != 0) {
3295 r_u->ptr_entries1 = 1;
3296 r_u->ptr_entries2 = 1;
3297 r_u->num_entries2 = num_sam_entries;
3298 r_u->num_entries3 = num_sam_entries;
3300 r_u->num_entries4 = num_sam_entries;
3302 r_u->ptr_entries1 = 0;
3303 r_u->num_entries2 = num_sam_entries;
3304 r_u->ptr_entries2 = 1;
3308 /*******************************************************************
3309 reads or writes a structure.
3310 ********************************************************************/
3312 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3313 prs_struct *ps, int depth)
3320 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3326 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3328 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3331 if (r_u->ptr_entries1 != 0) {
3332 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3334 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3336 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3339 if (UNMARSHALLING(ps)) {
3340 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3341 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3344 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3345 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3346 r_u->num_entries4 = 0;
3347 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3351 for (i = 0; i < r_u->num_entries2; i++) {
3353 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3354 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3358 for (i = 0; i < r_u->num_entries2; i++) {
3360 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3361 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3362 r_u->sam[i].hdr_name.buffer, ps,
3371 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3373 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3379 /*******************************************************************
3380 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3381 ********************************************************************/
3383 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3385 uint32 start_idx, uint32 size)
3387 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3391 q_e->start_idx = start_idx;
3392 q_e->max_size = size;
3395 /*******************************************************************
3396 reads or writes a structure.
3397 ********************************************************************/
3399 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3400 prs_struct *ps, int depth)
3405 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3411 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3414 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3416 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3422 /*******************************************************************
3423 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3424 ********************************************************************/
3426 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3427 uint32 next_idx, uint32 num_sam_entries)
3429 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3431 r_u->next_idx = next_idx;
3433 if (num_sam_entries != 0) {
3434 r_u->ptr_entries1 = 1;
3435 r_u->ptr_entries2 = 1;
3436 r_u->num_entries2 = num_sam_entries;
3437 r_u->num_entries3 = num_sam_entries;
3439 r_u->num_entries4 = num_sam_entries;
3441 r_u->ptr_entries1 = 0;
3442 r_u->num_entries2 = num_sam_entries;
3443 r_u->ptr_entries2 = 1;
3447 /*******************************************************************
3448 reads or writes a structure.
3449 ********************************************************************/
3451 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3452 prs_struct *ps, int depth)
3459 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3465 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3467 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3470 if (r_u->ptr_entries1 != 0) {
3471 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3473 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3475 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3478 if (UNMARSHALLING(ps)) {
3479 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3480 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3483 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3485 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3486 r_u->num_entries4 = 0;
3487 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3491 for (i = 0; i < r_u->num_entries2; i++) {
3492 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3496 for (i = 0; i < r_u->num_entries2; i++) {
3497 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3498 r_u->sam[i].hdr_name.buffer, ps, depth))
3505 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3507 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3513 /*******************************************************************
3514 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3515 ********************************************************************/
3517 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3518 POLICY_HND *pol, uint32 start_idx,
3521 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3525 q_e->start_idx = start_idx;
3526 q_e->max_size = size;
3530 /*******************************************************************
3531 reads or writes a structure.
3532 ********************************************************************/
3534 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3535 prs_struct *ps, int depth)
3540 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3546 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3549 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3551 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3557 /*******************************************************************
3558 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3559 ********************************************************************/
3561 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3563 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3565 r_u->next_idx = next_idx;
3567 if (num_sam_entries != 0) {
3568 r_u->ptr_entries1 = 1;
3569 r_u->ptr_entries2 = 1;
3570 r_u->num_entries2 = num_sam_entries;
3571 r_u->num_entries3 = num_sam_entries;
3573 r_u->num_entries4 = num_sam_entries;
3575 r_u->ptr_entries1 = 0;
3576 r_u->num_entries2 = num_sam_entries;
3577 r_u->ptr_entries2 = 1;
3581 /*******************************************************************
3582 reads or writes a structure.
3583 ********************************************************************/
3585 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3586 prs_struct *ps, int depth)
3593 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3599 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3601 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3604 if (r_u->ptr_entries1 != 0) {
3605 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3607 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3609 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3612 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3613 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3614 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3617 if (r_u->num_entries2 != 0 &&
3618 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3619 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3620 r_u->num_entries4 = 0;
3621 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3625 for (i = 0; i < r_u->num_entries2; i++) {
3626 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3630 for (i = 0; i < r_u->num_entries2; i++) {
3631 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3632 r_u->sam[i].hdr_name.buffer, ps,
3640 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3642 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3648 /*******************************************************************
3649 inits a ALIAS_INFO1 structure.
3650 ********************************************************************/
3652 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3654 DEBUG(5, ("init_samr_alias_info1\n"));
3656 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3657 al1->num_member = num_member;
3658 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3661 /*******************************************************************
3662 reads or writes a structure.
3663 ********************************************************************/
3665 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3666 prs_struct *ps, int depth)
3671 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3677 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3679 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3681 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3684 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3686 if ( !prs_align(ps) )
3688 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3690 if ( !prs_align(ps) )
3696 /*******************************************************************
3697 inits a ALIAS_INFO3 structure.
3698 ********************************************************************/
3700 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3702 DEBUG(5, ("init_samr_alias_info3\n"));
3704 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3707 /*******************************************************************
3708 reads or writes a structure.
3709 ********************************************************************/
3711 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3712 prs_struct *ps, int depth)
3717 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3723 if (!prs_unistr4("description", ps, depth, &al3->description))
3729 /*******************************************************************
3730 reads or writes a structure.
3731 ********************************************************************/
3733 BOOL samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
3734 prs_struct *ps, int depth)
3739 prs_debug(ps, depth, desc, "samr_io_alias_info2");
3745 if (!prs_unistr4("name", ps, depth, &al2->name))
3751 /*******************************************************************
3752 reads or writes a structure.
3753 ********************************************************************/
3755 BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3760 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3763 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3768 switch (ctr->level) {
3770 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3774 if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
3778 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3782 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3789 /*******************************************************************
3790 inits a SAMR_Q_QUERY_ALIASINFO structure.
3791 ********************************************************************/
3793 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3794 POLICY_HND *pol, uint32 switch_level)
3796 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3799 q_e->level = switch_level;
3802 /*******************************************************************
3803 reads or writes a structure.
3804 ********************************************************************/
3806 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3807 prs_struct *ps, int depth)
3812 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3818 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3821 if ( !prs_uint16("level", ps, depth, &in->level) )
3827 /*******************************************************************
3828 inits a SAMR_R_QUERY_ALIASINFO structure.
3829 ********************************************************************/
3831 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3832 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3834 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3837 out->status = status;
3840 /*******************************************************************
3841 reads or writes a structure.
3842 ********************************************************************/
3844 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3845 prs_struct *ps, int depth)
3850 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3856 if ( !prs_pointer("alias", ps, depth, (void**)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3861 if(!prs_ntstatus("status", ps, depth, &out->status))
3867 /*******************************************************************
3868 inits a SAMR_Q_SET_ALIASINFO structure.
3869 ********************************************************************/
3871 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3872 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3874 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3876 q_u->alias_pol = *hnd;
3880 /*******************************************************************
3881 reads or writes a structure.
3882 ********************************************************************/
3884 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3885 prs_struct *ps, int depth)
3890 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3896 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3898 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3904 /*******************************************************************
3905 reads or writes a structure.
3906 ********************************************************************/
3908 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3909 prs_struct *ps, int depth)
3914 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3919 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3925 /*******************************************************************
3926 inits a SAMR_Q_QUERY_USERALIASES structure.
3927 ********************************************************************/
3929 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3932 uint32 *ptr_sid, DOM_SID2 * sid)
3934 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3938 q_u->num_sids1 = num_sids;
3940 q_u->num_sids2 = num_sids;
3942 q_u->ptr_sid = ptr_sid;
3946 /*******************************************************************
3947 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3948 ********************************************************************/
3950 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3951 prs_struct *ps, int depth)
3959 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3965 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3968 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3970 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3976 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3979 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3980 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3981 if (q_u->ptr_sid == NULL)
3984 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3985 if (q_u->sid == NULL)
3989 for (i = 0; i < q_u->num_sids2; i++) {
3990 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3991 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3995 for (i = 0; i < q_u->num_sids2; i++) {
3996 if (q_u->ptr_sid[i] != 0) {
3997 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3998 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
4006 /*******************************************************************
4007 inits a SAMR_R_QUERY_USERALIASES structure.
4008 ********************************************************************/
4010 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
4011 uint32 num_rids, uint32 *rid,
4014 DEBUG(5, ("init_samr_r_query_useraliases\n"));
4016 if (NT_STATUS_IS_OK(status)) {
4017 r_u->num_entries = num_rids;
4019 r_u->num_entries2 = num_rids;
4023 r_u->num_entries = 0;
4025 r_u->num_entries2 = 0;
4028 r_u->status = status;
4031 /*******************************************************************
4032 reads or writes a structure.
4033 ********************************************************************/
4035 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
4036 prs_struct *ps, int depth)
4043 prs_debug(ps, depth, desc, "samr_io_rids");
4049 if(!prs_uint32("num_rids", ps, depth, num_rids))
4052 if ((*num_rids) != 0) {
4053 if (UNMARSHALLING(ps)) {
4055 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
4060 for (i = 0; i < (*num_rids); i++) {
4061 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
4062 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
4070 /*******************************************************************
4071 reads or writes a structure.
4072 ********************************************************************/
4074 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
4075 prs_struct *ps, int depth)
4080 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
4086 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
4088 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
4091 if (r_u->ptr != 0) {
4092 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
4098 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4104 /*******************************************************************
4105 inits a SAMR_Q_OPEN_ALIAS structure.
4106 ********************************************************************/
4108 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
4109 uint32 access_mask, uint32 rid)
4111 DEBUG(5, ("init_samr_q_open_alias\n"));
4113 q_u->dom_pol = *pol;
4114 q_u->access_mask = access_mask;
4115 q_u->rid_alias = rid;
4118 /*******************************************************************
4119 reads or writes a structure.
4120 ********************************************************************/
4122 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
4123 prs_struct *ps, int depth)
4128 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
4134 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
4137 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4139 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
4145 /*******************************************************************
4146 reads or writes a structure.
4147 ********************************************************************/
4149 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4150 prs_struct *ps, int depth)
4155 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4161 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4164 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4170 /*******************************************************************
4171 inits a SAMR_Q_LOOKUP_RIDS structure.
4172 ********************************************************************/
4174 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4175 POLICY_HND *pol, uint32 flags,
4176 uint32 num_rids, uint32 *rid)
4178 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4182 q_u->num_rids1 = num_rids;
4185 q_u->num_rids2 = num_rids;
4186 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4187 if (q_u->rid == NULL) {
4191 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4195 /*******************************************************************
4196 reads or writes a structure.
4197 ********************************************************************/
4199 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4200 prs_struct *ps, int depth)
4208 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4211 if (UNMARSHALLING(ps))
4217 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4220 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4222 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4224 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4226 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4229 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4230 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4231 if (q_u->rid == NULL)
4235 for (i = 0; i < q_u->num_rids2; i++) {
4236 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4237 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4244 /*******************************************************************
4245 inits a SAMR_R_LOOKUP_RIDS structure.
4246 ********************************************************************/
4248 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4249 uint32 num_names, UNIHDR * hdr_name,
4250 UNISTR2 *uni_name, uint32 *type)
4252 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4254 r_u->hdr_name = NULL;
4255 r_u->uni_name = NULL;
4258 if (num_names != 0) {
4259 r_u->num_names1 = num_names;
4261 r_u->num_names2 = num_names;
4263 r_u->num_types1 = num_names;
4265 r_u->num_types2 = num_names;
4267 r_u->hdr_name = hdr_name;
4268 r_u->uni_name = uni_name;
4271 r_u->num_names1 = num_names;
4273 r_u->num_names2 = num_names;
4275 r_u->num_types1 = num_names;
4277 r_u->num_types2 = num_names;
4281 /*******************************************************************
4282 reads or writes a structure.
4283 ********************************************************************/
4285 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4286 prs_struct *ps, int depth)
4293 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4299 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4301 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4304 if (r_u->ptr_names != 0) {
4306 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4310 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4311 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4312 if (r_u->hdr_name == NULL)
4315 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4316 if (r_u->uni_name == NULL)
4320 for (i = 0; i < r_u->num_names2; i++) {
4321 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4322 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4325 for (i = 0; i < r_u->num_names2; i++) {
4326 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4327 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4335 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4337 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4340 if (r_u->ptr_types != 0) {
4342 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4345 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4346 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4347 if (r_u->type == NULL)
4351 for (i = 0; i < r_u->num_types2; i++) {
4352 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4353 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4358 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4364 /*******************************************************************
4365 inits a SAMR_Q_OPEN_ALIAS structure.
4366 ********************************************************************/
4368 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4370 DEBUG(5, ("init_samr_q_delete_alias\n"));
4372 q_u->alias_pol = *hnd;
4375 /*******************************************************************
4376 reads or writes a structure.
4377 ********************************************************************/
4379 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4380 prs_struct *ps, int depth)
4385 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4391 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4397 /*******************************************************************
4398 reads or writes a structure.
4399 ********************************************************************/
4401 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4402 prs_struct *ps, int depth)
4407 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4413 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4415 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4421 /*******************************************************************
4422 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4423 ********************************************************************/
4425 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4426 POLICY_HND *hnd, const char *acct_desc)
4428 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4430 q_u->dom_pol = *hnd;
4432 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4433 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4435 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4438 /*******************************************************************
4439 reads or writes a structure.
4440 ********************************************************************/
4442 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4443 prs_struct *ps, int depth)
4448 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4454 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4457 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4459 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4460 q_u->hdr_acct_desc.buffer, ps, depth))
4465 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4471 /*******************************************************************
4472 reads or writes a structure.
4473 ********************************************************************/
4475 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4476 prs_struct *ps, int depth)
4481 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4487 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4490 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4493 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4499 /*******************************************************************
4500 inits a SAMR_Q_ADD_ALIASMEM structure.
4501 ********************************************************************/
4503 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4506 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4508 q_u->alias_pol = *hnd;
4509 init_dom_sid2(&q_u->sid, sid);
4512 /*******************************************************************
4513 reads or writes a structure.
4514 ********************************************************************/
4516 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4517 prs_struct *ps, int depth)
4522 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4528 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4530 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4536 /*******************************************************************
4537 reads or writes a structure.
4538 ********************************************************************/
4540 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4541 prs_struct *ps, int depth)
4546 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4552 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4558 /*******************************************************************
4559 inits a SAMR_Q_DEL_ALIASMEM structure.
4560 ********************************************************************/
4562 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4565 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4567 q_u->alias_pol = *hnd;
4568 init_dom_sid2(&q_u->sid, sid);
4571 /*******************************************************************
4572 reads or writes a structure.
4573 ********************************************************************/
4575 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4576 prs_struct *ps, int depth)
4581 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4587 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4589 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4595 /*******************************************************************
4596 reads or writes a structure.
4597 ********************************************************************/
4599 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4600 prs_struct *ps, int depth)
4605 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4611 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4617 /*******************************************************************
4618 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4619 ********************************************************************/
4621 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4624 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4626 q_c->alias_pol = *hnd;
4629 /*******************************************************************
4630 reads or writes a structure.
4631 ********************************************************************/
4633 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4634 prs_struct *ps, int depth)
4639 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4645 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4651 /*******************************************************************
4652 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4653 ********************************************************************/
4655 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4658 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4660 r_u->status = status;
4663 /*******************************************************************
4664 reads or writes a structure.
4665 ********************************************************************/
4667 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4668 prs_struct *ps, int depth)
4673 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4679 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4682 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4688 /*******************************************************************
4689 inits a SAMR_Q_QUERY_ALIASMEM structure.
4690 ********************************************************************/
4692 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4695 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4697 q_c->alias_pol = *hnd;
4700 /*******************************************************************
4701 reads or writes a structure.
4702 ********************************************************************/
4704 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4705 prs_struct *ps, int depth)
4710 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4716 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4722 /*******************************************************************
4723 inits a SAMR_R_QUERY_ALIASMEM structure.
4724 ********************************************************************/
4726 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4727 uint32 num_sids, DOM_SID2 * sid,
4730 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4732 if (NT_STATUS_IS_OK(status)) {
4733 r_u->num_sids = num_sids;
4734 r_u->ptr = (num_sids != 0) ? 1 : 0;
4735 r_u->num_sids1 = num_sids;
4743 r_u->status = status;
4746 /*******************************************************************
4747 reads or writes a structure.
4748 ********************************************************************/
4750 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4751 prs_struct *ps, int depth)
4758 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4764 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4766 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4769 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4770 uint32 *ptr_sid = NULL;
4772 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4775 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4780 for (i = 0; i < r_u->num_sids1; i++) {
4782 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4786 if (UNMARSHALLING(ps)) {
4787 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4790 for (i = 0; i < r_u->num_sids1; i++) {
4791 if (ptr_sid[i] != 0) {
4792 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4800 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4806 /*******************************************************************
4807 inits a SAMR_Q_LOOKUP_NAMES structure.
4808 ********************************************************************/
4810 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4811 POLICY_HND *pol, uint32 flags,
4812 uint32 num_names, const char **name)
4816 DEBUG(5, ("init_samr_q_lookup_names\n"));
4820 q_u->num_names1 = num_names;
4823 q_u->num_names2 = num_names;
4825 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4826 return NT_STATUS_NO_MEMORY;
4828 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4829 return NT_STATUS_NO_MEMORY;
4831 for (i = 0; i < num_names; i++) {
4832 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4833 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4836 return NT_STATUS_OK;
4839 /*******************************************************************
4840 reads or writes a structure.
4841 ********************************************************************/
4843 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4844 prs_struct *ps, int depth)
4851 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4854 if (UNMARSHALLING(ps))
4860 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4863 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4865 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4867 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4869 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4872 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4873 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4874 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4875 if (!q_u->hdr_name || !q_u->uni_name)
4879 for (i = 0; i < q_u->num_names2; i++) {
4880 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4884 for (i = 0; i < q_u->num_names2; i++) {
4885 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4892 /*******************************************************************
4893 inits a SAMR_R_LOOKUP_NAMES structure.
4894 ********************************************************************/
4896 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4898 uint32 *rid, uint32 *type,
4901 DEBUG(5, ("init_samr_r_lookup_names\n"));
4903 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4906 r_u->num_types1 = num_rids;
4908 r_u->num_types2 = num_rids;
4910 r_u->num_rids1 = num_rids;
4912 r_u->num_rids2 = num_rids;
4914 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4915 return NT_STATUS_NO_MEMORY;
4916 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4917 return NT_STATUS_NO_MEMORY;
4919 if (!r_u->rids || !r_u->types)
4922 for (i = 0; i < num_rids; i++) {
4923 r_u->rids[i] = rid[i];
4924 r_u->types[i] = type[i];
4929 r_u->num_types1 = 0;
4931 r_u->num_types2 = 0;
4941 r_u->status = status;
4943 return NT_STATUS_OK;
4946 /*******************************************************************
4947 reads or writes a structure.
4948 ********************************************************************/
4950 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4951 prs_struct *ps, int depth)
4959 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4962 if (UNMARSHALLING(ps))
4968 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4970 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4973 if (r_u->ptr_rids != 0) {
4974 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4977 if (r_u->num_rids2 != r_u->num_rids1) {
4982 if (UNMARSHALLING(ps))
4983 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4986 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4990 for (i = 0; i < r_u->num_rids2; i++) {
4991 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4992 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4997 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4999 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
5002 if (r_u->ptr_types != 0) {
5003 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
5006 if (r_u->num_types2 != r_u->num_types1) {
5011 if (UNMARSHALLING(ps))
5012 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
5015 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
5019 for (i = 0; i < r_u->num_types2; i++) {
5020 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
5021 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
5026 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5032 /*******************************************************************
5033 inits a SAMR_Q_DELETE_DOM_USER structure.
5034 ********************************************************************/
5036 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
5039 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
5041 q_c->user_pol = *hnd;
5044 /*******************************************************************
5045 reads or writes a structure.
5046 ********************************************************************/
5048 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
5049 prs_struct *ps, int depth)
5054 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
5060 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
5066 /*******************************************************************
5067 reads or writes a structure.
5068 ********************************************************************/
5070 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
5071 prs_struct *ps, int depth)
5076 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
5082 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
5084 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5090 /*******************************************************************
5091 reads or writes a structure.
5092 ********************************************************************/
5094 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
5096 uint32 access_mask, uint32 rid)
5098 DEBUG(5, ("samr_init_samr_q_open_user\n"));
5100 q_u->domain_pol = *pol;
5101 q_u->access_mask = access_mask;
5102 q_u->user_rid = rid;
5105 /*******************************************************************
5106 reads or writes a structure.
5107 ********************************************************************/
5109 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
5110 prs_struct *ps, int depth)
5115 prs_debug(ps, depth, desc, "samr_io_q_open_user");
5121 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5124 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5126 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
5132 /*******************************************************************
5133 reads or writes a structure.
5134 ********************************************************************/
5136 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
5137 prs_struct *ps, int depth)
5142 prs_debug(ps, depth, desc, "samr_io_r_open_user");
5148 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5151 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5158 /*******************************************************************
5159 reads or writes a structure.
5160 ********************************************************************/
5162 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5165 uint32 acb_info, uint32 access_mask)
5167 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5169 q_u->domain_pol = *pol;
5171 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5172 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5174 q_u->acb_info = acb_info;
5175 q_u->access_mask = access_mask;
5178 /*******************************************************************
5179 reads or writes a structure.
5180 ********************************************************************/
5182 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5183 prs_struct *ps, int depth)
5188 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5194 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5197 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5199 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5204 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5206 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5212 /*******************************************************************
5213 reads or writes a structure.
5214 ********************************************************************/
5216 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5217 prs_struct *ps, int depth)
5222 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5228 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5231 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5233 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5235 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5241 /*******************************************************************
5242 inits a SAMR_Q_QUERY_USERINFO structure.
5243 ********************************************************************/
5245 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5246 const POLICY_HND *hnd, uint16 switch_value)
5248 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5251 q_u->switch_value = switch_value;
5254 /*******************************************************************
5255 reads or writes a structure.
5256 ********************************************************************/
5258 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5259 prs_struct *ps, int depth)
5264 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5270 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5273 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5279 /*******************************************************************
5280 reads or writes a LOGON_HRS structure.
5281 ********************************************************************/
5283 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5284 prs_struct *ps, int depth)
5289 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5295 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5298 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5301 if(!prs_uint32("len ", ps, depth, &hrs->len))
5304 if (hrs->len > sizeof(hrs->hours)) {
5305 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5306 hrs->len = sizeof(hrs->hours);
5309 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5315 /*******************************************************************
5316 inits a SAM_USER_INFO_18 structure.
5317 ********************************************************************/
5319 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5320 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5322 DEBUG(5, ("init_sam_user_info18\n"));
5324 usr->lm_pwd_active =
5325 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5326 usr->nt_pwd_active =
5327 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5330 /*******************************************************************
5331 reads or writes a structure.
5332 ********************************************************************/
5334 static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5335 prs_struct *ps, int depth)
5340 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5346 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5348 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5351 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5353 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5359 /*******************************************************************
5360 inits a SAM_USER_INFO_7 structure.
5361 ********************************************************************/
5363 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5365 DEBUG(5, ("init_sam_user_info7\n"));
5367 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5368 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5372 /*******************************************************************
5373 reads or writes a structure.
5374 ********************************************************************/
5376 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5377 prs_struct *ps, int depth)
5382 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5388 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5391 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5397 /*******************************************************************
5398 inits a SAM_USER_INFO_9 structure.
5399 ********************************************************************/
5401 void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
5403 DEBUG(5, ("init_sam_user_info9\n"));
5405 usr->rid_group = rid_group;
5408 /*******************************************************************
5409 reads or writes a structure.
5410 ********************************************************************/
5412 static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
5413 prs_struct *ps, int depth)
5418 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
5424 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5430 /*******************************************************************
5431 inits a SAM_USER_INFO_16 structure.
5432 ********************************************************************/
5434 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5436 DEBUG(5, ("init_sam_user_info16\n"));
5438 usr->acb_info = acb_info;
5441 /*******************************************************************
5442 reads or writes a structure.
5443 ********************************************************************/
5445 static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5446 prs_struct *ps, int depth)
5451 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5457 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5463 /*******************************************************************
5464 inits a SAM_USER_INFO_17 structure.
5465 ********************************************************************/
5467 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5470 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5472 DEBUG(5, ("init_sam_user_info17\n"));
5474 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5475 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5477 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5479 usr->ptr_1 = 1; /* pointer */
5480 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5481 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5483 usr->ptr_2 = 1; /* pointer */
5484 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5486 usr->ptr_3 = 1; /* pointer */
5487 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5489 usr->rid_user = rid_user;
5490 usr->rid_group = rid_group;
5492 usr->acct_ctrl = acct_ctrl;
5493 usr->unknown_3 = 0x0000;
5495 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5496 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5498 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5499 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5501 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5502 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5505 /*******************************************************************
5506 reads or writes a structure.
5507 ********************************************************************/
5509 static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5510 prs_struct *ps, int depth)
5515 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5521 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5524 if(!smb_io_time("time", &usr->expiry, ps, depth))
5527 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5530 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5533 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5536 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5538 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5541 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5544 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5546 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5549 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5551 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5554 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5556 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5558 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5560 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5562 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5564 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5567 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5570 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5573 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5579 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5585 /*************************************************************************
5587 *************************************************************************/
5589 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5591 DEBUG(10, ("init_sam_user_info24:\n"));
5592 memcpy(usr->pass, newpass, sizeof(usr->pass));
5593 usr->pw_len = pw_len;
5596 /*******************************************************************
5597 reads or writes a structure.
5598 ********************************************************************/
5600 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5601 prs_struct *ps, int depth)
5606 prs_debug(ps, depth, desc, "sam_io_user_info24");
5612 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5616 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5617 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5619 } else if (UNMARSHALLING(ps)) {
5620 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5627 /*******************************************************************
5628 reads or writes a structure.
5629 ********************************************************************/
5631 static BOOL sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
5632 prs_struct *ps, int depth)
5637 prs_debug(ps, depth, desc, "sam_io_user_info26");
5643 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5647 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5654 /*************************************************************************
5655 init_sam_user_info23
5657 unknown_6 = 0x0000 04ec
5659 *************************************************************************/
5661 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5662 NTTIME * logoff_time, /* all zeros */
5663 NTTIME * kickoff_time, /* all zeros */
5664 NTTIME * pass_last_set_time, /* all zeros */
5665 NTTIME * pass_can_change_time, /* all zeros */
5666 NTTIME * pass_must_change_time, /* all zeros */
5677 uint32 user_rid, /* 0x0000 0000 */
5680 uint32 fields_present,
5683 uint16 bad_password_count,
5687 usr->logon_time = *logon_time; /* all zeros */
5688 usr->logoff_time = *logoff_time; /* all zeros */
5689 usr->kickoff_time = *kickoff_time; /* all zeros */
5690 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5691 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5692 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5694 ZERO_STRUCT(usr->nt_pwd);
5695 ZERO_STRUCT(usr->lm_pwd);
5697 usr->user_rid = user_rid; /* 0x0000 0000 */
5698 usr->group_rid = group_rid;
5699 usr->acb_info = acb_info;
5700 usr->fields_present = fields_present; /* 09f8 27fa */
5702 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5703 usr->ptr_logon_hrs = hrs ? 1 : 0;
5705 if (nt_time_is_zero(pass_must_change_time)) {
5706 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5708 usr->passmustchange=0;
5711 ZERO_STRUCT(usr->padding1);
5712 ZERO_STRUCT(usr->padding2);
5714 usr->bad_password_count = bad_password_count;
5715 usr->logon_count = logon_count;
5717 memcpy(usr->pass, newpass, sizeof(usr->pass));
5719 copy_unistr2(&usr->uni_user_name, user_name);
5720 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5722 copy_unistr2(&usr->uni_full_name, full_name);
5723 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5725 copy_unistr2(&usr->uni_home_dir, home_dir);
5726 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5728 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5729 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5731 copy_unistr2(&usr->uni_logon_script, log_scr);
5732 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5734 copy_unistr2(&usr->uni_profile_path, prof_path);
5735 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5737 copy_unistr2(&usr->uni_acct_desc, desc);
5738 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5740 copy_unistr2(&usr->uni_workstations, wkstas);
5741 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5743 copy_unistr2(&usr->uni_unknown_str, unk_str);
5744 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5746 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5747 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5750 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5752 ZERO_STRUCT(usr->logon_hrs);
5756 /*************************************************************************
5757 init_sam_user_info23
5759 unknown_6 = 0x0000 04ec
5761 *************************************************************************/
5763 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5764 NTTIME * logoff_time, /* all zeros */
5765 NTTIME * kickoff_time, /* all zeros */
5766 NTTIME * pass_last_set_time, /* all zeros */
5767 NTTIME * pass_can_change_time, /* all zeros */
5768 NTTIME * pass_must_change_time, /* all zeros */
5769 char *user_name, /* NULL */
5771 char *home_dir, char *dir_drive, char *log_scr,
5772 char *prof_path, const char *desc, char *wkstas,
5773 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5774 uint32 group_rid, uint32 acb_info,
5775 uint32 fields_present, uint16 logon_divs,
5776 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5779 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5781 usr->logon_time = *logon_time; /* all zeros */
5782 usr->logoff_time = *logoff_time; /* all zeros */
5783 usr->kickoff_time = *kickoff_time; /* all zeros */
5784 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5785 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5786 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5788 ZERO_STRUCT(usr->nt_pwd);
5789 ZERO_STRUCT(usr->lm_pwd);
5791 usr->user_rid = user_rid; /* 0x0000 0000 */
5792 usr->group_rid = group_rid;
5793 usr->acb_info = acb_info;
5794 usr->fields_present = fields_present; /* 09f8 27fa */
5796 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5797 usr->ptr_logon_hrs = hrs ? 1 : 0;
5799 if (nt_time_is_zero(pass_must_change_time)) {
5800 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5802 usr->passmustchange=0;
5805 ZERO_STRUCT(usr->padding1);
5806 ZERO_STRUCT(usr->padding2);
5808 usr->bad_password_count = bad_password_count;
5809 usr->logon_count = logon_count;
5811 memcpy(usr->pass, newpass, sizeof(usr->pass));
5813 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5814 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5816 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5817 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5819 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5820 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5822 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5823 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5825 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5826 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5828 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5829 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5831 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5832 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5834 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5835 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5837 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5838 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5840 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5841 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5843 data_blob_free(&blob);
5846 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5848 ZERO_STRUCT(usr->logon_hrs);
5852 /*******************************************************************
5853 reads or writes a structure.
5854 ********************************************************************/
5856 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5857 prs_struct *ps, int depth)
5862 prs_debug(ps, depth, desc, "sam_io_user_info23");
5868 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5870 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5872 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5874 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5876 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5878 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5881 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5883 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5885 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5887 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5889 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5891 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5893 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5895 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5897 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5899 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5902 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5904 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5907 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5909 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5911 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5914 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5916 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5920 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5923 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5925 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5928 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5930 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5932 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5936 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5939 /* here begins pointed-to data */
5941 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5944 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5947 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5950 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5953 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5956 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5959 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5962 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5965 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5968 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5971 /* ok, this is only guess-work (as usual) */
5972 if (usr->ptr_logon_hrs) {
5973 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5980 /*******************************************************************
5981 reads or writes a structure.
5982 NB. This structure is *definately* incorrect. It's my best guess
5983 currently for W2K SP2. The password field is encrypted in a different
5984 way than normal... And there are definately other problems. JRA.
5985 ********************************************************************/
5987 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5992 prs_debug(ps, depth, desc, "sam_io_user_info25");
5998 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6000 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6002 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6004 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
6006 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
6008 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6011 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6013 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6015 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6017 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6019 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6021 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6023 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6025 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6027 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6029 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6032 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6034 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6037 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6039 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6041 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6044 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
6047 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6050 /* here begins pointed-to data */
6052 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6055 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6058 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6061 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6064 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6067 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6070 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6073 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6076 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6079 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6082 #if 0 /* JRA - unknown... */
6083 /* ok, this is only guess-work (as usual) */
6084 if (usr->ptr_logon_hrs) {
6085 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6094 /*************************************************************************
6095 init_sam_user_info21W
6097 unknown_6 = 0x0000 04ec
6099 *************************************************************************/
6101 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
6102 NTTIME * logon_time,
6103 NTTIME * logoff_time,
6104 NTTIME * kickoff_time,
6105 NTTIME * pass_last_set_time,
6106 NTTIME * pass_can_change_time,
6107 NTTIME * pass_must_change_time,
6123 uint32 fields_present,
6126 uint16 bad_password_count,
6129 usr->logon_time = *logon_time;
6130 usr->logoff_time = *logoff_time;
6131 usr->kickoff_time = *kickoff_time;
6132 usr->pass_last_set_time = *pass_last_set_time;
6133 usr->pass_can_change_time = *pass_can_change_time;
6134 usr->pass_must_change_time = *pass_must_change_time;
6136 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
6137 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
6139 usr->user_rid = user_rid;
6140 usr->group_rid = group_rid;
6141 usr->acb_info = acb_info;
6142 usr->fields_present = fields_present; /* 0x00ff ffff */
6144 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
6145 usr->ptr_logon_hrs = hrs ? 1 : 0;
6146 usr->bad_password_count = bad_password_count;
6147 usr->logon_count = logon_count;
6149 if (nt_time_is_zero(pass_must_change_time)) {
6150 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6152 usr->passmustchange=0;
6155 ZERO_STRUCT(usr->padding1);
6156 ZERO_STRUCT(usr->padding2);
6158 copy_unistr2(&usr->uni_user_name, user_name);
6159 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6161 copy_unistr2(&usr->uni_full_name, full_name);
6162 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6164 copy_unistr2(&usr->uni_home_dir, home_dir);
6165 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6167 copy_unistr2(&usr->uni_dir_drive, dir_drive);
6168 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6170 copy_unistr2(&usr->uni_logon_script, log_scr);
6171 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6173 copy_unistr2(&usr->uni_profile_path, prof_path);
6174 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6176 copy_unistr2(&usr->uni_acct_desc, desc);
6177 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6179 copy_unistr2(&usr->uni_workstations, wkstas);
6180 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6182 copy_unistr2(&usr->uni_unknown_str, unk_str);
6183 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6185 copy_unistr2(&usr->uni_munged_dial, mung_dial);
6186 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6189 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
6191 ZERO_STRUCT(usr->logon_hrs);
6195 /*************************************************************************
6196 init_sam_user_info21
6198 unknown_6 = 0x0000 04ec
6200 *************************************************************************/
6202 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
6204 NTTIME logon_time, logoff_time, kickoff_time,
6205 pass_last_set_time, pass_can_change_time,
6206 pass_must_change_time;
6208 const char* user_name = pdb_get_username(pw);
6209 const char* full_name = pdb_get_fullname(pw);
6210 const char* home_dir = pdb_get_homedir(pw);
6211 const char* dir_drive = pdb_get_dir_drive(pw);
6212 const char* logon_script = pdb_get_logon_script(pw);
6213 const char* profile_path = pdb_get_profile_path(pw);
6214 const char* description = pdb_get_acct_desc(pw);
6215 const char* workstations = pdb_get_workstations(pw);
6216 const char* munged_dial = pdb_get_munged_dial(pw);
6217 DATA_BLOB munged_dial_blob;
6220 const DOM_SID *user_sid;
6223 const DOM_SID *group_sid;
6226 munged_dial_blob = base64_decode_data_blob(munged_dial);
6228 munged_dial_blob = data_blob(NULL, 0);
6231 /* Create NTTIME structs */
6232 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6233 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6234 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6235 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6236 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6237 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6239 /* structure assignment */
6240 usr->logon_time = logon_time;
6241 usr->logoff_time = logoff_time;
6242 usr->kickoff_time = kickoff_time;
6243 usr->pass_last_set_time = pass_last_set_time;
6244 usr->pass_can_change_time = pass_can_change_time;
6245 usr->pass_must_change_time = pass_must_change_time;
6247 ZERO_STRUCT(usr->nt_pwd);
6248 ZERO_STRUCT(usr->lm_pwd);
6250 user_sid = pdb_get_user_sid(pw);
6252 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6253 fstring user_sid_string;
6254 fstring domain_sid_string;
6255 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6256 "the domain sid %s. Failing operation.\n",
6258 sid_to_string(user_sid_string, user_sid),
6259 sid_to_string(domain_sid_string, domain_sid)));
6260 data_blob_free(&munged_dial_blob);
6261 return NT_STATUS_UNSUCCESSFUL;
6264 group_sid = pdb_get_group_sid(pw);
6266 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6267 fstring group_sid_string;
6268 fstring domain_sid_string;
6269 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6270 "which conflicts with the domain sid %s. Failing operation.\n",
6272 sid_to_string(group_sid_string, group_sid),
6273 sid_to_string(domain_sid_string, domain_sid)));
6274 data_blob_free(&munged_dial_blob);
6275 return NT_STATUS_UNSUCCESSFUL;
6278 usr->user_rid = user_rid;
6279 usr->group_rid = group_rid;
6280 usr->acb_info = pdb_get_acct_ctrl(pw);
6283 Look at a user on a real NT4 PDC with usrmgr, press
6284 'ok'. Then you will see that fields_present is set to
6285 0x08f827fa. Look at the user immediately after that again,
6286 and you will see that 0x00fffff is returned. This solves
6287 the problem that you get access denied after having looked
6291 usr->fields_present = pdb_build_fields_present(pw);
6293 usr->logon_divs = pdb_get_logon_divs(pw);
6294 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6295 usr->bad_password_count = pdb_get_bad_password_count(pw);
6296 usr->logon_count = pdb_get_logon_count(pw);
6298 if (pdb_get_pass_must_change_time(pw) == 0) {
6299 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6301 usr->passmustchange=0;
6304 ZERO_STRUCT(usr->padding1);
6305 ZERO_STRUCT(usr->padding2);
6307 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6308 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6310 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6311 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6313 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6314 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6316 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6317 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6319 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6320 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6322 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6323 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6325 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6326 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6328 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6329 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6331 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6332 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6334 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6335 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6336 data_blob_free(&munged_dial_blob);
6338 if (pdb_get_hours(pw)) {
6339 usr->logon_hrs.max_len = 1260;
6340 usr->logon_hrs.offset = 0;
6341 usr->logon_hrs.len = pdb_get_hours_len(pw);
6342 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6344 usr->logon_hrs.max_len = 1260;
6345 usr->logon_hrs.offset = 0;
6346 usr->logon_hrs.len = 0;
6347 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6350 return NT_STATUS_OK;
6353 /*******************************************************************
6354 reads or writes a structure.
6355 ********************************************************************/
6357 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6358 prs_struct *ps, int depth)
6363 prs_debug(ps, depth, desc, "sam_io_user_info21");
6369 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6371 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6373 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6375 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6377 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6379 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6382 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6384 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6386 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6388 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6390 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6392 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6394 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6396 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6398 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6400 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6403 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6405 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6408 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6410 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6412 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6415 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6417 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6421 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6424 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6426 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6429 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6431 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6433 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6436 /* here begins pointed-to data */
6438 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6440 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6442 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6444 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6446 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6448 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6450 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6452 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6454 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6456 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6459 /* ok, this is only guess-work (as usual) */
6460 if (usr->ptr_logon_hrs) {
6461 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6468 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
6470 const char *munged_dial = pdb_get_munged_dial(pw);
6471 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6473 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6474 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6475 data_blob_free(&blob);
6478 /*******************************************************************
6479 reads or writes a structure.
6480 ********************************************************************/
6482 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6483 prs_struct *ps, int depth)
6488 prs_debug(ps, depth, desc, "sam_io_user_info20");
6494 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6497 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6503 /*******************************************************************
6504 inits a SAM_USERINFO_CTR structure.
6505 ********************************************************************/
6507 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6508 uint16 switch_value,
6509 SAM_USER_INFO_21 * usr)
6511 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6513 ctr->switch_value = switch_value;
6514 ctr->info.id = NULL;
6516 switch (switch_value) {
6518 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6519 if (ctr->info.id16 == NULL)
6520 return NT_STATUS_NO_MEMORY;
6522 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6525 /* whoops - got this wrong. i think. or don't understand what's happening. */
6529 info = (void *)&id11;
6531 expire.low = 0xffffffff;
6532 expire.high = 0x7fffffff;
6534 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6535 init_sam_user_info11(ctr->info.id17, &expire,
6536 "BROOKFIELDS$", /* name */
6537 0x03ef, /* user rid */
6538 0x201, /* group rid */
6539 0x0080); /* acb info */
6545 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6546 if (ctr->info.id18 == NULL)
6547 return NT_STATUS_NO_MEMORY;
6549 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6553 SAM_USER_INFO_21 *cusr;
6554 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6555 ctr->info.id21 = cusr;
6556 if (ctr->info.id21 == NULL)
6557 return NT_STATUS_NO_MEMORY;
6558 memcpy(cusr, usr, sizeof(*usr));
6559 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6560 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6564 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6565 return NT_STATUS_INVALID_INFO_CLASS;
6568 return NT_STATUS_OK;
6571 /*******************************************************************
6572 inits a SAM_USERINFO_CTR structure.
6573 ********************************************************************/
6575 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6576 uint16 switch_value, void *info)
6578 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6580 ctr->switch_value = switch_value;
6581 ctr->info.id = info;
6583 switch (switch_value) {
6585 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6586 dump_data(100, (char *)sess_key->data, sess_key->length);
6587 dump_data(100, (char *)ctr->info.id24->pass, 516);
6590 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6591 dump_data(100, (char *)sess_key->data, sess_key->length);
6592 dump_data(100, (char *)ctr->info.id23->pass, 516);
6597 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6601 /*******************************************************************
6602 reads or writes a structure.
6603 ********************************************************************/
6605 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6606 prs_struct *ps, int depth)
6609 SAM_USERINFO_CTR *ctr;
6611 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6614 if (UNMARSHALLING(ps)) {
6615 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6623 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6625 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6632 switch (ctr->switch_value) {
6634 if (UNMARSHALLING(ps))
6635 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6636 if (ctr->info.id7 == NULL) {
6637 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6640 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6643 if (UNMARSHALLING(ps))
6644 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
6645 if (ctr->info.id9 == NULL) {
6646 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6649 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
6652 if (UNMARSHALLING(ps))
6653 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6654 if (ctr->info.id16 == NULL) {
6655 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6658 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6661 if (UNMARSHALLING(ps))
6662 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6664 if (ctr->info.id17 == NULL) {
6665 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6668 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6671 if (UNMARSHALLING(ps))
6672 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6674 if (ctr->info.id18 == NULL) {
6675 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6678 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6681 if (UNMARSHALLING(ps))
6682 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6684 if (ctr->info.id20 == NULL) {
6685 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6688 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6691 if (UNMARSHALLING(ps))
6692 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6694 if (ctr->info.id21 == NULL) {
6695 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6698 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6701 if (UNMARSHALLING(ps))
6702 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6704 if (ctr->info.id23 == NULL) {
6705 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6708 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6711 if (UNMARSHALLING(ps))
6712 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6714 if (ctr->info.id24 == NULL) {
6715 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6718 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6721 if (UNMARSHALLING(ps))
6722 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6724 if (ctr->info.id25 == NULL) {
6725 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6728 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6731 if (UNMARSHALLING(ps))
6732 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6734 if (ctr->info.id26 == NULL) {
6735 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6738 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6741 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6749 /*******************************************************************
6750 inits a SAMR_R_QUERY_USERINFO structure.
6751 ********************************************************************/
6753 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6754 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6756 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6761 if (NT_STATUS_IS_OK(status)) {
6766 r_u->status = status; /* return status */
6769 /*******************************************************************
6770 reads or writes a structure.
6771 ********************************************************************/
6773 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6774 prs_struct *ps, int depth)
6779 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6785 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6788 if (r_u->ptr != 0) {
6789 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6795 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6801 /*******************************************************************
6802 inits a SAMR_Q_SET_USERINFO structure.
6803 ********************************************************************/
6805 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6806 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6807 uint16 switch_value, void *info)
6809 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6812 q_u->switch_value = switch_value;
6813 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6816 /*******************************************************************
6817 reads or writes a structure.
6818 ********************************************************************/
6820 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6821 prs_struct *ps, int depth)
6826 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6832 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6834 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6836 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6842 /*******************************************************************
6843 inits a SAMR_R_SET_USERINFO structure.
6844 ********************************************************************/
6846 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6848 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6850 r_u->status = status; /* return status */
6853 /*******************************************************************
6854 reads or writes a structure.
6855 ********************************************************************/
6857 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6858 prs_struct *ps, int depth)
6863 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6869 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6875 /*******************************************************************
6876 inits a SAMR_Q_SET_USERINFO2 structure.
6877 ********************************************************************/
6879 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6880 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6881 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6883 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6886 q_u->switch_value = switch_value;
6889 if (q_u->ctr != NULL)
6890 q_u->ctr->switch_value = switch_value;
6892 switch (switch_value) {
6894 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
6895 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
6896 dump_data(100, (char *)sess_key->data, sess_key->length);
6897 dump_data(100, (char *)ctr->info.id18->lm_pwd, 16);
6898 dump_data(100, (char *)ctr->info.id18->nt_pwd, 16);
6903 /*******************************************************************
6904 reads or writes a structure.
6905 ********************************************************************/
6907 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6908 prs_struct *ps, int depth)
6913 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6919 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6922 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6924 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6930 /*******************************************************************
6931 inits a SAMR_R_SET_USERINFO2 structure.
6932 ********************************************************************/
6934 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6936 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6938 r_u->status = status; /* return status */
6941 /*******************************************************************
6942 reads or writes a structure.
6943 ********************************************************************/
6945 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6946 prs_struct *ps, int depth)
6951 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6957 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6963 /*******************************************************************
6964 inits a SAMR_Q_CONNECT structure.
6965 ********************************************************************/
6967 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6968 char *srv_name, uint32 access_mask)
6970 DEBUG(5, ("init_samr_q_connect\n"));
6972 /* make PDC server name \\server */
6973 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6974 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6976 /* example values: 0x0000 0002 */
6977 q_u->access_mask = access_mask;
6980 /*******************************************************************
6981 reads or writes a structure.
6982 ********************************************************************/
6984 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6985 prs_struct *ps, int depth)
6990 prs_debug(ps, depth, desc, "samr_io_q_connect");
6996 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6998 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7003 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7009 /*******************************************************************
7010 reads or writes a structure.
7011 ********************************************************************/
7013 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
7014 prs_struct *ps, int depth)
7019 prs_debug(ps, depth, desc, "samr_io_r_connect");
7025 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7028 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7034 /*******************************************************************
7035 inits a SAMR_Q_CONNECT4 structure.
7036 ********************************************************************/
7038 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
7039 char *srv_name, uint32 access_mask)
7041 DEBUG(5, ("init_samr_q_connect4\n"));
7043 /* make PDC server name \\server */
7044 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7045 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7047 /* Only value we've seen, possibly an address type ? */
7050 /* example values: 0x0000 0002 */
7051 q_u->access_mask = access_mask;
7054 /*******************************************************************
7055 reads or writes a structure.
7056 ********************************************************************/
7058 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
7059 prs_struct *ps, int depth)
7064 prs_debug(ps, depth, desc, "samr_io_q_connect4");
7070 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7072 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7077 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
7079 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7085 /*******************************************************************
7086 reads or writes a structure.
7087 ********************************************************************/
7089 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
7090 prs_struct *ps, int depth)
7095 prs_debug(ps, depth, desc, "samr_io_r_connect4");
7101 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7104 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7110 /*******************************************************************
7111 inits a SAMR_Q_CONNECT5 structure.
7112 ********************************************************************/
7114 void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
7115 char *srv_name, uint32 access_mask)
7117 DEBUG(5, ("init_samr_q_connect5\n"));
7119 /* make PDC server name \\server */
7120 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7121 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7123 /* example values: 0x0000 0002 */
7124 q_u->access_mask = access_mask;
7127 q_u->info1_unk1 = 3;
7128 q_u->info1_unk2 = 0;
7131 /*******************************************************************
7132 inits a SAMR_R_CONNECT5 structure.
7133 ********************************************************************/
7135 void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
7137 DEBUG(5, ("init_samr_q_connect5\n"));
7140 r_u->info1_unk1 = 3;
7141 r_u->info1_unk2 = 0;
7143 r_u->connect_pol = *pol;
7144 r_u->status = status;
7147 /*******************************************************************
7148 reads or writes a structure.
7149 ********************************************************************/
7151 BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
7152 prs_struct *ps, int depth)
7157 prs_debug(ps, depth, desc, "samr_io_q_connect5");
7163 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7165 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7170 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7173 if(!prs_uint32("level", ps, depth, &q_u->level))
7175 if(!prs_uint32("level", ps, depth, &q_u->level))
7178 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
7180 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
7186 /*******************************************************************
7187 reads or writes a structure.
7188 ********************************************************************/
7190 BOOL samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
7191 prs_struct *ps, int depth)
7196 prs_debug(ps, depth, desc, "samr_io_r_connect5");
7202 if(!prs_uint32("level", ps, depth, &r_u->level))
7204 if(!prs_uint32("level", ps, depth, &r_u->level))
7206 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
7208 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
7211 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7214 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7220 /*******************************************************************
7221 inits a SAMR_Q_CONNECT_ANON structure.
7222 ********************************************************************/
7224 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
7226 DEBUG(5, ("init_samr_q_connect_anon\n"));
7229 q_u->unknown_0 = 0x5c; /* server name (?!!) */
7230 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
7233 /*******************************************************************
7234 reads or writes a structure.
7235 ********************************************************************/
7237 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
7238 prs_struct *ps, int depth)
7243 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
7249 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
7252 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
7257 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7263 /*******************************************************************
7264 reads or writes a structure.
7265 ********************************************************************/
7267 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
7268 prs_struct *ps, int depth)
7273 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
7279 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7282 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7288 /*******************************************************************
7289 inits a SAMR_Q_GET_DOM_PWINFO structure.
7290 ********************************************************************/
7292 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
7295 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7298 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
7299 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
7302 /*******************************************************************
7303 reads or writes a structure.
7304 ********************************************************************/
7306 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
7307 prs_struct *ps, int depth)
7312 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
7318 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
7320 if (q_u->ptr != 0) {
7321 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7323 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7330 /*******************************************************************
7331 reads or writes a structure.
7332 ********************************************************************/
7334 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7335 prs_struct *ps, int depth)
7340 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7346 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
7350 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
7353 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7359 /*******************************************************************
7360 make a SAMR_ENC_PASSWD structure.
7361 ********************************************************************/
7363 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7371 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7375 /*******************************************************************
7376 reads or writes a SAMR_ENC_PASSWD structure.
7377 ********************************************************************/
7379 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7380 prs_struct *ps, int depth)
7385 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7391 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7394 if (pwd->ptr != 0) {
7395 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7402 /*******************************************************************
7403 inits a SAMR_ENC_HASH structure.
7404 ********************************************************************/
7406 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7414 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7418 /*******************************************************************
7419 reads or writes a SAMR_ENC_HASH structure.
7420 ********************************************************************/
7422 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7423 prs_struct *ps, int depth)
7428 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7434 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7436 if (hsh->ptr != 0) {
7437 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7444 /*******************************************************************
7445 inits a SAMR_Q_CHGPASSWD_USER structure.
7446 ********************************************************************/
7448 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7449 const char *dest_host, const char *user_name,
7450 const uchar nt_newpass[516],
7451 const uchar nt_oldhash[16],
7452 const uchar lm_newpass[516],
7453 const uchar lm_oldhash[16])
7455 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7458 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7459 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7461 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7462 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7464 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7465 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7467 q_u->unknown = 0x01;
7469 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7470 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7473 /*******************************************************************
7474 reads or writes a structure.
7475 ********************************************************************/
7477 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7478 prs_struct *ps, int depth)
7483 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7489 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7492 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7494 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7499 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7501 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7504 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7506 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7509 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7512 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7514 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7520 /*******************************************************************
7521 inits a SAMR_R_CHGPASSWD_USER structure.
7522 ********************************************************************/
7524 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7526 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7528 r_u->status = status;
7531 /*******************************************************************
7532 reads or writes a structure.
7533 ********************************************************************/
7535 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7536 prs_struct *ps, int depth)
7541 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7547 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7553 /*******************************************************************
7554 inits a SAMR_Q_CHGPASSWD3 structure.
7555 ********************************************************************/
7557 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
7558 const char *dest_host, const char *user_name,
7559 const uchar nt_newpass[516],
7560 const uchar nt_oldhash[16],
7561 const uchar lm_newpass[516],
7562 const uchar lm_oldhash[16])
7564 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7567 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7568 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7570 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7571 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7573 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7574 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7576 q_u->lm_change = 0x01;
7578 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7579 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7581 init_enc_passwd(&q_u->password3, NULL);
7584 /*******************************************************************
7585 reads or writes a structure.
7586 ********************************************************************/
7588 BOOL samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
7589 prs_struct *ps, int depth)
7594 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
7600 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7603 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7605 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7610 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7612 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7615 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7617 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7620 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
7623 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7625 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7628 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
7634 /*******************************************************************
7635 inits a SAMR_R_CHGPASSWD_USER3 structure.
7636 ********************************************************************/
7638 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
7639 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
7641 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7643 r_u->status = status;
7647 r_u->ptr_reject = 0;
7653 if (reject && (reject->reject_reason != Undefined)) {
7654 r_u->reject = reject;
7655 r_u->ptr_reject = 1;
7659 /*******************************************************************
7660 Reads or writes an SAMR_CHANGE_REJECT structure.
7661 ********************************************************************/
7663 BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
7668 prs_debug(ps, depth, desc, "samr_io_change_reject");
7674 if(UNMARSHALLING(ps))
7675 ZERO_STRUCTP(reject);
7677 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
7680 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
7683 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
7689 /*******************************************************************
7690 reads or writes a structure.
7691 ********************************************************************/
7693 BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
7694 prs_struct *ps, int depth)
7699 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
7705 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
7708 if (r_u->ptr_info && r_u->info != NULL) {
7709 /* SAM_UNK_INFO_1 */
7710 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
7714 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
7717 if (r_u->ptr_reject && r_u->reject != NULL) {
7718 /* SAMR_CHANGE_REJECT */
7719 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
7723 if (!prs_ntstatus("status", ps, depth, &r_u->status))
7729 /*******************************************************************
7730 reads or writes a structure.
7731 ********************************************************************/
7733 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7734 POLICY_HND *domain_pol, uint16 switch_value)
7736 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7738 q_u->domain_pol = *domain_pol;
7739 q_u->switch_value = switch_value;
7742 /*******************************************************************
7743 reads or writes a structure.
7744 ********************************************************************/
7746 BOOL samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7747 prs_struct *ps, int depth)
7752 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7758 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7761 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7767 /*******************************************************************
7768 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7769 ********************************************************************/
7771 void init_samr_r_samr_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7772 uint16 switch_value, SAM_UNK_CTR * ctr,
7775 DEBUG(5, ("init_samr_r_samr_query_domain_info2\n"));
7778 r_u->switch_value = 0;
7779 r_u->status = status; /* return status */
7781 if (NT_STATUS_IS_OK(status)) {
7782 r_u->switch_value = switch_value;
7788 /*******************************************************************
7789 reads or writes a structure.
7790 ********************************************************************/
7792 BOOL samr_io_r_samr_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7793 prs_struct *ps, int depth)
7798 prs_debug(ps, depth, desc, "samr_io_r_samr_query_domain_info2");
7804 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7807 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7808 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7813 switch (r_u->switch_value) {
7815 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7819 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7823 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7827 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7831 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7835 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7839 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7843 DEBUG(0, ("samr_io_r_samr_query_domain_info2: unknown switch level 0x%x\n",
7844 r_u->switch_value));
7845 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7853 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7860 /*******************************************************************
7861 reads or writes a structure.
7862 ********************************************************************/
7864 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7865 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7867 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7869 q_u->domain_pol = *domain_pol;
7870 q_u->switch_value0 = switch_value;
7872 q_u->switch_value = switch_value;
7877 /*******************************************************************
7878 reads or writes a structure.
7879 ********************************************************************/
7881 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7882 prs_struct *ps, int depth)
7887 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7893 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7896 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7899 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7905 if (UNMARSHALLING(ps)) {
7906 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7910 switch (q_u->switch_value) {
7913 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7917 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7921 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7925 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7929 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7933 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7937 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7941 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7942 q_u->switch_value));
7949 /*******************************************************************
7950 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7951 ********************************************************************/
7953 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7955 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7957 r_u->status = status; /* return status */
7960 /*******************************************************************
7961 reads or writes a structure.
7962 ********************************************************************/
7964 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7965 prs_struct *ps, int depth)
7970 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7976 if(!prs_ntstatus("status", ps, depth, &r_u->status))