2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Paul Ashton 1997-2000,
7 * Copyright (C) Elrond 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Jean François Micouleau 1998-2001,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #define DBGC_CLASS DBGC_RPC_PARSE
32 /*******************************************************************
33 inits a SAMR_Q_CLOSE_HND structure.
34 ********************************************************************/
36 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
38 DEBUG(5, ("init_samr_q_close_hnd\n"));
43 /*******************************************************************
44 reads or writes a structure.
45 ********************************************************************/
47 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
48 prs_struct *ps, int depth)
53 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
59 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
62 /*******************************************************************
63 reads or writes a structure.
64 ********************************************************************/
66 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
67 prs_struct *ps, int depth)
72 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
78 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
81 if(!prs_ntstatus("status", ps, depth, &r_u->status))
87 /*******************************************************************
88 inits a SAMR_Q_LOOKUP_DOMAIN structure.
89 ********************************************************************/
91 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
92 POLICY_HND *pol, char *dom_name)
94 DEBUG(5, ("init_samr_q_lookup_domain\n"));
96 q_u->connect_pol = *pol;
98 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
99 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
102 /*******************************************************************
103 reads or writes a structure.
104 ********************************************************************/
105 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
106 prs_struct *ps, int depth)
111 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
117 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
120 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
123 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
129 /*******************************************************************
130 inits a SAMR_R_LOOKUP_DOMAIN structure.
131 ********************************************************************/
133 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
134 DOM_SID *dom_sid, NTSTATUS status)
136 DEBUG(5, ("init_samr_r_lookup_domain\n"));
138 r_u->status = status;
140 if (NT_STATUS_IS_OK(status)) {
142 init_dom_sid2(&r_u->dom_sid, dom_sid);
146 /*******************************************************************
147 reads or writes a structure.
148 ********************************************************************/
150 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
151 prs_struct *ps, int depth)
156 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
162 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
165 if (r_u->ptr_sid != 0) {
166 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
172 if(!prs_ntstatus("status", ps, depth, &r_u->status))
178 /*******************************************************************
179 reads or writes a structure.
180 ********************************************************************/
182 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
184 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
186 q_u->dom_pol = *dom_pol;
187 init_dom_sid2(&q_u->sid, sid);
190 /*******************************************************************
191 reads or writes a structure.
192 ********************************************************************/
194 BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
195 prs_struct *ps, int depth)
200 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
206 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
209 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
218 /*******************************************************************
219 reads or writes a structure.
220 ********************************************************************/
222 BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
223 prs_struct *ps, int depth)
228 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
234 if(!prs_ntstatus("status", ps, depth, &r_u->status))
240 /*******************************************************************
241 reads or writes a structure.
242 ********************************************************************/
244 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
245 POLICY_HND *pol, uint32 flags,
248 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
252 init_dom_sid2(&q_u->dom_sid, sid);
255 /*******************************************************************
256 reads or writes a structure.
257 ********************************************************************/
259 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
260 prs_struct *ps, int depth)
265 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
271 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
274 if(!prs_uint32("flags", ps, depth, &q_u->flags))
277 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
283 /*******************************************************************
284 reads or writes a structure.
285 ********************************************************************/
287 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
288 prs_struct *ps, int depth)
293 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
299 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
302 if(!prs_ntstatus("status", ps, depth, &r_u->status))
308 /*******************************************************************
309 reads or writes a structure.
310 ********************************************************************/
312 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
313 POLICY_HND *user_pol)
315 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
317 q_u->user_pol = *user_pol;
320 /*******************************************************************
321 reads or writes a structure.
322 ********************************************************************/
324 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
325 prs_struct *ps, int depth)
330 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
336 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
339 /*******************************************************************
341 ********************************************************************/
343 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
345 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
347 r_u->min_pwd_length = 0x0000;
351 * r_u->unknown_1 = 0x0015;
354 r_u->unknown_1 = 0x01D1;
355 r_u->unknown_1 = 0x0015;
357 r_u->password_properties = 0x00000000;
359 r_u->status = status;
362 /*******************************************************************
363 reads or writes a structure.
364 ********************************************************************/
366 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
367 prs_struct *ps, int depth)
372 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
378 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
380 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
382 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
385 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
392 /*******************************************************************
393 reads or writes a structure.
394 ********************************************************************/
396 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
397 prs_struct *ps, int depth)
402 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
408 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
411 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
414 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
421 /*******************************************************************
422 reads or writes a structure.
423 ********************************************************************/
425 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
426 POLICY_HND *user_pol, uint32 sec_info)
428 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
430 q_u->user_pol = *user_pol;
431 q_u->sec_info = sec_info;
435 /*******************************************************************
436 reads or writes a structure.
437 ********************************************************************/
439 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
440 prs_struct *ps, int depth)
445 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
451 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
454 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
460 /*******************************************************************
461 reads or writes a structure.
462 ********************************************************************/
464 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
465 POLICY_HND *domain_pol, uint16 switch_value)
467 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
469 q_u->domain_pol = *domain_pol;
470 q_u->switch_value = switch_value;
473 /*******************************************************************
474 reads or writes a structure.
475 ********************************************************************/
477 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
478 prs_struct *ps, int depth)
483 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
489 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
492 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
499 /*******************************************************************
501 ********************************************************************/
503 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
505 u_3->logout.low = nt_logout.low;
506 u_3->logout.high = nt_logout.high;
509 /*******************************************************************
510 reads or writes a structure.
511 ********************************************************************/
513 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
514 prs_struct *ps, int depth)
519 prs_debug(ps, depth, desc, "sam_io_unk_info3");
522 if(!smb_io_time("logout", &u_3->logout, ps, depth))
528 /*******************************************************************
530 ********************************************************************/
532 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
534 u_6->unknown_0 = 0x00000000;
536 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
539 /*******************************************************************
540 reads or writes a structure.
541 ********************************************************************/
543 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
544 prs_struct *ps, int depth)
549 prs_debug(ps, depth, desc, "sam_io_unk_info6");
552 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
554 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
556 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
562 /*******************************************************************
564 ********************************************************************/
566 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
568 u_7->server_role = server_role;
571 /*******************************************************************
572 reads or writes a structure.
573 ********************************************************************/
575 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
576 prs_struct *ps, int depth)
581 prs_debug(ps, depth, desc, "sam_io_unk_info7");
584 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
590 /*******************************************************************
592 ********************************************************************/
594 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
596 unix_to_nt_time(&u_8->domain_create_time, 0);
597 u_8->seq_num.low = seq_num;
598 u_8->seq_num.high = 0x0000;
601 /*******************************************************************
602 reads or writes a structure.
603 ********************************************************************/
605 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
606 prs_struct *ps, int depth)
611 prs_debug(ps, depth, desc, "sam_io_unk_info8");
614 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
617 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
624 /*******************************************************************
626 ********************************************************************/
628 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
630 u_12->duration.low = nt_lock_duration.low;
631 u_12->duration.high = nt_lock_duration.high;
632 u_12->reset_count.low = nt_reset_time.low;
633 u_12->reset_count.high = nt_reset_time.high;
635 u_12->bad_attempt_lockout = lockout;
638 /*******************************************************************
639 reads or writes a structure.
640 ********************************************************************/
642 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
643 prs_struct *ps, int depth)
648 prs_debug(ps, depth, desc, "sam_io_unk_info12");
651 if(!smb_io_time("duration", &u_12->duration, ps, depth))
653 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
655 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
661 /*******************************************************************
663 ********************************************************************/
665 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
667 init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE);
668 init_uni_hdr(&u_5->hdr_server, &u_5->uni_server);
671 /*******************************************************************
672 reads or writes a structure.
673 ********************************************************************/
675 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
676 prs_struct *ps, int depth)
681 prs_debug(ps, depth, desc, "sam_io_unk_info5");
684 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
687 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
693 /*******************************************************************
695 ********************************************************************/
697 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
698 const char *comment, const char *domain, const char *server,
699 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
701 u_2->logout.low = nt_logout.low;
702 u_2->logout.high = nt_logout.high;
704 u_2->seq_num.low = seq_num;
705 u_2->seq_num.high = 0x00000000;
708 u_2->unknown_4 = 0x00000001;
709 u_2->server_role = server_role;
710 u_2->unknown_6 = 0x00000001;
711 u_2->num_domain_usrs = num_users;
712 u_2->num_domain_grps = num_groups;
713 u_2->num_local_grps = num_alias;
715 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
717 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
718 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
719 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
720 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
721 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
722 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
725 /*******************************************************************
726 reads or writes a structure.
727 ********************************************************************/
729 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
730 prs_struct *ps, int depth)
735 prs_debug(ps, depth, desc, "sam_io_unk_info2");
738 if(!smb_io_time("logout", &u_2->logout, ps, depth))
740 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
742 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
744 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
747 /* put all the data in here, at the moment, including what the above
748 pointer is referring to
751 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
754 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
756 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
758 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
760 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
762 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
764 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
767 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
769 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
771 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
777 /*******************************************************************
779 ********************************************************************/
781 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
782 uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
784 u_1->min_length_password = min_pass_len;
785 u_1->password_history = pass_hist;
786 u_1->password_properties = password_properties;
788 /* password never expire */
789 u_1->expire.high = nt_expire.high;
790 u_1->expire.low = nt_expire.low;
792 /* can change the password now */
793 u_1->min_passwordage.high = nt_min_age.high;
794 u_1->min_passwordage.low = nt_min_age.low;
798 /*******************************************************************
799 reads or writes a structure.
800 ********************************************************************/
802 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
803 prs_struct *ps, int depth)
808 prs_debug(ps, depth, desc, "sam_io_unk_info1");
811 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
813 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
815 if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
817 if(!smb_io_time("expire", &u_1->expire, ps, depth))
819 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
825 /*******************************************************************
826 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
827 ********************************************************************/
829 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
830 uint16 switch_value, SAM_UNK_CTR * ctr,
833 DEBUG(5, ("init_samr_r_query_dom_info\n"));
836 r_u->switch_value = 0;
837 r_u->status = status; /* return status */
839 if (NT_STATUS_IS_OK(status)) {
840 r_u->switch_value = switch_value;
846 /*******************************************************************
847 reads or writes a structure.
848 ********************************************************************/
850 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
851 prs_struct *ps, int depth)
856 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
862 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
865 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
866 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
871 switch (r_u->switch_value) {
873 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
877 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
881 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
885 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
889 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
893 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
897 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
901 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
905 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
907 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
921 /*******************************************************************
922 reads or writes a SAMR_R_SET_SEC_OBJ structure.
923 ********************************************************************/
925 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
926 prs_struct *ps, int depth)
931 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
937 if(!prs_ntstatus("status", ps, depth, &r_u->status))
943 /*******************************************************************
944 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
945 ********************************************************************/
947 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
948 prs_struct *ps, int depth)
953 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
959 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
962 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
966 if(!prs_ntstatus("status", ps, depth, &r_u->status))
972 /*******************************************************************
973 reads or writes a SAM_STR1 structure.
974 ********************************************************************/
976 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
977 uint32 name_buf, uint32 desc_buf,
978 prs_struct *ps, int depth)
983 prs_debug(ps, depth, desc, "sam_io_sam_str1");
988 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
991 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
994 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1000 /*******************************************************************
1001 inits a SAM_ENTRY1 structure.
1002 ********************************************************************/
1004 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1005 UNISTR2 *sam_name, UNISTR2 *sam_full,
1006 UNISTR2 *sam_desc, uint32 rid_user,
1009 DEBUG(5, ("init_sam_entry1\n"));
1013 sam->user_idx = user_idx;
1014 sam->rid_user = rid_user;
1015 sam->acb_info = acb_info;
1017 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1018 init_uni_hdr(&sam->hdr_user_name, sam_full);
1019 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1022 /*******************************************************************
1023 reads or writes a SAM_ENTRY1 structure.
1024 ********************************************************************/
1026 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1027 prs_struct *ps, int depth)
1032 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1038 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1041 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1043 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1046 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1048 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1050 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1056 /*******************************************************************
1057 reads or writes a SAM_STR2 structure.
1058 ********************************************************************/
1060 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1061 uint32 desc_buf, prs_struct *ps, int depth)
1066 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1072 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1074 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1080 /*******************************************************************
1081 inits a SAM_ENTRY2 structure.
1082 ********************************************************************/
1083 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1084 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1085 uint32 rid_user, uint32 acb_info)
1087 DEBUG(5, ("init_sam_entry2\n"));
1089 sam->user_idx = user_idx;
1090 sam->rid_user = rid_user;
1091 sam->acb_info = acb_info;
1093 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1094 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1097 /*******************************************************************
1098 reads or writes a SAM_ENTRY2 structure.
1099 ********************************************************************/
1101 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1102 prs_struct *ps, int depth)
1107 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1113 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1116 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1118 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1121 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1123 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1129 /*******************************************************************
1130 reads or writes a SAM_STR3 structure.
1131 ********************************************************************/
1133 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1134 uint32 desc_buf, prs_struct *ps, int depth)
1139 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1145 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1147 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1153 /*******************************************************************
1154 inits a SAM_ENTRY3 structure.
1155 ********************************************************************/
1157 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1158 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1161 DEBUG(5, ("init_sam_entry3\n"));
1163 sam->grp_idx = grp_idx;
1164 sam->rid_grp = rid_grp;
1165 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1167 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1168 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1171 /*******************************************************************
1172 reads or writes a SAM_ENTRY3 structure.
1173 ********************************************************************/
1175 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1176 prs_struct *ps, int depth)
1181 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1187 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1190 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1192 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1195 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1197 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1203 /*******************************************************************
1204 inits a SAM_ENTRY4 structure.
1205 ********************************************************************/
1207 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1208 uint32 len_acct_name)
1210 DEBUG(5, ("init_sam_entry4\n"));
1212 sam->user_idx = user_idx;
1213 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1216 /*******************************************************************
1217 reads or writes a SAM_ENTRY4 structure.
1218 ********************************************************************/
1220 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1221 prs_struct *ps, int depth)
1226 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1232 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1234 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1240 /*******************************************************************
1241 inits a SAM_ENTRY5 structure.
1242 ********************************************************************/
1244 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1245 uint32 len_grp_name)
1247 DEBUG(5, ("init_sam_entry5\n"));
1249 sam->grp_idx = grp_idx;
1250 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1254 /*******************************************************************
1255 reads or writes a SAM_ENTRY5 structure.
1256 ********************************************************************/
1258 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1259 prs_struct *ps, int depth)
1264 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1270 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1272 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1278 /*******************************************************************
1279 inits a SAM_ENTRY structure.
1280 ********************************************************************/
1282 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1284 DEBUG(10, ("init_sam_entry: %d\n", rid));
1287 init_uni_hdr(&sam->hdr_name, uni2);
1290 /*******************************************************************
1291 reads or writes a SAM_ENTRY structure.
1292 ********************************************************************/
1294 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1295 prs_struct *ps, int depth)
1300 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1305 if(!prs_uint32("rid", ps, depth, &sam->rid))
1307 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1313 /*******************************************************************
1314 inits a SAMR_Q_ENUM_DOM_USERS structure.
1315 ********************************************************************/
1317 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1319 uint32 acb_mask, uint32 size)
1321 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1325 q_e->start_idx = start_idx; /* zero indicates lots */
1326 q_e->acb_mask = acb_mask;
1327 q_e->max_size = size;
1330 /*******************************************************************
1331 reads or writes a structure.
1332 ********************************************************************/
1334 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1335 prs_struct *ps, int depth)
1340 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1346 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1349 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1351 if(!prs_uint32("acb_mask ", ps, depth, &q_e->acb_mask))
1354 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1361 /*******************************************************************
1362 inits a SAMR_R_ENUM_DOM_USERS structure.
1363 ********************************************************************/
1365 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1366 uint32 next_idx, uint32 num_sam_entries)
1368 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1370 r_u->next_idx = next_idx;
1372 if (num_sam_entries != 0) {
1373 r_u->ptr_entries1 = 1;
1374 r_u->ptr_entries2 = 1;
1375 r_u->num_entries2 = num_sam_entries;
1376 r_u->num_entries3 = num_sam_entries;
1378 r_u->num_entries4 = num_sam_entries;
1380 r_u->ptr_entries1 = 0;
1381 r_u->num_entries2 = num_sam_entries;
1382 r_u->ptr_entries2 = 1;
1386 /*******************************************************************
1387 reads or writes a structure.
1388 ********************************************************************/
1390 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1391 prs_struct *ps, int depth)
1398 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1404 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1406 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1409 if (r_u->ptr_entries1 != 0) {
1410 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1412 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1414 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1417 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1418 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1419 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1422 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1423 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1424 r_u->num_entries4 = 0;
1425 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1429 for (i = 0; i < r_u->num_entries2; i++) {
1430 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1434 for (i = 0; i < r_u->num_entries2; i++) {
1435 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1444 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1446 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1452 /*******************************************************************
1453 inits a SAMR_Q_QUERY_DISPINFO structure.
1454 ********************************************************************/
1456 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1457 uint16 switch_level, uint32 start_idx,
1458 uint32 max_entries, uint32 max_size)
1460 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1462 q_e->domain_pol = *pol;
1464 q_e->switch_level = switch_level;
1466 q_e->start_idx = start_idx;
1467 q_e->max_entries = max_entries;
1468 q_e->max_size = max_size;
1471 /*******************************************************************
1472 reads or writes a structure.
1473 ********************************************************************/
1475 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1476 prs_struct *ps, int depth)
1481 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1487 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1490 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1495 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1497 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1499 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1505 /*******************************************************************
1506 inits a SAM_DISPINFO_1 structure.
1507 ********************************************************************/
1509 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1510 uint32 num_entries, uint32 start_idx,
1511 struct samr_displayentry *entries)
1515 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1518 return NT_STATUS_OK;
1520 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1522 return NT_STATUS_NO_MEMORY;
1524 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1525 if ((*sam)->sam == NULL)
1526 return NT_STATUS_NO_MEMORY;
1528 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1529 if ((*sam)->str == NULL)
1530 return NT_STATUS_NO_MEMORY;
1532 for (i = 0; i < num_entries ; i++) {
1533 init_unistr2(&(*sam)->str[i].uni_acct_name,
1534 entries[i].account_name, UNI_FLAGS_NONE);
1535 init_unistr2(&(*sam)->str[i].uni_full_name,
1536 entries[i].fullname, UNI_FLAGS_NONE);
1537 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1538 entries[i].description, UNI_FLAGS_NONE);
1540 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1541 &(*sam)->str[i].uni_acct_name,
1542 &(*sam)->str[i].uni_full_name,
1543 &(*sam)->str[i].uni_acct_desc,
1544 entries[i].rid, entries[i].acct_flags);
1547 return NT_STATUS_OK;
1550 /*******************************************************************
1551 reads or writes a structure.
1552 ********************************************************************/
1554 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1556 prs_struct *ps, int depth)
1560 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1566 if (UNMARSHALLING(ps) && num_entries > 0) {
1568 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1569 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1573 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1574 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1579 for (i = 0; i < num_entries; i++) {
1580 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1584 for (i = 0; i < num_entries; i++) {
1585 if(!sam_io_sam_str1("", &sam->str[i],
1586 sam->sam[i].hdr_acct_name.buffer,
1587 sam->sam[i].hdr_user_name.buffer,
1588 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1595 /*******************************************************************
1596 inits a SAM_DISPINFO_2 structure.
1597 ********************************************************************/
1599 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1600 uint32 num_entries, uint32 start_idx,
1601 struct samr_displayentry *entries)
1605 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1608 return NT_STATUS_OK;
1610 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1612 return NT_STATUS_NO_MEMORY;
1614 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1615 if ((*sam)->sam == NULL)
1616 return NT_STATUS_NO_MEMORY;
1618 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1619 if ((*sam)->str == NULL)
1620 return NT_STATUS_NO_MEMORY;
1622 for (i = 0; i < num_entries; i++) {
1623 init_unistr2(&(*sam)->str[i].uni_srv_name,
1624 entries[i].account_name, UNI_FLAGS_NONE);
1625 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1626 entries[i].description, UNI_FLAGS_NONE);
1628 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1629 &(*sam)->str[i].uni_srv_name,
1630 &(*sam)->str[i].uni_srv_desc,
1631 entries[i].rid, entries[i].acct_flags);
1634 return NT_STATUS_OK;
1637 /*******************************************************************
1638 reads or writes a structure.
1639 ********************************************************************/
1641 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1643 prs_struct *ps, int depth)
1650 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1656 if (UNMARSHALLING(ps) && num_entries > 0) {
1658 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1659 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1663 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1664 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1669 for (i = 0; i < num_entries; i++) {
1670 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1674 for (i = 0; i < num_entries; i++) {
1675 if(!sam_io_sam_str2("", &sam->str[i],
1676 sam->sam[i].hdr_srv_name.buffer,
1677 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1684 /*******************************************************************
1685 inits a SAM_DISPINFO_3 structure.
1686 ********************************************************************/
1688 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1689 uint32 num_entries, uint32 start_idx,
1690 struct samr_displayentry *entries)
1694 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1697 return NT_STATUS_OK;
1699 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1701 return NT_STATUS_NO_MEMORY;
1703 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1704 return NT_STATUS_NO_MEMORY;
1706 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1707 return NT_STATUS_NO_MEMORY;
1709 for (i = 0; i < num_entries; i++) {
1710 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1712 init_unistr2(&(*sam)->str[i].uni_grp_name,
1713 entries[i].account_name, UNI_FLAGS_NONE);
1714 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1715 entries[i].description, UNI_FLAGS_NONE);
1717 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1718 &(*sam)->str[i].uni_grp_name,
1719 &(*sam)->str[i].uni_grp_desc,
1723 return NT_STATUS_OK;
1726 /*******************************************************************
1727 reads or writes a structure.
1728 ********************************************************************/
1730 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1732 prs_struct *ps, int depth)
1739 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1745 if (UNMARSHALLING(ps) && num_entries > 0) {
1747 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1748 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1752 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1753 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1758 for (i = 0; i < num_entries; i++) {
1759 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1763 for (i = 0; i < num_entries; i++) {
1764 if(!sam_io_sam_str3("", &sam->str[i],
1765 sam->sam[i].hdr_grp_name.buffer,
1766 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1773 /*******************************************************************
1774 inits a SAM_DISPINFO_4 structure.
1775 ********************************************************************/
1777 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1778 uint32 num_entries, uint32 start_idx,
1779 struct samr_displayentry *entries)
1783 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1786 return NT_STATUS_OK;
1788 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1790 return NT_STATUS_NO_MEMORY;
1792 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1793 if ((*sam)->sam == NULL)
1794 return NT_STATUS_NO_MEMORY;
1796 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1797 if ((*sam)->str == NULL)
1798 return NT_STATUS_NO_MEMORY;
1800 for (i = 0; i < num_entries; i++) {
1801 size_t len_sam_name = strlen(entries[i].account_name);
1803 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1805 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1808 init_string2(&(*sam)->str[i].acct_name,
1809 entries[i].account_name, len_sam_name+1,
1813 return NT_STATUS_OK;
1816 /*******************************************************************
1817 reads or writes a structure.
1818 ********************************************************************/
1820 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1822 prs_struct *ps, int depth)
1829 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1835 if (UNMARSHALLING(ps) && num_entries > 0) {
1837 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1838 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1842 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1843 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1848 for (i = 0; i < num_entries; i++) {
1849 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1853 for (i = 0; i < num_entries; i++) {
1854 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1855 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1862 /*******************************************************************
1863 inits a SAM_DISPINFO_5 structure.
1864 ********************************************************************/
1866 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1867 uint32 num_entries, uint32 start_idx,
1868 struct samr_displayentry *entries)
1870 uint32 len_sam_name;
1873 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1876 return NT_STATUS_OK;
1878 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1880 return NT_STATUS_NO_MEMORY;
1882 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1883 return NT_STATUS_NO_MEMORY;
1885 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1886 return NT_STATUS_NO_MEMORY;
1888 for (i = 0; i < num_entries; i++) {
1889 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1891 len_sam_name = strlen(entries[i].account_name);
1893 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
1894 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
1895 len_sam_name+1, len_sam_name);
1898 return NT_STATUS_OK;
1901 /*******************************************************************
1902 reads or writes a structure.
1903 ********************************************************************/
1905 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1907 prs_struct *ps, int depth)
1914 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1920 if (UNMARSHALLING(ps) && num_entries > 0) {
1922 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1923 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1927 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1928 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1933 for (i = 0; i < num_entries; i++) {
1934 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1938 for (i = 0; i < num_entries; i++) {
1939 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1940 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1947 /*******************************************************************
1948 inits a SAMR_R_QUERY_DISPINFO structure.
1949 ********************************************************************/
1951 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1952 uint32 num_entries, uint32 total_size, uint32 data_size,
1953 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1956 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1958 r_u->total_size = total_size;
1960 r_u->data_size = data_size;
1962 r_u->switch_level = switch_level;
1963 r_u->num_entries = num_entries;
1966 r_u->ptr_entries = 0;
1968 r_u->ptr_entries = 1;
1970 r_u->num_entries2 = num_entries;
1973 r_u->status = status;
1976 /*******************************************************************
1977 reads or writes a structure.
1978 ********************************************************************/
1980 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1981 prs_struct *ps, int depth)
1986 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
1992 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
1994 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
1996 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2001 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2003 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2006 if (r_u->ptr_entries==0) {
2009 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2015 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2018 switch (r_u->switch_level) {
2020 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2021 r_u->num_entries, ps, depth))
2025 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2026 r_u->num_entries, ps, depth))
2030 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2031 r_u->num_entries, ps, depth))
2035 if(!sam_io_sam_dispinfo_4("user list",
2036 r_u->ctr->sam.info4,
2037 r_u->num_entries, ps, depth))
2041 if(!sam_io_sam_dispinfo_5("group list",
2042 r_u->ctr->sam.info5,
2043 r_u->num_entries, ps, depth))
2047 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2053 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2059 /*******************************************************************
2060 inits a SAMR_Q_OPEN_GROUP structure.
2061 ********************************************************************/
2063 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2065 uint32 access_mask, uint32 rid)
2067 DEBUG(5, ("init_samr_q_open_group\n"));
2069 q_c->domain_pol = *hnd;
2070 q_c->access_mask = access_mask;
2071 q_c->rid_group = rid;
2074 /*******************************************************************
2075 reads or writes a structure.
2076 ********************************************************************/
2078 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2079 prs_struct *ps, int depth)
2084 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2090 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2093 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2095 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2101 /*******************************************************************
2102 reads or writes a structure.
2103 ********************************************************************/
2105 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2106 prs_struct *ps, int depth)
2111 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2117 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2120 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2126 /*******************************************************************
2127 inits a GROUP_INFO1 structure.
2128 ********************************************************************/
2130 void init_samr_group_info1(GROUP_INFO1 * gr1,
2131 char *acct_name, char *acct_desc,
2134 DEBUG(5, ("init_samr_group_info1\n"));
2136 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2137 gr1->num_members = num_members;
2139 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2140 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2141 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2142 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2145 /*******************************************************************
2146 reads or writes a structure.
2147 ********************************************************************/
2149 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2150 prs_struct *ps, int depth)
2157 prs_debug(ps, depth, desc, "samr_io_group_info1");
2160 if(!prs_uint16("level", ps, depth, &dummy))
2166 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2169 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2171 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2174 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2177 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2178 gr1->hdr_acct_name.buffer, ps, depth))
2181 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2182 gr1->hdr_acct_desc.buffer, ps, depth))
2188 /*******************************************************************
2189 inits a GROUP_INFO2 structure.
2190 ********************************************************************/
2192 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2194 DEBUG(5, ("init_samr_group_info2\n"));
2197 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2198 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2201 /*******************************************************************
2202 reads or writes a structure.
2203 ********************************************************************/
2205 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2210 prs_debug(ps, depth, desc, "samr_io_group_info2");
2213 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2216 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2218 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2219 gr2->hdr_acct_name.buffer, ps, depth))
2225 /*******************************************************************
2226 inits a GROUP_INFO3 structure.
2227 ********************************************************************/
2229 void init_samr_group_info3(GROUP_INFO3 *gr3)
2231 DEBUG(5, ("init_samr_group_info3\n"));
2233 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2236 /*******************************************************************
2237 reads or writes a structure.
2238 ********************************************************************/
2240 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2245 prs_debug(ps, depth, desc, "samr_io_group_info3");
2251 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2257 /*******************************************************************
2258 inits a GROUP_INFO4 structure.
2259 ********************************************************************/
2261 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2263 DEBUG(5, ("init_samr_group_info4\n"));
2266 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2267 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2270 /*******************************************************************
2271 reads or writes a structure.
2272 ********************************************************************/
2274 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2275 prs_struct *ps, int depth)
2280 prs_debug(ps, depth, desc, "samr_io_group_info4");
2283 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2285 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2287 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2288 gr4->hdr_acct_desc.buffer, ps, depth))
2294 /*******************************************************************
2295 reads or writes a structure.
2296 ********************************************************************/
2298 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2299 prs_struct *ps, int depth)
2301 if (UNMARSHALLING(ps))
2302 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2307 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2310 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2313 switch ((*ctr)->switch_value1) {
2315 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2319 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2323 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2327 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2331 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2338 /*******************************************************************
2339 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2340 ********************************************************************/
2342 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2343 POLICY_HND *pol, const char *acct_desc,
2346 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2350 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2351 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2353 q_e->access_mask = access_mask;
2356 /*******************************************************************
2357 reads or writes a structure.
2358 ********************************************************************/
2360 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2361 prs_struct *ps, int depth)
2366 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2372 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2375 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2377 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2378 q_e->hdr_acct_desc.buffer, ps, depth))
2383 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2389 /*******************************************************************
2390 reads or writes a structure.
2391 ********************************************************************/
2393 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2394 prs_struct *ps, int depth)
2399 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2405 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2408 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2410 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2416 /*******************************************************************
2417 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2418 ********************************************************************/
2420 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2423 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2425 q_c->group_pol = *hnd;
2428 /*******************************************************************
2429 reads or writes a structure.
2430 ********************************************************************/
2432 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2433 prs_struct *ps, int depth)
2438 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2444 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2450 /*******************************************************************
2451 reads or writes a structure.
2452 ********************************************************************/
2454 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2455 prs_struct *ps, int depth)
2460 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2466 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2469 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2475 /*******************************************************************
2476 inits a SAMR_Q_DEL_GROUPMEM structure.
2477 ********************************************************************/
2479 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2480 POLICY_HND *pol, uint32 rid)
2482 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2488 /*******************************************************************
2489 reads or writes a structure.
2490 ********************************************************************/
2492 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2493 prs_struct *ps, int depth)
2498 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2504 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2507 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2513 /*******************************************************************
2514 inits a SAMR_R_DEL_GROUPMEM structure.
2515 ********************************************************************/
2517 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2520 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2522 r_u->status = status;
2525 /*******************************************************************
2526 reads or writes a structure.
2527 ********************************************************************/
2529 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2530 prs_struct *ps, int depth)
2535 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2541 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2547 /*******************************************************************
2548 inits a SAMR_Q_ADD_GROUPMEM structure.
2549 ********************************************************************/
2551 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2552 POLICY_HND *pol, uint32 rid)
2554 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2558 q_e->unknown = 0x0005;
2561 /*******************************************************************
2562 reads or writes a structure.
2563 ********************************************************************/
2565 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2566 prs_struct *ps, int depth)
2571 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2577 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2580 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2582 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2588 /*******************************************************************
2589 inits a SAMR_R_ADD_GROUPMEM structure.
2590 ********************************************************************/
2592 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2595 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2597 r_u->status = status;
2600 /*******************************************************************
2601 reads or writes a structure.
2602 ********************************************************************/
2604 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2605 prs_struct *ps, int depth)
2610 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2616 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2622 /*******************************************************************
2623 inits a SAMR_Q_SET_GROUPINFO structure.
2624 ********************************************************************/
2626 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2627 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2629 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2635 /*******************************************************************
2636 reads or writes a structure.
2637 ********************************************************************/
2639 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2640 prs_struct *ps, int depth)
2645 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2651 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2654 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2660 /*******************************************************************
2661 inits a SAMR_R_SET_GROUPINFO structure.
2662 ********************************************************************/
2664 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2666 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2668 r_u->status = status;
2671 /*******************************************************************
2672 reads or writes a structure.
2673 ********************************************************************/
2675 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2676 prs_struct *ps, int depth)
2681 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2687 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2693 /*******************************************************************
2694 inits a SAMR_Q_QUERY_GROUPINFO structure.
2695 ********************************************************************/
2697 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2698 POLICY_HND *pol, uint16 switch_level)
2700 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2704 q_e->switch_level = switch_level;
2707 /*******************************************************************
2708 reads or writes a structure.
2709 ********************************************************************/
2711 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2712 prs_struct *ps, int depth)
2717 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2723 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2726 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2732 /*******************************************************************
2733 inits a SAMR_R_QUERY_GROUPINFO structure.
2734 ********************************************************************/
2736 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2737 GROUP_INFO_CTR * ctr, NTSTATUS status)
2739 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2741 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2743 r_u->status = status;
2746 /*******************************************************************
2747 reads or writes a structure.
2748 ********************************************************************/
2750 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2751 prs_struct *ps, int depth)
2756 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2762 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2765 if (r_u->ptr != 0) {
2766 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2772 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2778 /*******************************************************************
2779 inits a SAMR_Q_QUERY_GROUPMEM structure.
2780 ********************************************************************/
2782 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2784 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2786 q_c->group_pol = *hnd;
2789 /*******************************************************************
2790 reads or writes a structure.
2791 ********************************************************************/
2793 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2794 prs_struct *ps, int depth)
2799 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2805 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2811 /*******************************************************************
2812 inits a SAMR_R_QUERY_GROUPMEM structure.
2813 ********************************************************************/
2815 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2816 uint32 num_entries, uint32 *rid,
2817 uint32 *attr, NTSTATUS status)
2819 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2821 if (NT_STATUS_IS_OK(status)) {
2823 r_u->num_entries = num_entries;
2825 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2826 r_u->ptr_rids = rid != NULL ? 1 : 0;
2828 r_u->num_rids = num_entries;
2831 r_u->num_attrs = num_entries;
2835 r_u->num_entries = 0;
2838 r_u->status = status;
2841 /*******************************************************************
2842 reads or writes a structure.
2843 ********************************************************************/
2845 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2846 prs_struct *ps, int depth)
2853 if (UNMARSHALLING(ps))
2856 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2862 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2864 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2867 if (r_u->ptr != 0) {
2868 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2870 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2873 if (r_u->ptr_rids != 0) {
2874 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2876 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2877 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2878 if (r_u->rid == NULL)
2882 for (i = 0; i < r_u->num_rids; i++) {
2883 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2888 if (r_u->ptr_attrs != 0) {
2889 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2892 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2893 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2894 if (r_u->attr == NULL)
2898 for (i = 0; i < r_u->num_attrs; i++) {
2899 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2905 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2911 /*******************************************************************
2912 inits a SAMR_Q_QUERY_USERGROUPS structure.
2913 ********************************************************************/
2915 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2918 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2923 /*******************************************************************
2924 reads or writes a structure.
2925 ********************************************************************/
2927 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2928 prs_struct *ps, int depth)
2933 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2939 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2945 /*******************************************************************
2946 inits a SAMR_R_QUERY_USERGROUPS structure.
2947 ********************************************************************/
2949 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2950 uint32 num_gids, DOM_GID * gid,
2953 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2955 if (NT_STATUS_IS_OK(status)) {
2957 r_u->num_entries = num_gids;
2958 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2959 r_u->num_entries2 = num_gids;
2964 r_u->num_entries = 0;
2969 r_u->status = status;
2972 /*******************************************************************
2973 reads or writes a structure.
2974 ********************************************************************/
2976 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
2977 prs_struct *ps, int depth)
2983 prs_debug(ps, depth, desc, "samr_io_gids");
2989 if(!prs_uint32("num_gids", ps, depth, num_gids))
2992 if ((*num_gids) != 0) {
2993 if (UNMARSHALLING(ps)) {
2994 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
2997 if ((*gid) == NULL) {
3001 for (i = 0; i < (*num_gids); i++) {
3002 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3010 /*******************************************************************
3011 reads or writes a structure.
3012 ********************************************************************/
3014 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3015 prs_struct *ps, int depth)
3020 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3026 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3029 if (r_u->ptr_0 != 0) {
3030 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3032 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3035 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3036 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3043 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3049 /*******************************************************************
3050 inits a SAMR_Q_ENUM_DOMAINS structure.
3051 ********************************************************************/
3053 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3055 uint32 start_idx, uint32 size)
3057 DEBUG(5, ("init_samr_q_enum_domains\n"));
3061 q_e->start_idx = start_idx;
3062 q_e->max_size = size;
3065 /*******************************************************************
3066 reads or writes a structure.
3067 ********************************************************************/
3069 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3070 prs_struct *ps, int depth)
3075 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3081 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3084 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3086 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3092 /*******************************************************************
3093 inits a SAMR_R_ENUM_DOMAINS structure.
3094 ********************************************************************/
3096 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3097 uint32 next_idx, uint32 num_sam_entries)
3099 DEBUG(5, ("init_samr_r_enum_domains\n"));
3101 r_u->next_idx = next_idx;
3103 if (num_sam_entries != 0) {
3104 r_u->ptr_entries1 = 1;
3105 r_u->ptr_entries2 = 1;
3106 r_u->num_entries2 = num_sam_entries;
3107 r_u->num_entries3 = num_sam_entries;
3109 r_u->num_entries4 = num_sam_entries;
3111 r_u->ptr_entries1 = 0;
3112 r_u->num_entries2 = num_sam_entries;
3113 r_u->ptr_entries2 = 1;
3117 /*******************************************************************
3118 reads or writes a structure.
3119 ********************************************************************/
3121 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3122 prs_struct *ps, int depth)
3129 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3135 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3137 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3140 if (r_u->ptr_entries1 != 0) {
3141 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3143 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3145 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3148 if (UNMARSHALLING(ps)) {
3149 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3150 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3153 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3154 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3155 r_u->num_entries4 = 0;
3156 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3160 for (i = 0; i < r_u->num_entries2; i++) {
3162 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3163 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3167 for (i = 0; i < r_u->num_entries2; i++) {
3169 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3170 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3171 r_u->sam[i].hdr_name.buffer, ps,
3180 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3182 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3188 /*******************************************************************
3189 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3190 ********************************************************************/
3192 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3194 uint32 start_idx, uint32 size)
3196 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3200 q_e->start_idx = start_idx;
3201 q_e->max_size = size;
3204 /*******************************************************************
3205 reads or writes a structure.
3206 ********************************************************************/
3208 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3209 prs_struct *ps, int depth)
3214 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3220 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3223 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3225 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3231 /*******************************************************************
3232 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3233 ********************************************************************/
3235 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3236 uint32 next_idx, uint32 num_sam_entries)
3238 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3240 r_u->next_idx = next_idx;
3242 if (num_sam_entries != 0) {
3243 r_u->ptr_entries1 = 1;
3244 r_u->ptr_entries2 = 1;
3245 r_u->num_entries2 = num_sam_entries;
3246 r_u->num_entries3 = num_sam_entries;
3248 r_u->num_entries4 = num_sam_entries;
3250 r_u->ptr_entries1 = 0;
3251 r_u->num_entries2 = num_sam_entries;
3252 r_u->ptr_entries2 = 1;
3256 /*******************************************************************
3257 reads or writes a structure.
3258 ********************************************************************/
3260 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3261 prs_struct *ps, int depth)
3268 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3274 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3276 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3279 if (r_u->ptr_entries1 != 0) {
3280 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3282 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3284 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3287 if (UNMARSHALLING(ps)) {
3288 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3289 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3292 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3294 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3295 r_u->num_entries4 = 0;
3296 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3300 for (i = 0; i < r_u->num_entries2; i++) {
3301 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3305 for (i = 0; i < r_u->num_entries2; i++) {
3306 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3307 r_u->sam[i].hdr_name.buffer, ps, depth))
3314 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3316 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3322 /*******************************************************************
3323 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3324 ********************************************************************/
3326 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3327 POLICY_HND *pol, uint32 start_idx,
3330 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3334 q_e->start_idx = start_idx;
3335 q_e->max_size = size;
3339 /*******************************************************************
3340 reads or writes a structure.
3341 ********************************************************************/
3343 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3344 prs_struct *ps, int depth)
3349 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3355 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3358 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3360 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3366 /*******************************************************************
3367 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3368 ********************************************************************/
3370 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3372 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3374 r_u->next_idx = next_idx;
3376 if (num_sam_entries != 0) {
3377 r_u->ptr_entries1 = 1;
3378 r_u->ptr_entries2 = 1;
3379 r_u->num_entries2 = num_sam_entries;
3380 r_u->num_entries3 = num_sam_entries;
3382 r_u->num_entries4 = num_sam_entries;
3384 r_u->ptr_entries1 = 0;
3385 r_u->num_entries2 = num_sam_entries;
3386 r_u->ptr_entries2 = 1;
3390 /*******************************************************************
3391 reads or writes a structure.
3392 ********************************************************************/
3394 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3395 prs_struct *ps, int depth)
3402 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3408 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3410 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3413 if (r_u->ptr_entries1 != 0) {
3414 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3416 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3418 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3421 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3422 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3423 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3426 if (r_u->num_entries2 != 0 &&
3427 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3428 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3429 r_u->num_entries4 = 0;
3430 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3434 for (i = 0; i < r_u->num_entries2; i++) {
3435 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3439 for (i = 0; i < r_u->num_entries2; i++) {
3440 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3441 r_u->sam[i].hdr_name.buffer, ps,
3449 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3451 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3457 /*******************************************************************
3458 inits a ALIAS_INFO1 structure.
3459 ********************************************************************/
3461 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3463 DEBUG(5, ("init_samr_alias_info1\n"));
3465 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3466 al1->num_member = num_member;
3467 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3470 /*******************************************************************
3471 reads or writes a structure.
3472 ********************************************************************/
3474 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3475 prs_struct *ps, int depth)
3480 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3486 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3488 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3490 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3493 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3495 if ( !prs_align(ps) )
3497 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3499 if ( !prs_align(ps) )
3505 /*******************************************************************
3506 inits a ALIAS_INFO3 structure.
3507 ********************************************************************/
3509 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3511 DEBUG(5, ("init_samr_alias_info3\n"));
3513 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3516 /*******************************************************************
3517 reads or writes a structure.
3518 ********************************************************************/
3520 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3521 prs_struct *ps, int depth)
3526 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3532 if (!prs_unistr4("description", ps, depth, &al3->description))
3538 /*******************************************************************
3539 reads or writes a structure.
3540 ********************************************************************/
3542 BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3547 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3550 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3555 switch (ctr->level) {
3557 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3561 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3565 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3572 /*******************************************************************
3573 inits a SAMR_Q_QUERY_ALIASINFO structure.
3574 ********************************************************************/
3576 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3577 POLICY_HND *pol, uint32 switch_level)
3579 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3582 q_e->level = switch_level;
3585 /*******************************************************************
3586 reads or writes a structure.
3587 ********************************************************************/
3589 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3590 prs_struct *ps, int depth)
3595 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3601 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3604 if ( !prs_uint16("level", ps, depth, &in->level) )
3610 /*******************************************************************
3611 inits a SAMR_R_QUERY_ALIASINFO structure.
3612 ********************************************************************/
3614 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3615 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3617 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3620 out->status = status;
3623 /*******************************************************************
3624 reads or writes a structure.
3625 ********************************************************************/
3627 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3628 prs_struct *ps, int depth)
3633 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3639 if ( !prs_pointer("alias", ps, depth, (void**)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3644 if(!prs_ntstatus("status", ps, depth, &out->status))
3650 /*******************************************************************
3651 inits a SAMR_Q_SET_ALIASINFO structure.
3652 ********************************************************************/
3654 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3655 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3657 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3659 q_u->alias_pol = *hnd;
3663 /*******************************************************************
3664 reads or writes a structure.
3665 ********************************************************************/
3667 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3668 prs_struct *ps, int depth)
3673 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3679 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3681 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3687 /*******************************************************************
3688 reads or writes a structure.
3689 ********************************************************************/
3691 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3692 prs_struct *ps, int depth)
3697 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3702 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3708 /*******************************************************************
3709 inits a SAMR_Q_QUERY_USERALIASES structure.
3710 ********************************************************************/
3712 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3715 uint32 *ptr_sid, DOM_SID2 * sid)
3717 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3721 q_u->num_sids1 = num_sids;
3723 q_u->num_sids2 = num_sids;
3725 q_u->ptr_sid = ptr_sid;
3729 /*******************************************************************
3730 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3731 ********************************************************************/
3733 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3734 prs_struct *ps, int depth)
3742 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3748 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3751 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3753 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3759 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3762 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3763 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3764 if (q_u->ptr_sid == NULL)
3767 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3768 if (q_u->sid == NULL)
3772 for (i = 0; i < q_u->num_sids2; i++) {
3773 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3774 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3778 for (i = 0; i < q_u->num_sids2; i++) {
3779 if (q_u->ptr_sid[i] != 0) {
3780 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3781 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3789 /*******************************************************************
3790 inits a SAMR_R_QUERY_USERALIASES structure.
3791 ********************************************************************/
3793 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3794 uint32 num_rids, uint32 *rid,
3797 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3799 if (NT_STATUS_IS_OK(status)) {
3800 r_u->num_entries = num_rids;
3802 r_u->num_entries2 = num_rids;
3806 r_u->num_entries = 0;
3808 r_u->num_entries2 = 0;
3811 r_u->status = status;
3814 /*******************************************************************
3815 reads or writes a structure.
3816 ********************************************************************/
3818 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3819 prs_struct *ps, int depth)
3826 prs_debug(ps, depth, desc, "samr_io_rids");
3832 if(!prs_uint32("num_rids", ps, depth, num_rids))
3835 if ((*num_rids) != 0) {
3836 if (UNMARSHALLING(ps)) {
3838 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3843 for (i = 0; i < (*num_rids); i++) {
3844 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3845 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3853 /*******************************************************************
3854 reads or writes a structure.
3855 ********************************************************************/
3857 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3858 prs_struct *ps, int depth)
3863 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3869 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3871 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3874 if (r_u->ptr != 0) {
3875 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3881 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3887 /*******************************************************************
3888 inits a SAMR_Q_OPEN_ALIAS structure.
3889 ********************************************************************/
3891 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3892 uint32 access_mask, uint32 rid)
3894 DEBUG(5, ("init_samr_q_open_alias\n"));
3896 q_u->dom_pol = *pol;
3897 q_u->access_mask = access_mask;
3898 q_u->rid_alias = rid;
3901 /*******************************************************************
3902 reads or writes a structure.
3903 ********************************************************************/
3905 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3906 prs_struct *ps, int depth)
3911 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3917 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3920 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3922 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3928 /*******************************************************************
3929 reads or writes a structure.
3930 ********************************************************************/
3932 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
3933 prs_struct *ps, int depth)
3938 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3944 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3947 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3953 /*******************************************************************
3954 inits a SAMR_Q_LOOKUP_RIDS structure.
3955 ********************************************************************/
3957 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3958 POLICY_HND *pol, uint32 flags,
3959 uint32 num_rids, uint32 *rid)
3961 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3965 q_u->num_rids1 = num_rids;
3968 q_u->num_rids2 = num_rids;
3969 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
3970 if (q_u->rid == NULL) {
3974 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
3978 /*******************************************************************
3979 reads or writes a structure.
3980 ********************************************************************/
3982 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
3983 prs_struct *ps, int depth)
3991 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
3994 if (UNMARSHALLING(ps))
4000 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4003 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4005 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4007 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4009 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4012 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4013 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4014 if (q_u->rid == NULL)
4018 for (i = 0; i < q_u->num_rids2; i++) {
4019 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4020 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4027 /*******************************************************************
4028 inits a SAMR_R_LOOKUP_RIDS structure.
4029 ********************************************************************/
4031 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4032 uint32 num_names, UNIHDR * hdr_name,
4033 UNISTR2 *uni_name, uint32 *type)
4035 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4037 r_u->hdr_name = NULL;
4038 r_u->uni_name = NULL;
4041 if (num_names != 0) {
4042 r_u->num_names1 = num_names;
4044 r_u->num_names2 = num_names;
4046 r_u->num_types1 = num_names;
4048 r_u->num_types2 = num_names;
4050 r_u->hdr_name = hdr_name;
4051 r_u->uni_name = uni_name;
4054 r_u->num_names1 = num_names;
4056 r_u->num_names2 = num_names;
4058 r_u->num_types1 = num_names;
4060 r_u->num_types2 = num_names;
4064 /*******************************************************************
4065 reads or writes a structure.
4066 ********************************************************************/
4068 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4069 prs_struct *ps, int depth)
4076 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4082 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4084 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4087 if (r_u->ptr_names != 0) {
4089 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4093 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4094 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4095 if (r_u->hdr_name == NULL)
4098 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4099 if (r_u->uni_name == NULL)
4103 for (i = 0; i < r_u->num_names2; i++) {
4104 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4105 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4108 for (i = 0; i < r_u->num_names2; i++) {
4109 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4110 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4118 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4120 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4123 if (r_u->ptr_types != 0) {
4125 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4128 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4129 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4130 if (r_u->type == NULL)
4134 for (i = 0; i < r_u->num_types2; i++) {
4135 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4136 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4141 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4147 /*******************************************************************
4148 inits a SAMR_Q_OPEN_ALIAS structure.
4149 ********************************************************************/
4151 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4153 DEBUG(5, ("init_samr_q_delete_alias\n"));
4155 q_u->alias_pol = *hnd;
4158 /*******************************************************************
4159 reads or writes a structure.
4160 ********************************************************************/
4162 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4163 prs_struct *ps, int depth)
4168 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4174 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4180 /*******************************************************************
4181 reads or writes a structure.
4182 ********************************************************************/
4184 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4185 prs_struct *ps, int depth)
4190 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4196 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4198 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4204 /*******************************************************************
4205 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4206 ********************************************************************/
4208 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4209 POLICY_HND *hnd, const char *acct_desc)
4211 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4213 q_u->dom_pol = *hnd;
4215 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4216 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4218 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4221 /*******************************************************************
4222 reads or writes a structure.
4223 ********************************************************************/
4225 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4226 prs_struct *ps, int depth)
4231 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4237 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4240 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4242 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4243 q_u->hdr_acct_desc.buffer, ps, depth))
4248 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4254 /*******************************************************************
4255 reads or writes a structure.
4256 ********************************************************************/
4258 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4259 prs_struct *ps, int depth)
4264 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4270 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4273 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4276 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4282 /*******************************************************************
4283 inits a SAMR_Q_ADD_ALIASMEM structure.
4284 ********************************************************************/
4286 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4289 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4291 q_u->alias_pol = *hnd;
4292 init_dom_sid2(&q_u->sid, sid);
4295 /*******************************************************************
4296 reads or writes a structure.
4297 ********************************************************************/
4299 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4300 prs_struct *ps, int depth)
4305 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4311 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4313 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4319 /*******************************************************************
4320 reads or writes a structure.
4321 ********************************************************************/
4323 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4324 prs_struct *ps, int depth)
4329 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4335 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4341 /*******************************************************************
4342 inits a SAMR_Q_DEL_ALIASMEM structure.
4343 ********************************************************************/
4345 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4348 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4350 q_u->alias_pol = *hnd;
4351 init_dom_sid2(&q_u->sid, sid);
4354 /*******************************************************************
4355 reads or writes a structure.
4356 ********************************************************************/
4358 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4359 prs_struct *ps, int depth)
4364 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4370 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4372 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4378 /*******************************************************************
4379 reads or writes a structure.
4380 ********************************************************************/
4382 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4383 prs_struct *ps, int depth)
4388 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4394 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4400 /*******************************************************************
4401 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4402 ********************************************************************/
4404 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4407 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4409 q_c->alias_pol = *hnd;
4412 /*******************************************************************
4413 reads or writes a structure.
4414 ********************************************************************/
4416 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4417 prs_struct *ps, int depth)
4422 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4428 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4434 /*******************************************************************
4435 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4436 ********************************************************************/
4438 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4441 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4443 r_u->status = status;
4446 /*******************************************************************
4447 reads or writes a structure.
4448 ********************************************************************/
4450 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4451 prs_struct *ps, int depth)
4456 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4462 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4468 /*******************************************************************
4469 inits a SAMR_Q_QUERY_ALIASMEM structure.
4470 ********************************************************************/
4472 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4475 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4477 q_c->alias_pol = *hnd;
4480 /*******************************************************************
4481 reads or writes a structure.
4482 ********************************************************************/
4484 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4485 prs_struct *ps, int depth)
4490 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4496 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4502 /*******************************************************************
4503 inits a SAMR_R_QUERY_ALIASMEM structure.
4504 ********************************************************************/
4506 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4507 uint32 num_sids, DOM_SID2 * sid,
4510 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4512 if (NT_STATUS_IS_OK(status)) {
4513 r_u->num_sids = num_sids;
4514 r_u->ptr = (num_sids != 0) ? 1 : 0;
4515 r_u->num_sids1 = num_sids;
4523 r_u->status = status;
4526 /*******************************************************************
4527 reads or writes a structure.
4528 ********************************************************************/
4530 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4531 prs_struct *ps, int depth)
4538 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4544 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4546 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4549 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4550 uint32 *ptr_sid = NULL;
4552 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4555 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4560 for (i = 0; i < r_u->num_sids1; i++) {
4562 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4566 if (UNMARSHALLING(ps)) {
4567 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4570 for (i = 0; i < r_u->num_sids1; i++) {
4571 if (ptr_sid[i] != 0) {
4572 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4580 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4586 /*******************************************************************
4587 inits a SAMR_Q_LOOKUP_NAMES structure.
4588 ********************************************************************/
4590 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4591 POLICY_HND *pol, uint32 flags,
4592 uint32 num_names, const char **name)
4596 DEBUG(5, ("init_samr_q_lookup_names\n"));
4600 q_u->num_names1 = num_names;
4603 q_u->num_names2 = num_names;
4605 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4606 return NT_STATUS_NO_MEMORY;
4608 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4609 return NT_STATUS_NO_MEMORY;
4611 for (i = 0; i < num_names; i++) {
4612 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4613 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4616 return NT_STATUS_OK;
4619 /*******************************************************************
4620 reads or writes a structure.
4621 ********************************************************************/
4623 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4624 prs_struct *ps, int depth)
4631 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4634 if (UNMARSHALLING(ps))
4640 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4643 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4645 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4647 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4649 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4652 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4653 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4654 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4655 if (!q_u->hdr_name || !q_u->uni_name)
4659 for (i = 0; i < q_u->num_names2; i++) {
4660 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4664 for (i = 0; i < q_u->num_names2; i++) {
4665 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4672 /*******************************************************************
4673 inits a SAMR_R_LOOKUP_NAMES structure.
4674 ********************************************************************/
4676 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4678 uint32 *rid, uint32 *type,
4681 DEBUG(5, ("init_samr_r_lookup_names\n"));
4683 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4686 r_u->num_types1 = num_rids;
4688 r_u->num_types2 = num_rids;
4690 r_u->num_rids1 = num_rids;
4692 r_u->num_rids2 = num_rids;
4694 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4695 return NT_STATUS_NO_MEMORY;
4696 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4697 return NT_STATUS_NO_MEMORY;
4699 if (!r_u->rids || !r_u->types)
4702 for (i = 0; i < num_rids; i++) {
4703 r_u->rids[i] = rid[i];
4704 r_u->types[i] = type[i];
4709 r_u->num_types1 = 0;
4711 r_u->num_types2 = 0;
4721 r_u->status = status;
4723 return NT_STATUS_OK;
4726 /*******************************************************************
4727 reads or writes a structure.
4728 ********************************************************************/
4730 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4731 prs_struct *ps, int depth)
4739 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4742 if (UNMARSHALLING(ps))
4748 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4750 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4753 if (r_u->ptr_rids != 0) {
4754 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4757 if (r_u->num_rids2 != r_u->num_rids1) {
4762 if (UNMARSHALLING(ps))
4763 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4766 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4770 for (i = 0; i < r_u->num_rids2; i++) {
4771 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4772 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4777 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4779 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4782 if (r_u->ptr_types != 0) {
4783 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4786 if (r_u->num_types2 != r_u->num_types1) {
4791 if (UNMARSHALLING(ps))
4792 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4795 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4799 for (i = 0; i < r_u->num_types2; i++) {
4800 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4801 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4806 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4812 /*******************************************************************
4813 inits a SAMR_Q_DELETE_DOM_USER structure.
4814 ********************************************************************/
4816 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4819 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4821 q_c->user_pol = *hnd;
4824 /*******************************************************************
4825 reads or writes a structure.
4826 ********************************************************************/
4828 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4829 prs_struct *ps, int depth)
4834 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4840 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4846 /*******************************************************************
4847 reads or writes a structure.
4848 ********************************************************************/
4850 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4851 prs_struct *ps, int depth)
4856 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4862 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4864 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4870 /*******************************************************************
4871 reads or writes a structure.
4872 ********************************************************************/
4874 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4876 uint32 access_mask, uint32 rid)
4878 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4880 q_u->domain_pol = *pol;
4881 q_u->access_mask = access_mask;
4882 q_u->user_rid = rid;
4885 /*******************************************************************
4886 reads or writes a structure.
4887 ********************************************************************/
4889 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4890 prs_struct *ps, int depth)
4895 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4901 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4904 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4906 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4912 /*******************************************************************
4913 reads or writes a structure.
4914 ********************************************************************/
4916 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4917 prs_struct *ps, int depth)
4922 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4928 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4931 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4938 /*******************************************************************
4939 reads or writes a structure.
4940 ********************************************************************/
4942 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4945 uint32 acb_info, uint32 access_mask)
4947 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4949 q_u->domain_pol = *pol;
4951 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
4952 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
4954 q_u->acb_info = acb_info;
4955 q_u->access_mask = access_mask;
4958 /*******************************************************************
4959 reads or writes a structure.
4960 ********************************************************************/
4962 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
4963 prs_struct *ps, int depth)
4968 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4974 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4977 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
4979 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
4984 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
4986 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4992 /*******************************************************************
4993 reads or writes a structure.
4994 ********************************************************************/
4996 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
4997 prs_struct *ps, int depth)
5002 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5008 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5011 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5013 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5015 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5021 /*******************************************************************
5022 inits a SAMR_Q_QUERY_USERINFO structure.
5023 ********************************************************************/
5025 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5026 const POLICY_HND *hnd, uint16 switch_value)
5028 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5031 q_u->switch_value = switch_value;
5034 /*******************************************************************
5035 reads or writes a structure.
5036 ********************************************************************/
5038 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5039 prs_struct *ps, int depth)
5044 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5050 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5053 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5059 /*******************************************************************
5060 reads or writes a LOGON_HRS structure.
5061 ********************************************************************/
5063 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5064 prs_struct *ps, int depth)
5069 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5075 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5078 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5081 if(!prs_uint32("len ", ps, depth, &hrs->len))
5084 if (hrs->len > sizeof(hrs->hours)) {
5085 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5086 hrs->len = sizeof(hrs->hours);
5089 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5095 /*******************************************************************
5096 inits a SAM_USER_INFO_18 structure.
5097 ********************************************************************/
5099 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5100 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5102 DEBUG(5, ("init_sam_user_info18\n"));
5104 usr->lm_pwd_active =
5105 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5106 usr->nt_pwd_active =
5107 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5110 /*******************************************************************
5111 reads or writes a structure.
5112 ********************************************************************/
5114 static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5115 prs_struct *ps, int depth)
5120 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5126 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5128 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5131 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5133 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5139 /*******************************************************************
5140 inits a SAM_USER_INFO_7 structure.
5141 ********************************************************************/
5143 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5145 DEBUG(5, ("init_sam_user_info7\n"));
5147 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5148 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5152 /*******************************************************************
5153 reads or writes a structure.
5154 ********************************************************************/
5156 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5157 prs_struct *ps, int depth)
5162 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5168 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5171 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5177 /*******************************************************************
5178 inits a SAM_USER_INFO_9 structure.
5179 ********************************************************************/
5181 void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
5183 DEBUG(5, ("init_sam_user_info9\n"));
5185 usr->rid_group = rid_group;
5188 /*******************************************************************
5189 reads or writes a structure.
5190 ********************************************************************/
5192 static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
5193 prs_struct *ps, int depth)
5198 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
5204 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5210 /*******************************************************************
5211 inits a SAM_USER_INFO_16 structure.
5212 ********************************************************************/
5214 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5216 DEBUG(5, ("init_sam_user_info16\n"));
5218 usr->acb_info = acb_info;
5221 /*******************************************************************
5222 reads or writes a structure.
5223 ********************************************************************/
5225 static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5226 prs_struct *ps, int depth)
5231 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5237 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5243 /*******************************************************************
5244 inits a SAM_USER_INFO_17 structure.
5245 ********************************************************************/
5247 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5250 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5252 DEBUG(5, ("init_sam_user_info17\n"));
5254 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5255 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5257 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5259 usr->ptr_1 = 1; /* pointer */
5260 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5261 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5263 usr->ptr_2 = 1; /* pointer */
5264 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5266 usr->ptr_3 = 1; /* pointer */
5267 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5269 usr->rid_user = rid_user;
5270 usr->rid_group = rid_group;
5272 usr->acct_ctrl = acct_ctrl;
5273 usr->unknown_3 = 0x0000;
5275 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5276 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5278 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5279 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5281 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5282 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5285 /*******************************************************************
5286 reads or writes a structure.
5287 ********************************************************************/
5289 static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5290 prs_struct *ps, int depth)
5295 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5301 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5304 if(!smb_io_time("time", &usr->expiry, ps, depth))
5307 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5310 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5313 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5316 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5318 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5321 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5324 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5326 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5329 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5331 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5334 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5336 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5338 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5340 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5342 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5344 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5347 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5350 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5353 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5359 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5365 /*************************************************************************
5367 *************************************************************************/
5369 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5371 DEBUG(10, ("init_sam_user_info24:\n"));
5372 memcpy(usr->pass, newpass, sizeof(usr->pass));
5373 usr->pw_len = pw_len;
5376 /*******************************************************************
5377 reads or writes a structure.
5378 ********************************************************************/
5380 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5381 prs_struct *ps, int depth)
5386 prs_debug(ps, depth, desc, "sam_io_user_info24");
5392 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5396 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5397 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5399 } else if (UNMARSHALLING(ps)) {
5400 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5407 /*******************************************************************
5408 reads or writes a structure.
5409 ********************************************************************/
5411 static BOOL sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
5412 prs_struct *ps, int depth)
5417 prs_debug(ps, depth, desc, "sam_io_user_info26");
5423 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5427 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5434 /*************************************************************************
5435 init_sam_user_info23
5437 unknown_6 = 0x0000 04ec
5439 *************************************************************************/
5441 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5442 NTTIME * logoff_time, /* all zeros */
5443 NTTIME * kickoff_time, /* all zeros */
5444 NTTIME * pass_last_set_time, /* all zeros */
5445 NTTIME * pass_can_change_time, /* all zeros */
5446 NTTIME * pass_must_change_time, /* all zeros */
5457 uint32 user_rid, /* 0x0000 0000 */
5460 uint32 fields_present,
5463 uint16 bad_password_count,
5467 usr->logon_time = *logon_time; /* all zeros */
5468 usr->logoff_time = *logoff_time; /* all zeros */
5469 usr->kickoff_time = *kickoff_time; /* all zeros */
5470 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5471 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5472 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5474 ZERO_STRUCT(usr->nt_pwd);
5475 ZERO_STRUCT(usr->lm_pwd);
5477 usr->user_rid = user_rid; /* 0x0000 0000 */
5478 usr->group_rid = group_rid;
5479 usr->acb_info = acb_info;
5480 usr->fields_present = fields_present; /* 09f8 27fa */
5482 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5483 usr->ptr_logon_hrs = hrs ? 1 : 0;
5485 if (nt_time_is_zero(pass_must_change_time)) {
5486 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5488 usr->passmustchange=0;
5491 ZERO_STRUCT(usr->padding1);
5492 ZERO_STRUCT(usr->padding2);
5494 usr->bad_password_count = bad_password_count;
5495 usr->logon_count = logon_count;
5497 memcpy(usr->pass, newpass, sizeof(usr->pass));
5499 copy_unistr2(&usr->uni_user_name, user_name);
5500 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5502 copy_unistr2(&usr->uni_full_name, full_name);
5503 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5505 copy_unistr2(&usr->uni_home_dir, home_dir);
5506 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5508 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5509 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5511 copy_unistr2(&usr->uni_logon_script, log_scr);
5512 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5514 copy_unistr2(&usr->uni_profile_path, prof_path);
5515 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5517 copy_unistr2(&usr->uni_acct_desc, desc);
5518 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5520 copy_unistr2(&usr->uni_workstations, wkstas);
5521 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5523 copy_unistr2(&usr->uni_unknown_str, unk_str);
5524 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5526 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5527 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5529 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5532 /*************************************************************************
5533 init_sam_user_info23
5535 unknown_6 = 0x0000 04ec
5537 *************************************************************************/
5539 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5540 NTTIME * logoff_time, /* all zeros */
5541 NTTIME * kickoff_time, /* all zeros */
5542 NTTIME * pass_last_set_time, /* all zeros */
5543 NTTIME * pass_can_change_time, /* all zeros */
5544 NTTIME * pass_must_change_time, /* all zeros */
5545 char *user_name, /* NULL */
5547 char *home_dir, char *dir_drive, char *log_scr,
5548 char *prof_path, const char *desc, char *wkstas,
5549 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5550 uint32 group_rid, uint32 acb_info,
5551 uint32 fields_present, uint16 logon_divs,
5552 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5555 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5557 usr->logon_time = *logon_time; /* all zeros */
5558 usr->logoff_time = *logoff_time; /* all zeros */
5559 usr->kickoff_time = *kickoff_time; /* all zeros */
5560 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5561 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5562 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5564 ZERO_STRUCT(usr->nt_pwd);
5565 ZERO_STRUCT(usr->lm_pwd);
5567 usr->user_rid = user_rid; /* 0x0000 0000 */
5568 usr->group_rid = group_rid;
5569 usr->acb_info = acb_info;
5570 usr->fields_present = fields_present; /* 09f8 27fa */
5572 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5573 usr->ptr_logon_hrs = hrs ? 1 : 0;
5575 if (nt_time_is_zero(pass_must_change_time)) {
5576 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5578 usr->passmustchange=0;
5581 ZERO_STRUCT(usr->padding1);
5582 ZERO_STRUCT(usr->padding2);
5584 usr->bad_password_count = bad_password_count;
5585 usr->logon_count = logon_count;
5587 memcpy(usr->pass, newpass, sizeof(usr->pass));
5589 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5590 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5592 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5593 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5595 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5596 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5598 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5599 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5601 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5602 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5604 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5605 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5607 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5608 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5610 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5611 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5613 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5614 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5616 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5617 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5619 data_blob_free(&blob);
5621 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5624 /*******************************************************************
5625 reads or writes a structure.
5626 ********************************************************************/
5628 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5629 prs_struct *ps, int depth)
5634 prs_debug(ps, depth, desc, "sam_io_user_info23");
5640 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5642 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5644 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5646 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5648 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5650 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5653 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5655 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5657 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5659 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5661 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5663 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5665 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5667 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5669 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5671 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5674 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5676 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5679 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5681 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5683 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5686 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5688 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5692 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5695 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5697 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5700 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5702 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5704 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5708 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5711 /* here begins pointed-to data */
5713 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5716 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5719 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5722 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5725 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5728 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5731 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5734 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5737 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5740 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5743 /* ok, this is only guess-work (as usual) */
5744 if (usr->ptr_logon_hrs) {
5745 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5752 /*******************************************************************
5753 reads or writes a structure.
5754 NB. This structure is *definately* incorrect. It's my best guess
5755 currently for W2K SP2. The password field is encrypted in a different
5756 way than normal... And there are definately other problems. JRA.
5757 ********************************************************************/
5759 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5764 prs_debug(ps, depth, desc, "sam_io_user_info25");
5770 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5772 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5774 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5776 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5778 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5780 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5783 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5785 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5787 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5789 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5791 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5793 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5795 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5797 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5799 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5801 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5804 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5806 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5809 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5811 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5813 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5816 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5819 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5822 /* here begins pointed-to data */
5824 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5827 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5830 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5833 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5836 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5839 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5842 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5845 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5848 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5851 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5854 #if 0 /* JRA - unknown... */
5855 /* ok, this is only guess-work (as usual) */
5856 if (usr->ptr_logon_hrs) {
5857 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5866 /*************************************************************************
5867 init_sam_user_info21W
5869 unknown_6 = 0x0000 04ec
5871 *************************************************************************/
5873 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5874 NTTIME * logon_time,
5875 NTTIME * logoff_time,
5876 NTTIME * kickoff_time,
5877 NTTIME * pass_last_set_time,
5878 NTTIME * pass_can_change_time,
5879 NTTIME * pass_must_change_time,
5895 uint32 fields_present,
5898 uint16 bad_password_count,
5901 usr->logon_time = *logon_time;
5902 usr->logoff_time = *logoff_time;
5903 usr->kickoff_time = *kickoff_time;
5904 usr->pass_last_set_time = *pass_last_set_time;
5905 usr->pass_can_change_time = *pass_can_change_time;
5906 usr->pass_must_change_time = *pass_must_change_time;
5908 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5909 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5911 usr->user_rid = user_rid;
5912 usr->group_rid = group_rid;
5913 usr->acb_info = acb_info;
5914 usr->fields_present = fields_present; /* 0x00ff ffff */
5916 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5917 usr->ptr_logon_hrs = hrs ? 1 : 0;
5918 usr->bad_password_count = bad_password_count;
5919 usr->logon_count = logon_count;
5921 if (nt_time_is_zero(pass_must_change_time)) {
5922 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5924 usr->passmustchange=0;
5927 ZERO_STRUCT(usr->padding1);
5928 ZERO_STRUCT(usr->padding2);
5930 copy_unistr2(&usr->uni_user_name, user_name);
5931 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5933 copy_unistr2(&usr->uni_full_name, full_name);
5934 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5936 copy_unistr2(&usr->uni_home_dir, home_dir);
5937 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5939 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5940 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5942 copy_unistr2(&usr->uni_logon_script, log_scr);
5943 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5945 copy_unistr2(&usr->uni_profile_path, prof_path);
5946 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5948 copy_unistr2(&usr->uni_acct_desc, desc);
5949 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5951 copy_unistr2(&usr->uni_workstations, wkstas);
5952 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5954 copy_unistr2(&usr->uni_unknown_str, unk_str);
5955 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5957 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5958 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5960 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5963 /*************************************************************************
5964 init_sam_user_info21
5966 unknown_6 = 0x0000 04ec
5968 *************************************************************************/
5970 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
5972 NTTIME logon_time, logoff_time, kickoff_time,
5973 pass_last_set_time, pass_can_change_time,
5974 pass_must_change_time;
5976 const char* user_name = pdb_get_username(pw);
5977 const char* full_name = pdb_get_fullname(pw);
5978 const char* home_dir = pdb_get_homedir(pw);
5979 const char* dir_drive = pdb_get_dir_drive(pw);
5980 const char* logon_script = pdb_get_logon_script(pw);
5981 const char* profile_path = pdb_get_profile_path(pw);
5982 const char* description = pdb_get_acct_desc(pw);
5983 const char* workstations = pdb_get_workstations(pw);
5984 const char* munged_dial = pdb_get_munged_dial(pw);
5985 DATA_BLOB munged_dial_blob;
5988 const DOM_SID *user_sid;
5991 const DOM_SID *group_sid;
5994 munged_dial_blob = base64_decode_data_blob(munged_dial);
5996 munged_dial_blob = data_blob(NULL, 0);
5999 /* Create NTTIME structs */
6000 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6001 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6002 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6003 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6004 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6005 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6007 /* structure assignment */
6008 usr->logon_time = logon_time;
6009 usr->logoff_time = logoff_time;
6010 usr->kickoff_time = kickoff_time;
6011 usr->pass_last_set_time = pass_last_set_time;
6012 usr->pass_can_change_time = pass_can_change_time;
6013 usr->pass_must_change_time = pass_must_change_time;
6015 ZERO_STRUCT(usr->nt_pwd);
6016 ZERO_STRUCT(usr->lm_pwd);
6018 user_sid = pdb_get_user_sid(pw);
6020 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6021 fstring user_sid_string;
6022 fstring domain_sid_string;
6023 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6024 "the domain sid %s. Failing operation.\n",
6026 sid_to_string(user_sid_string, user_sid),
6027 sid_to_string(domain_sid_string, domain_sid)));
6028 data_blob_free(&munged_dial_blob);
6029 return NT_STATUS_UNSUCCESSFUL;
6032 group_sid = pdb_get_group_sid(pw);
6034 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6035 fstring group_sid_string;
6036 fstring domain_sid_string;
6037 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6038 "which conflicts with the domain sid %s. Failing operation.\n",
6040 sid_to_string(group_sid_string, group_sid),
6041 sid_to_string(domain_sid_string, domain_sid)));
6042 data_blob_free(&munged_dial_blob);
6043 return NT_STATUS_UNSUCCESSFUL;
6046 usr->user_rid = user_rid;
6047 usr->group_rid = group_rid;
6048 usr->acb_info = pdb_get_acct_ctrl(pw);
6051 Look at a user on a real NT4 PDC with usrmgr, press
6052 'ok'. Then you will see that fields_present is set to
6053 0x08f827fa. Look at the user immediately after that again,
6054 and you will see that 0x00fffff is returned. This solves
6055 the problem that you get access denied after having looked
6059 usr->fields_present = pdb_build_fields_present(pw);
6061 usr->logon_divs = pdb_get_logon_divs(pw);
6062 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6063 usr->bad_password_count = pdb_get_bad_password_count(pw);
6064 usr->logon_count = pdb_get_logon_count(pw);
6066 if (pdb_get_pass_must_change_time(pw) == 0) {
6067 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6069 usr->passmustchange=0;
6072 ZERO_STRUCT(usr->padding1);
6073 ZERO_STRUCT(usr->padding2);
6075 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6076 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6078 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6079 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6081 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6082 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6084 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6085 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6087 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6088 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6090 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6091 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6093 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6094 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6096 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6097 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6099 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6100 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6102 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6103 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6104 data_blob_free(&munged_dial_blob);
6106 if (pdb_get_hours(pw)) {
6107 usr->logon_hrs.max_len = 1260;
6108 usr->logon_hrs.offset = 0;
6109 usr->logon_hrs.len = pdb_get_hours_len(pw);
6110 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6112 usr->logon_hrs.max_len = 1260;
6113 usr->logon_hrs.offset = 0;
6114 usr->logon_hrs.len = 0;
6115 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6118 return NT_STATUS_OK;
6121 /*******************************************************************
6122 reads or writes a structure.
6123 ********************************************************************/
6125 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6126 prs_struct *ps, int depth)
6131 prs_debug(ps, depth, desc, "sam_io_user_info21");
6137 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6139 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6141 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6143 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6145 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6147 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6150 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6152 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6154 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6156 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6158 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6160 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6162 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6164 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6166 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6168 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6171 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6173 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6176 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6178 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6180 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6183 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6185 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6189 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6192 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6194 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6197 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6199 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6201 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6204 /* here begins pointed-to data */
6206 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6208 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6210 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6212 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6214 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6216 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6218 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6220 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6222 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6224 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6227 /* ok, this is only guess-work (as usual) */
6228 if (usr->ptr_logon_hrs) {
6229 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6236 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
6238 const char *munged_dial = pdb_get_munged_dial(pw);
6239 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6241 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6242 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6243 data_blob_free(&blob);
6246 /*******************************************************************
6247 reads or writes a structure.
6248 ********************************************************************/
6250 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6251 prs_struct *ps, int depth)
6256 prs_debug(ps, depth, desc, "sam_io_user_info20");
6262 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6265 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6271 /*******************************************************************
6272 inits a SAM_USERINFO_CTR structure.
6273 ********************************************************************/
6275 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6276 uint16 switch_value,
6277 SAM_USER_INFO_21 * usr)
6279 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6281 ctr->switch_value = switch_value;
6282 ctr->info.id = NULL;
6284 switch (switch_value) {
6286 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6287 if (ctr->info.id16 == NULL)
6288 return NT_STATUS_NO_MEMORY;
6290 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6293 /* whoops - got this wrong. i think. or don't understand what's happening. */
6297 info = (void *)&id11;
6299 expire.low = 0xffffffff;
6300 expire.high = 0x7fffffff;
6302 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6303 init_sam_user_info11(ctr->info.id17, &expire,
6304 "BROOKFIELDS$", /* name */
6305 0x03ef, /* user rid */
6306 0x201, /* group rid */
6307 0x0080); /* acb info */
6313 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6314 if (ctr->info.id18 == NULL)
6315 return NT_STATUS_NO_MEMORY;
6317 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6321 SAM_USER_INFO_21 *cusr;
6322 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6323 ctr->info.id21 = cusr;
6324 if (ctr->info.id21 == NULL)
6325 return NT_STATUS_NO_MEMORY;
6326 memcpy(cusr, usr, sizeof(*usr));
6327 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6328 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6332 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6333 return NT_STATUS_INVALID_INFO_CLASS;
6336 return NT_STATUS_OK;
6339 /*******************************************************************
6340 inits a SAM_USERINFO_CTR structure.
6341 ********************************************************************/
6343 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6344 uint16 switch_value, void *info)
6346 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6348 ctr->switch_value = switch_value;
6349 ctr->info.id = info;
6351 switch (switch_value) {
6353 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6354 dump_data(100, (char *)sess_key->data, sess_key->length);
6355 dump_data(100, (char *)ctr->info.id24->pass, 516);
6358 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6359 dump_data(100, (char *)sess_key->data, sess_key->length);
6360 dump_data(100, (char *)ctr->info.id23->pass, 516);
6365 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6369 /*******************************************************************
6370 reads or writes a structure.
6371 ********************************************************************/
6373 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6374 prs_struct *ps, int depth)
6377 SAM_USERINFO_CTR *ctr;
6379 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6382 if (UNMARSHALLING(ps)) {
6383 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6391 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6393 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6400 switch (ctr->switch_value) {
6402 if (UNMARSHALLING(ps))
6403 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6404 if (ctr->info.id7 == NULL) {
6405 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6408 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6411 if (UNMARSHALLING(ps))
6412 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
6413 if (ctr->info.id9 == NULL) {
6414 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6417 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
6420 if (UNMARSHALLING(ps))
6421 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6422 if (ctr->info.id16 == NULL) {
6423 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6426 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6429 if (UNMARSHALLING(ps))
6430 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6432 if (ctr->info.id17 == NULL) {
6433 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6436 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6439 if (UNMARSHALLING(ps))
6440 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6442 if (ctr->info.id18 == NULL) {
6443 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6446 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6449 if (UNMARSHALLING(ps))
6450 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6452 if (ctr->info.id20 == NULL) {
6453 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6456 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6459 if (UNMARSHALLING(ps))
6460 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6462 if (ctr->info.id21 == NULL) {
6463 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6466 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6469 if (UNMARSHALLING(ps))
6470 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6472 if (ctr->info.id23 == NULL) {
6473 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6476 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6479 if (UNMARSHALLING(ps))
6480 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6482 if (ctr->info.id24 == NULL) {
6483 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6486 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6489 if (UNMARSHALLING(ps))
6490 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6492 if (ctr->info.id25 == NULL) {
6493 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6496 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6499 if (UNMARSHALLING(ps))
6500 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6502 if (ctr->info.id26 == NULL) {
6503 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6506 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6509 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6517 /*******************************************************************
6518 inits a SAMR_R_QUERY_USERINFO structure.
6519 ********************************************************************/
6521 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6522 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6524 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6529 if (NT_STATUS_IS_OK(status)) {
6534 r_u->status = status; /* return status */
6537 /*******************************************************************
6538 reads or writes a structure.
6539 ********************************************************************/
6541 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6542 prs_struct *ps, int depth)
6547 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6553 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6556 if (r_u->ptr != 0) {
6557 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6563 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6569 /*******************************************************************
6570 inits a SAMR_Q_SET_USERINFO structure.
6571 ********************************************************************/
6573 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6574 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6575 uint16 switch_value, void *info)
6577 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6580 q_u->switch_value = switch_value;
6581 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6584 /*******************************************************************
6585 reads or writes a structure.
6586 ********************************************************************/
6588 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6589 prs_struct *ps, int depth)
6594 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6600 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6602 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6604 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6610 /*******************************************************************
6611 inits a SAMR_R_SET_USERINFO structure.
6612 ********************************************************************/
6614 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6616 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6618 r_u->status = status; /* return status */
6621 /*******************************************************************
6622 reads or writes a structure.
6623 ********************************************************************/
6625 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6626 prs_struct *ps, int depth)
6631 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6637 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6643 /*******************************************************************
6644 inits a SAMR_Q_SET_USERINFO2 structure.
6645 ********************************************************************/
6647 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6648 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6649 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6651 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6654 q_u->switch_value = switch_value;
6657 if (q_u->ctr != NULL)
6658 q_u->ctr->switch_value = switch_value;
6660 switch (switch_value) {
6662 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
6663 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
6664 dump_data(100, (char *)sess_key->data, sess_key->length);
6665 dump_data(100, (char *)ctr->info.id18->lm_pwd, 16);
6666 dump_data(100, (char *)ctr->info.id18->nt_pwd, 16);
6671 /*******************************************************************
6672 reads or writes a structure.
6673 ********************************************************************/
6675 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6676 prs_struct *ps, int depth)
6681 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6687 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6690 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6692 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6698 /*******************************************************************
6699 inits a SAMR_R_SET_USERINFO2 structure.
6700 ********************************************************************/
6702 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6704 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6706 r_u->status = status; /* return status */
6709 /*******************************************************************
6710 reads or writes a structure.
6711 ********************************************************************/
6713 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6714 prs_struct *ps, int depth)
6719 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6725 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6731 /*******************************************************************
6732 inits a SAMR_Q_CONNECT structure.
6733 ********************************************************************/
6735 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6736 char *srv_name, uint32 access_mask)
6738 DEBUG(5, ("init_samr_q_connect\n"));
6740 /* make PDC server name \\server */
6741 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6742 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6744 /* example values: 0x0000 0002 */
6745 q_u->access_mask = access_mask;
6748 /*******************************************************************
6749 reads or writes a structure.
6750 ********************************************************************/
6752 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6753 prs_struct *ps, int depth)
6758 prs_debug(ps, depth, desc, "samr_io_q_connect");
6764 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6766 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6771 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6777 /*******************************************************************
6778 reads or writes a structure.
6779 ********************************************************************/
6781 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6782 prs_struct *ps, int depth)
6787 prs_debug(ps, depth, desc, "samr_io_r_connect");
6793 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6796 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6802 /*******************************************************************
6803 inits a SAMR_Q_CONNECT4 structure.
6804 ********************************************************************/
6806 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6807 char *srv_name, uint32 access_mask)
6809 DEBUG(5, ("init_samr_q_connect4\n"));
6811 /* make PDC server name \\server */
6812 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6813 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6815 /* Only value we've seen, possibly an address type ? */
6818 /* example values: 0x0000 0002 */
6819 q_u->access_mask = access_mask;
6822 /*******************************************************************
6823 reads or writes a structure.
6824 ********************************************************************/
6826 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6827 prs_struct *ps, int depth)
6832 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6838 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6840 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6845 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6847 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6853 /*******************************************************************
6854 reads or writes a structure.
6855 ********************************************************************/
6857 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6858 prs_struct *ps, int depth)
6863 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6869 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6872 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6878 /*******************************************************************
6879 inits a SAMR_Q_CONNECT5 structure.
6880 ********************************************************************/
6882 void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
6883 char *srv_name, uint32 access_mask)
6885 DEBUG(5, ("init_samr_q_connect5\n"));
6887 /* make PDC server name \\server */
6888 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6889 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6891 /* example values: 0x0000 0002 */
6892 q_u->access_mask = access_mask;
6895 q_u->info1_unk1 = 3;
6896 q_u->info1_unk2 = 0;
6899 /*******************************************************************
6900 inits a SAMR_R_CONNECT5 structure.
6901 ********************************************************************/
6903 void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
6905 DEBUG(5, ("init_samr_q_connect5\n"));
6908 r_u->info1_unk1 = 3;
6909 r_u->info1_unk2 = 0;
6911 r_u->connect_pol = *pol;
6912 r_u->status = status;
6915 /*******************************************************************
6916 reads or writes a structure.
6917 ********************************************************************/
6919 BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
6920 prs_struct *ps, int depth)
6925 prs_debug(ps, depth, desc, "samr_io_q_connect5");
6931 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6933 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6938 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6941 if(!prs_uint32("level", ps, depth, &q_u->level))
6943 if(!prs_uint32("level", ps, depth, &q_u->level))
6946 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
6948 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
6954 /*******************************************************************
6955 reads or writes a structure.
6956 ********************************************************************/
6958 BOOL samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
6959 prs_struct *ps, int depth)
6964 prs_debug(ps, depth, desc, "samr_io_r_connect5");
6970 if(!prs_uint32("level", ps, depth, &r_u->level))
6972 if(!prs_uint32("level", ps, depth, &r_u->level))
6974 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
6976 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
6979 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6982 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6988 /*******************************************************************
6989 inits a SAMR_Q_CONNECT_ANON structure.
6990 ********************************************************************/
6992 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6994 DEBUG(5, ("init_samr_q_connect_anon\n"));
6997 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6998 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
7001 /*******************************************************************
7002 reads or writes a structure.
7003 ********************************************************************/
7005 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
7006 prs_struct *ps, int depth)
7011 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
7017 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
7020 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
7025 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7031 /*******************************************************************
7032 reads or writes a structure.
7033 ********************************************************************/
7035 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
7036 prs_struct *ps, int depth)
7041 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
7047 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7050 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7056 /*******************************************************************
7057 inits a SAMR_Q_GET_DOM_PWINFO structure.
7058 ********************************************************************/
7060 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
7063 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7066 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
7067 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
7070 /*******************************************************************
7071 reads or writes a structure.
7072 ********************************************************************/
7074 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
7075 prs_struct *ps, int depth)
7080 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
7086 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
7088 if (q_u->ptr != 0) {
7089 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7091 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7098 /*******************************************************************
7099 reads or writes a structure.
7100 ********************************************************************/
7102 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7103 prs_struct *ps, int depth)
7108 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7114 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
7118 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
7121 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7127 /*******************************************************************
7128 make a SAMR_ENC_PASSWD structure.
7129 ********************************************************************/
7131 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7139 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7143 /*******************************************************************
7144 reads or writes a SAMR_ENC_PASSWD structure.
7145 ********************************************************************/
7147 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7148 prs_struct *ps, int depth)
7153 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7159 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7162 if (pwd->ptr != 0) {
7163 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7170 /*******************************************************************
7171 inits a SAMR_ENC_HASH structure.
7172 ********************************************************************/
7174 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7182 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7186 /*******************************************************************
7187 reads or writes a SAMR_ENC_HASH structure.
7188 ********************************************************************/
7190 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7191 prs_struct *ps, int depth)
7196 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7202 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7204 if (hsh->ptr != 0) {
7205 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7212 /*******************************************************************
7213 inits a SAMR_Q_CHGPASSWD_USER structure.
7214 ********************************************************************/
7216 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7217 const char *dest_host, const char *user_name,
7218 const uchar nt_newpass[516],
7219 const uchar nt_oldhash[16],
7220 const uchar lm_newpass[516],
7221 const uchar lm_oldhash[16])
7223 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7226 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7227 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7229 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7230 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7232 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7233 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7235 q_u->unknown = 0x01;
7237 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7238 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7241 /*******************************************************************
7242 reads or writes a structure.
7243 ********************************************************************/
7245 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7246 prs_struct *ps, int depth)
7251 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7257 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7260 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7262 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7267 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7269 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7272 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7274 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7277 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7280 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7282 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7288 /*******************************************************************
7289 inits a SAMR_R_CHGPASSWD_USER structure.
7290 ********************************************************************/
7292 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7294 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7296 r_u->status = status;
7299 /*******************************************************************
7300 reads or writes a structure.
7301 ********************************************************************/
7303 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7304 prs_struct *ps, int depth)
7309 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7315 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7321 /*******************************************************************
7322 inits a SAMR_Q_CHGPASSWD3 structure.
7323 ********************************************************************/
7325 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
7326 const char *dest_host, const char *user_name,
7327 const uchar nt_newpass[516],
7328 const uchar nt_oldhash[16],
7329 const uchar lm_newpass[516],
7330 const uchar lm_oldhash[16])
7332 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7335 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7336 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7338 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7339 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7341 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7342 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7344 q_u->lm_change = 0x01;
7346 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7347 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7349 init_enc_passwd(&q_u->password3, NULL);
7352 /*******************************************************************
7353 reads or writes a structure.
7354 ********************************************************************/
7356 BOOL samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
7357 prs_struct *ps, int depth)
7362 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
7368 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7371 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7373 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7378 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7380 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7383 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7385 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7388 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
7391 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7393 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7396 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
7402 /*******************************************************************
7403 inits a SAMR_R_CHGPASSWD_USER3 structure.
7404 ********************************************************************/
7406 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
7407 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
7409 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7411 r_u->status = status;
7415 r_u->ptr_reject = 0;
7421 if (reject && (reject->reject_reason != Undefined)) {
7422 r_u->reject = reject;
7423 r_u->ptr_reject = 1;
7427 /*******************************************************************
7428 Reads or writes an SAMR_CHANGE_REJECT structure.
7429 ********************************************************************/
7431 BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
7436 prs_debug(ps, depth, desc, "samr_io_change_reject");
7442 if(UNMARSHALLING(ps))
7443 ZERO_STRUCTP(reject);
7445 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
7448 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
7451 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
7457 /*******************************************************************
7458 reads or writes a structure.
7459 ********************************************************************/
7461 BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
7462 prs_struct *ps, int depth)
7467 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
7473 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
7476 if (r_u->ptr_info && r_u->info != NULL) {
7477 /* SAM_UNK_INFO_1 */
7478 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
7482 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
7485 if (r_u->ptr_reject && r_u->reject != NULL) {
7486 /* SAMR_CHANGE_REJECT */
7487 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
7491 if (!prs_ntstatus("status", ps, depth, &r_u->status))
7497 /*******************************************************************
7498 reads or writes a structure.
7499 ********************************************************************/
7501 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7502 POLICY_HND *domain_pol, uint16 switch_value)
7504 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7506 q_u->domain_pol = *domain_pol;
7507 q_u->switch_value = switch_value;
7510 /*******************************************************************
7511 reads or writes a structure.
7512 ********************************************************************/
7514 BOOL samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7515 prs_struct *ps, int depth)
7520 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7526 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7529 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7535 /*******************************************************************
7536 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7537 ********************************************************************/
7539 void init_samr_r_samr_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7540 uint16 switch_value, SAM_UNK_CTR * ctr,
7543 DEBUG(5, ("init_samr_r_samr_query_domain_info2\n"));
7546 r_u->switch_value = 0;
7547 r_u->status = status; /* return status */
7549 if (NT_STATUS_IS_OK(status)) {
7550 r_u->switch_value = switch_value;
7556 /*******************************************************************
7557 reads or writes a structure.
7558 ********************************************************************/
7560 BOOL samr_io_r_samr_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7561 prs_struct *ps, int depth)
7566 prs_debug(ps, depth, desc, "samr_io_r_samr_query_domain_info2");
7572 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7575 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7576 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7581 switch (r_u->switch_value) {
7583 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7587 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7591 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7595 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7599 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7603 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7607 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7611 DEBUG(0, ("samr_io_r_samr_query_domain_info2: unknown switch level 0x%x\n",
7612 r_u->switch_value));
7613 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7621 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7628 /*******************************************************************
7629 reads or writes a structure.
7630 ********************************************************************/
7632 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7633 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7635 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7637 q_u->domain_pol = *domain_pol;
7638 q_u->switch_value0 = switch_value;
7640 q_u->switch_value = switch_value;
7645 /*******************************************************************
7646 reads or writes a structure.
7647 ********************************************************************/
7649 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7650 prs_struct *ps, int depth)
7655 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7661 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7664 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7667 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7673 if (UNMARSHALLING(ps)) {
7674 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7678 switch (q_u->switch_value) {
7681 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7685 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7689 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7693 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7697 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7701 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7705 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7709 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7710 q_u->switch_value));
7717 /*******************************************************************
7718 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7719 ********************************************************************/
7721 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7723 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7725 r_u->status = status; /* return status */
7728 /*******************************************************************
7729 reads or writes a structure.
7730 ********************************************************************/
7732 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7733 prs_struct *ps, int depth)
7738 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7744 if(!prs_ntstatus("status", ps, depth, &r_u->status))