2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Paul Ashton 1997-2000,
7 * Copyright (C) Elrond 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Jean François Micouleau 1998-2001,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #define DBGC_CLASS DBGC_RPC_PARSE
32 /*******************************************************************
33 inits a SAMR_Q_CLOSE_HND structure.
34 ********************************************************************/
36 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
38 DEBUG(5, ("init_samr_q_close_hnd\n"));
43 /*******************************************************************
44 reads or writes a structure.
45 ********************************************************************/
47 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
48 prs_struct *ps, int depth)
53 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
59 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
62 /*******************************************************************
63 reads or writes a structure.
64 ********************************************************************/
66 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
67 prs_struct *ps, int depth)
72 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
78 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
81 if(!prs_ntstatus("status", ps, depth, &r_u->status))
87 /*******************************************************************
88 inits a SAMR_Q_LOOKUP_DOMAIN structure.
89 ********************************************************************/
91 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
92 POLICY_HND *pol, char *dom_name)
94 DEBUG(5, ("init_samr_q_lookup_domain\n"));
96 q_u->connect_pol = *pol;
98 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
99 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
102 /*******************************************************************
103 reads or writes a structure.
104 ********************************************************************/
105 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
106 prs_struct *ps, int depth)
111 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
117 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
120 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
123 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
129 /*******************************************************************
130 inits a SAMR_R_LOOKUP_DOMAIN structure.
131 ********************************************************************/
133 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
134 DOM_SID *dom_sid, NTSTATUS status)
136 DEBUG(5, ("init_samr_r_lookup_domain\n"));
138 r_u->status = status;
140 if (NT_STATUS_IS_OK(status)) {
142 init_dom_sid2(&r_u->dom_sid, dom_sid);
146 /*******************************************************************
147 reads or writes a structure.
148 ********************************************************************/
150 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
151 prs_struct *ps, int depth)
156 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
162 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
165 if (r_u->ptr_sid != 0) {
166 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
172 if(!prs_ntstatus("status", ps, depth, &r_u->status))
178 /*******************************************************************
179 reads or writes a structure.
180 ********************************************************************/
182 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
184 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
186 q_u->dom_pol = *dom_pol;
187 init_dom_sid2(&q_u->sid, sid);
190 /*******************************************************************
191 reads or writes a structure.
192 ********************************************************************/
194 BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
195 prs_struct *ps, int depth)
200 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
206 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
209 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
218 /*******************************************************************
219 reads or writes a structure.
220 ********************************************************************/
222 BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
223 prs_struct *ps, int depth)
228 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
234 if(!prs_ntstatus("status", ps, depth, &r_u->status))
240 /*******************************************************************
241 reads or writes a structure.
242 ********************************************************************/
244 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
245 POLICY_HND *pol, uint32 flags,
248 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
252 init_dom_sid2(&q_u->dom_sid, sid);
255 /*******************************************************************
256 reads or writes a structure.
257 ********************************************************************/
259 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
260 prs_struct *ps, int depth)
265 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
271 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
274 if(!prs_uint32("flags", ps, depth, &q_u->flags))
277 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
283 /*******************************************************************
284 reads or writes a structure.
285 ********************************************************************/
287 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
288 prs_struct *ps, int depth)
293 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
299 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
302 if(!prs_ntstatus("status", ps, depth, &r_u->status))
308 /*******************************************************************
309 reads or writes a structure.
310 ********************************************************************/
312 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
313 POLICY_HND *user_pol)
315 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
317 q_u->user_pol = *user_pol;
320 /*******************************************************************
321 reads or writes a structure.
322 ********************************************************************/
324 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
325 prs_struct *ps, int depth)
330 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
336 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
339 /*******************************************************************
341 ********************************************************************/
343 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
345 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
347 r_u->min_pwd_length = 0x0000;
351 * r_u->unknown_1 = 0x0015;
354 r_u->unknown_1 = 0x01D1;
355 r_u->unknown_1 = 0x0015;
357 r_u->password_properties = 0x00000000;
359 r_u->status = status;
362 /*******************************************************************
363 reads or writes a structure.
364 ********************************************************************/
366 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
367 prs_struct *ps, int depth)
372 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
378 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
380 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
382 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
385 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
392 /*******************************************************************
393 reads or writes a structure.
394 ********************************************************************/
396 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
397 prs_struct *ps, int depth)
402 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
408 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
411 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
414 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
421 /*******************************************************************
422 reads or writes a structure.
423 ********************************************************************/
425 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
426 POLICY_HND *user_pol, uint32 sec_info)
428 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
430 q_u->user_pol = *user_pol;
431 q_u->sec_info = sec_info;
435 /*******************************************************************
436 reads or writes a structure.
437 ********************************************************************/
439 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
440 prs_struct *ps, int depth)
445 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
451 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
454 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
460 /*******************************************************************
461 reads or writes a structure.
462 ********************************************************************/
464 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
465 POLICY_HND *domain_pol, uint16 switch_value)
467 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
469 q_u->domain_pol = *domain_pol;
470 q_u->switch_value = switch_value;
473 /*******************************************************************
474 reads or writes a structure.
475 ********************************************************************/
477 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
478 prs_struct *ps, int depth)
483 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
489 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
492 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
499 /*******************************************************************
501 ********************************************************************/
503 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
505 u_3->logout.low = nt_logout.low;
506 u_3->logout.high = nt_logout.high;
509 /*******************************************************************
510 reads or writes a structure.
511 ********************************************************************/
513 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
514 prs_struct *ps, int depth)
519 prs_debug(ps, depth, desc, "sam_io_unk_info3");
522 if(!smb_io_time("logout", &u_3->logout, ps, depth))
528 /*******************************************************************
530 ********************************************************************/
532 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
534 u_6->unknown_0 = 0x00000000;
536 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
539 /*******************************************************************
540 reads or writes a structure.
541 ********************************************************************/
543 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
544 prs_struct *ps, int depth)
549 prs_debug(ps, depth, desc, "sam_io_unk_info6");
552 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
554 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
556 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
562 /*******************************************************************
564 ********************************************************************/
566 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
568 u_7->server_role = server_role;
571 /*******************************************************************
572 reads or writes a structure.
573 ********************************************************************/
575 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
576 prs_struct *ps, int depth)
581 prs_debug(ps, depth, desc, "sam_io_unk_info7");
584 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
590 /*******************************************************************
592 ********************************************************************/
594 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
596 unix_to_nt_time(&u_8->domain_create_time, 0);
597 u_8->seq_num.low = seq_num;
598 u_8->seq_num.high = 0x0000;
601 /*******************************************************************
602 reads or writes a structure.
603 ********************************************************************/
605 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
606 prs_struct *ps, int depth)
611 prs_debug(ps, depth, desc, "sam_io_unk_info8");
614 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
617 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
624 /*******************************************************************
626 ********************************************************************/
628 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
630 u_12->duration.low = nt_lock_duration.low;
631 u_12->duration.high = nt_lock_duration.high;
632 u_12->reset_count.low = nt_reset_time.low;
633 u_12->reset_count.high = nt_reset_time.high;
635 u_12->bad_attempt_lockout = lockout;
638 /*******************************************************************
639 reads or writes a structure.
640 ********************************************************************/
642 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
643 prs_struct *ps, int depth)
648 prs_debug(ps, depth, desc, "sam_io_unk_info12");
651 if(!smb_io_time("duration", &u_12->duration, ps, depth))
653 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
655 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
661 /*******************************************************************
663 ********************************************************************/
665 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
667 init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE);
668 init_uni_hdr(&u_5->hdr_server, &u_5->uni_server);
671 /*******************************************************************
672 reads or writes a structure.
673 ********************************************************************/
675 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
676 prs_struct *ps, int depth)
681 prs_debug(ps, depth, desc, "sam_io_unk_info5");
684 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
687 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
693 /*******************************************************************
695 ********************************************************************/
697 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
698 const char *comment, const char *domain, const char *server,
699 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
701 u_2->logout.low = nt_logout.low;
702 u_2->logout.high = nt_logout.high;
704 u_2->seq_num.low = seq_num;
705 u_2->seq_num.high = 0x00000000;
708 u_2->unknown_4 = 0x00000001;
709 u_2->server_role = server_role;
710 u_2->unknown_6 = 0x00000001;
711 u_2->num_domain_usrs = num_users;
712 u_2->num_domain_grps = num_groups;
713 u_2->num_local_grps = num_alias;
715 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
717 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
718 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
719 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
720 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
721 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
722 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
725 /*******************************************************************
726 reads or writes a structure.
727 ********************************************************************/
729 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
730 prs_struct *ps, int depth)
735 prs_debug(ps, depth, desc, "sam_io_unk_info2");
738 if(!smb_io_time("logout", &u_2->logout, ps, depth))
740 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
742 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
744 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
747 /* put all the data in here, at the moment, including what the above
748 pointer is referring to
751 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
754 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
756 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
758 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
760 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
762 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
764 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
767 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
769 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
771 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
777 /*******************************************************************
779 ********************************************************************/
781 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
782 uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
784 u_1->min_length_password = min_pass_len;
785 u_1->password_history = pass_hist;
786 u_1->password_properties = password_properties;
788 /* password never expire */
789 u_1->expire.high = nt_expire.high;
790 u_1->expire.low = nt_expire.low;
792 /* can change the password now */
793 u_1->min_passwordage.high = nt_min_age.high;
794 u_1->min_passwordage.low = nt_min_age.low;
798 /*******************************************************************
799 reads or writes a structure.
800 ********************************************************************/
802 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
803 prs_struct *ps, int depth)
808 prs_debug(ps, depth, desc, "sam_io_unk_info1");
811 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
813 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
815 if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
817 if(!smb_io_time("expire", &u_1->expire, ps, depth))
819 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
825 /*******************************************************************
826 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
827 ********************************************************************/
829 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
830 uint16 switch_value, SAM_UNK_CTR * ctr,
833 DEBUG(5, ("init_samr_r_query_dom_info\n"));
836 r_u->switch_value = 0;
837 r_u->status = status; /* return status */
839 if (NT_STATUS_IS_OK(status)) {
840 r_u->switch_value = switch_value;
846 /*******************************************************************
847 reads or writes a structure.
848 ********************************************************************/
850 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
851 prs_struct *ps, int depth)
856 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
862 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
865 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
866 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
871 switch (r_u->switch_value) {
873 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
877 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
881 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
885 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
889 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
893 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
897 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
901 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
905 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
907 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
921 /*******************************************************************
922 reads or writes a SAMR_R_SET_SEC_OBJ structure.
923 ********************************************************************/
925 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
926 prs_struct *ps, int depth)
931 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
937 if(!prs_ntstatus("status", ps, depth, &r_u->status))
943 /*******************************************************************
944 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
945 ********************************************************************/
947 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
948 prs_struct *ps, int depth)
953 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
959 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
962 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
966 if(!prs_ntstatus("status", ps, depth, &r_u->status))
972 /*******************************************************************
973 reads or writes a SAM_STR1 structure.
974 ********************************************************************/
976 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
977 uint32 name_buf, uint32 desc_buf,
978 prs_struct *ps, int depth)
983 prs_debug(ps, depth, desc, "sam_io_sam_str1");
988 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
991 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
994 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1000 /*******************************************************************
1001 inits a SAM_ENTRY1 structure.
1002 ********************************************************************/
1004 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1005 UNISTR2 *sam_name, UNISTR2 *sam_full,
1006 UNISTR2 *sam_desc, uint32 rid_user,
1009 DEBUG(5, ("init_sam_entry1\n"));
1013 sam->user_idx = user_idx;
1014 sam->rid_user = rid_user;
1015 sam->acb_info = acb_info;
1017 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1018 init_uni_hdr(&sam->hdr_user_name, sam_full);
1019 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1022 /*******************************************************************
1023 reads or writes a SAM_ENTRY1 structure.
1024 ********************************************************************/
1026 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1027 prs_struct *ps, int depth)
1032 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1038 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1041 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1043 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1049 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1051 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1053 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1059 /*******************************************************************
1060 reads or writes a SAM_STR2 structure.
1061 ********************************************************************/
1063 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1064 uint32 desc_buf, prs_struct *ps, int depth)
1069 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1075 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1077 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1083 /*******************************************************************
1084 inits a SAM_ENTRY2 structure.
1085 ********************************************************************/
1086 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1087 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1088 uint32 rid_user, uint16 acb_info)
1090 DEBUG(5, ("init_sam_entry2\n"));
1092 sam->user_idx = user_idx;
1093 sam->rid_user = rid_user;
1094 sam->acb_info = acb_info;
1096 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1097 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1100 /*******************************************************************
1101 reads or writes a SAM_ENTRY2 structure.
1102 ********************************************************************/
1104 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1105 prs_struct *ps, int depth)
1110 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1116 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1119 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1121 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1127 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1129 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1135 /*******************************************************************
1136 reads or writes a SAM_STR3 structure.
1137 ********************************************************************/
1139 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1140 uint32 desc_buf, prs_struct *ps, int depth)
1145 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1151 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1153 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1159 /*******************************************************************
1160 inits a SAM_ENTRY3 structure.
1161 ********************************************************************/
1163 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1164 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1167 DEBUG(5, ("init_sam_entry3\n"));
1169 sam->grp_idx = grp_idx;
1170 sam->rid_grp = rid_grp;
1171 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1173 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1174 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1177 /*******************************************************************
1178 reads or writes a SAM_ENTRY3 structure.
1179 ********************************************************************/
1181 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1182 prs_struct *ps, int depth)
1187 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1193 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1196 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1198 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1201 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1203 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1209 /*******************************************************************
1210 inits a SAM_ENTRY4 structure.
1211 ********************************************************************/
1213 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1214 uint32 len_acct_name)
1216 DEBUG(5, ("init_sam_entry4\n"));
1218 sam->user_idx = user_idx;
1219 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1222 /*******************************************************************
1223 reads or writes a SAM_ENTRY4 structure.
1224 ********************************************************************/
1226 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1227 prs_struct *ps, int depth)
1232 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1238 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1240 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1246 /*******************************************************************
1247 inits a SAM_ENTRY5 structure.
1248 ********************************************************************/
1250 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1251 uint32 len_grp_name)
1253 DEBUG(5, ("init_sam_entry5\n"));
1255 sam->grp_idx = grp_idx;
1256 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1260 /*******************************************************************
1261 reads or writes a SAM_ENTRY5 structure.
1262 ********************************************************************/
1264 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1265 prs_struct *ps, int depth)
1270 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1276 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1278 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1284 /*******************************************************************
1285 inits a SAM_ENTRY structure.
1286 ********************************************************************/
1288 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1290 DEBUG(10, ("init_sam_entry: %d\n", rid));
1293 init_uni_hdr(&sam->hdr_name, uni2);
1296 /*******************************************************************
1297 reads or writes a SAM_ENTRY structure.
1298 ********************************************************************/
1300 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1301 prs_struct *ps, int depth)
1306 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1311 if(!prs_uint32("rid", ps, depth, &sam->rid))
1313 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1319 /*******************************************************************
1320 inits a SAMR_Q_ENUM_DOM_USERS structure.
1321 ********************************************************************/
1323 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1325 uint16 acb_mask, uint16 unk_1, uint32 size)
1327 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1331 q_e->start_idx = start_idx; /* zero indicates lots */
1332 q_e->acb_mask = acb_mask;
1333 q_e->unknown_1 = unk_1;
1334 q_e->max_size = size;
1337 /*******************************************************************
1338 reads or writes a structure.
1339 ********************************************************************/
1341 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1342 prs_struct *ps, int depth)
1347 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1353 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1356 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1358 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1360 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1363 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1370 /*******************************************************************
1371 inits a SAMR_R_ENUM_DOM_USERS structure.
1372 ********************************************************************/
1374 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1375 uint32 next_idx, uint32 num_sam_entries)
1377 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1379 r_u->next_idx = next_idx;
1381 if (num_sam_entries != 0) {
1382 r_u->ptr_entries1 = 1;
1383 r_u->ptr_entries2 = 1;
1384 r_u->num_entries2 = num_sam_entries;
1385 r_u->num_entries3 = num_sam_entries;
1387 r_u->num_entries4 = num_sam_entries;
1389 r_u->ptr_entries1 = 0;
1390 r_u->num_entries2 = num_sam_entries;
1391 r_u->ptr_entries2 = 1;
1395 /*******************************************************************
1396 reads or writes a structure.
1397 ********************************************************************/
1399 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1400 prs_struct *ps, int depth)
1407 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1413 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1415 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1418 if (r_u->ptr_entries1 != 0) {
1419 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1421 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1423 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1426 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1427 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1428 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1431 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1432 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1433 r_u->num_entries4 = 0;
1434 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1438 for (i = 0; i < r_u->num_entries2; i++) {
1439 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1443 for (i = 0; i < r_u->num_entries2; i++) {
1444 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1453 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1455 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1461 /*******************************************************************
1462 inits a SAMR_Q_QUERY_DISPINFO structure.
1463 ********************************************************************/
1465 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1466 uint16 switch_level, uint32 start_idx,
1467 uint32 max_entries, uint32 max_size)
1469 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1471 q_e->domain_pol = *pol;
1473 q_e->switch_level = switch_level;
1475 q_e->start_idx = start_idx;
1476 q_e->max_entries = max_entries;
1477 q_e->max_size = max_size;
1480 /*******************************************************************
1481 reads or writes a structure.
1482 ********************************************************************/
1484 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1485 prs_struct *ps, int depth)
1490 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1496 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1499 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1504 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1506 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1508 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1514 /*******************************************************************
1515 inits a SAM_DISPINFO_1 structure.
1516 ********************************************************************/
1518 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1519 uint32 num_entries, uint32 start_idx,
1520 struct samr_displayentry *entries)
1524 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1527 return NT_STATUS_OK;
1529 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1531 return NT_STATUS_NO_MEMORY;
1533 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1534 if ((*sam)->sam == NULL)
1535 return NT_STATUS_NO_MEMORY;
1537 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1538 if ((*sam)->str == NULL)
1539 return NT_STATUS_NO_MEMORY;
1541 for (i = 0; i < num_entries ; i++) {
1542 init_unistr2(&(*sam)->str[i].uni_acct_name,
1543 entries[i].account_name, UNI_FLAGS_NONE);
1544 init_unistr2(&(*sam)->str[i].uni_full_name,
1545 entries[i].fullname, UNI_FLAGS_NONE);
1546 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1547 entries[i].description, UNI_FLAGS_NONE);
1549 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1550 &(*sam)->str[i].uni_acct_name,
1551 &(*sam)->str[i].uni_full_name,
1552 &(*sam)->str[i].uni_acct_desc,
1553 entries[i].rid, entries[i].acct_flags);
1556 return NT_STATUS_OK;
1559 /*******************************************************************
1560 reads or writes a structure.
1561 ********************************************************************/
1563 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1565 prs_struct *ps, int depth)
1569 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1575 if (UNMARSHALLING(ps) && num_entries > 0) {
1577 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1578 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1582 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1583 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1588 for (i = 0; i < num_entries; i++) {
1589 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1593 for (i = 0; i < num_entries; i++) {
1594 if(!sam_io_sam_str1("", &sam->str[i],
1595 sam->sam[i].hdr_acct_name.buffer,
1596 sam->sam[i].hdr_user_name.buffer,
1597 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1604 /*******************************************************************
1605 inits a SAM_DISPINFO_2 structure.
1606 ********************************************************************/
1608 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1609 uint32 num_entries, uint32 start_idx,
1610 struct samr_displayentry *entries)
1614 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1617 return NT_STATUS_OK;
1619 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1621 return NT_STATUS_NO_MEMORY;
1623 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1624 if ((*sam)->sam == NULL)
1625 return NT_STATUS_NO_MEMORY;
1627 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1628 if ((*sam)->str == NULL)
1629 return NT_STATUS_NO_MEMORY;
1631 for (i = 0; i < num_entries; i++) {
1632 init_unistr2(&(*sam)->str[i].uni_srv_name,
1633 entries[i].account_name, UNI_FLAGS_NONE);
1634 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1635 entries[i].description, UNI_FLAGS_NONE);
1637 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1638 &(*sam)->str[i].uni_srv_name,
1639 &(*sam)->str[i].uni_srv_desc,
1640 entries[i].rid, entries[i].acct_flags);
1643 return NT_STATUS_OK;
1646 /*******************************************************************
1647 reads or writes a structure.
1648 ********************************************************************/
1650 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1652 prs_struct *ps, int depth)
1659 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1665 if (UNMARSHALLING(ps) && num_entries > 0) {
1667 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1668 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1672 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1673 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1678 for (i = 0; i < num_entries; i++) {
1679 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1683 for (i = 0; i < num_entries; i++) {
1684 if(!sam_io_sam_str2("", &sam->str[i],
1685 sam->sam[i].hdr_srv_name.buffer,
1686 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1693 /*******************************************************************
1694 inits a SAM_DISPINFO_3 structure.
1695 ********************************************************************/
1697 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1698 uint32 num_entries, uint32 start_idx,
1699 struct samr_displayentry *entries)
1703 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1706 return NT_STATUS_OK;
1708 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1710 return NT_STATUS_NO_MEMORY;
1712 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1713 return NT_STATUS_NO_MEMORY;
1715 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1716 return NT_STATUS_NO_MEMORY;
1718 for (i = 0; i < num_entries; i++) {
1719 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1721 init_unistr2(&(*sam)->str[i].uni_grp_name,
1722 entries[i].account_name, UNI_FLAGS_NONE);
1723 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1724 entries[i].description, UNI_FLAGS_NONE);
1726 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1727 &(*sam)->str[i].uni_grp_name,
1728 &(*sam)->str[i].uni_grp_desc,
1732 return NT_STATUS_OK;
1735 /*******************************************************************
1736 reads or writes a structure.
1737 ********************************************************************/
1739 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1741 prs_struct *ps, int depth)
1748 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1754 if (UNMARSHALLING(ps) && num_entries > 0) {
1756 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1757 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1761 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1762 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1767 for (i = 0; i < num_entries; i++) {
1768 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1772 for (i = 0; i < num_entries; i++) {
1773 if(!sam_io_sam_str3("", &sam->str[i],
1774 sam->sam[i].hdr_grp_name.buffer,
1775 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1782 /*******************************************************************
1783 inits a SAM_DISPINFO_4 structure.
1784 ********************************************************************/
1786 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1787 uint32 num_entries, uint32 start_idx,
1788 struct samr_displayentry *entries)
1792 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1795 return NT_STATUS_OK;
1797 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1799 return NT_STATUS_NO_MEMORY;
1801 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1802 if ((*sam)->sam == NULL)
1803 return NT_STATUS_NO_MEMORY;
1805 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1806 if ((*sam)->str == NULL)
1807 return NT_STATUS_NO_MEMORY;
1809 for (i = 0; i < num_entries; i++) {
1810 size_t len_sam_name = strlen(entries[i].account_name);
1812 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1814 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1817 init_string2(&(*sam)->str[i].acct_name,
1818 entries[i].account_name, len_sam_name+1,
1822 return NT_STATUS_OK;
1825 /*******************************************************************
1826 reads or writes a structure.
1827 ********************************************************************/
1829 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1831 prs_struct *ps, int depth)
1838 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1844 if (UNMARSHALLING(ps) && num_entries > 0) {
1846 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1847 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1851 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1852 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1857 for (i = 0; i < num_entries; i++) {
1858 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1862 for (i = 0; i < num_entries; i++) {
1863 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1864 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1871 /*******************************************************************
1872 inits a SAM_DISPINFO_5 structure.
1873 ********************************************************************/
1875 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1876 uint32 num_entries, uint32 start_idx,
1877 struct samr_displayentry *entries)
1879 uint32 len_sam_name;
1882 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1885 return NT_STATUS_OK;
1887 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1889 return NT_STATUS_NO_MEMORY;
1891 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1892 return NT_STATUS_NO_MEMORY;
1894 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1895 return NT_STATUS_NO_MEMORY;
1897 for (i = 0; i < num_entries; i++) {
1898 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1900 len_sam_name = strlen(entries[i].account_name);
1902 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
1903 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
1904 len_sam_name+1, len_sam_name);
1907 return NT_STATUS_OK;
1910 /*******************************************************************
1911 reads or writes a structure.
1912 ********************************************************************/
1914 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1916 prs_struct *ps, int depth)
1923 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1929 if (UNMARSHALLING(ps) && num_entries > 0) {
1931 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1932 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1936 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1937 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1942 for (i = 0; i < num_entries; i++) {
1943 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1947 for (i = 0; i < num_entries; i++) {
1948 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1949 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1956 /*******************************************************************
1957 inits a SAMR_R_QUERY_DISPINFO structure.
1958 ********************************************************************/
1960 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1961 uint32 num_entries, uint32 total_size, uint32 data_size,
1962 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1965 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1967 r_u->total_size = total_size;
1969 r_u->data_size = data_size;
1971 r_u->switch_level = switch_level;
1972 r_u->num_entries = num_entries;
1975 r_u->ptr_entries = 0;
1977 r_u->ptr_entries = 1;
1979 r_u->num_entries2 = num_entries;
1982 r_u->status = status;
1985 /*******************************************************************
1986 reads or writes a structure.
1987 ********************************************************************/
1989 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1990 prs_struct *ps, int depth)
1995 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2001 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2003 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2005 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2010 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2012 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2015 if (r_u->ptr_entries==0) {
2018 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2024 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2027 switch (r_u->switch_level) {
2029 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2030 r_u->num_entries, ps, depth))
2034 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2035 r_u->num_entries, ps, depth))
2039 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2040 r_u->num_entries, ps, depth))
2044 if(!sam_io_sam_dispinfo_4("user list",
2045 r_u->ctr->sam.info4,
2046 r_u->num_entries, ps, depth))
2050 if(!sam_io_sam_dispinfo_5("group list",
2051 r_u->ctr->sam.info5,
2052 r_u->num_entries, ps, depth))
2056 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2062 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2068 /*******************************************************************
2069 inits a SAMR_Q_OPEN_GROUP structure.
2070 ********************************************************************/
2072 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2074 uint32 access_mask, uint32 rid)
2076 DEBUG(5, ("init_samr_q_open_group\n"));
2078 q_c->domain_pol = *hnd;
2079 q_c->access_mask = access_mask;
2080 q_c->rid_group = rid;
2083 /*******************************************************************
2084 reads or writes a structure.
2085 ********************************************************************/
2087 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2088 prs_struct *ps, int depth)
2093 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2099 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2102 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2104 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2110 /*******************************************************************
2111 reads or writes a structure.
2112 ********************************************************************/
2114 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2115 prs_struct *ps, int depth)
2120 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2126 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2129 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2135 /*******************************************************************
2136 inits a GROUP_INFO1 structure.
2137 ********************************************************************/
2139 void init_samr_group_info1(GROUP_INFO1 * gr1,
2140 char *acct_name, char *acct_desc,
2143 DEBUG(5, ("init_samr_group_info1\n"));
2145 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2146 gr1->num_members = num_members;
2148 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2149 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2150 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2151 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2154 /*******************************************************************
2155 reads or writes a structure.
2156 ********************************************************************/
2158 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2159 prs_struct *ps, int depth)
2166 prs_debug(ps, depth, desc, "samr_io_group_info1");
2169 if(!prs_uint16("level", ps, depth, &dummy))
2175 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2178 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2180 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2183 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2186 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2187 gr1->hdr_acct_name.buffer, ps, depth))
2190 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2191 gr1->hdr_acct_desc.buffer, ps, depth))
2197 /*******************************************************************
2198 inits a GROUP_INFO2 structure.
2199 ********************************************************************/
2201 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2203 DEBUG(5, ("init_samr_group_info2\n"));
2206 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2207 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2210 /*******************************************************************
2211 reads or writes a structure.
2212 ********************************************************************/
2214 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2219 prs_debug(ps, depth, desc, "samr_io_group_info2");
2222 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2225 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2227 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2228 gr2->hdr_acct_name.buffer, ps, depth))
2234 /*******************************************************************
2235 inits a GROUP_INFO3 structure.
2236 ********************************************************************/
2238 void init_samr_group_info3(GROUP_INFO3 *gr3)
2240 DEBUG(5, ("init_samr_group_info3\n"));
2242 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2245 /*******************************************************************
2246 reads or writes a structure.
2247 ********************************************************************/
2249 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2254 prs_debug(ps, depth, desc, "samr_io_group_info3");
2260 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2266 /*******************************************************************
2267 inits a GROUP_INFO4 structure.
2268 ********************************************************************/
2270 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2272 DEBUG(5, ("init_samr_group_info4\n"));
2275 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2276 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2279 /*******************************************************************
2280 reads or writes a structure.
2281 ********************************************************************/
2283 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2284 prs_struct *ps, int depth)
2289 prs_debug(ps, depth, desc, "samr_io_group_info4");
2292 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2294 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2296 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2297 gr4->hdr_acct_desc.buffer, ps, depth))
2303 /*******************************************************************
2304 reads or writes a structure.
2305 ********************************************************************/
2307 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2308 prs_struct *ps, int depth)
2310 if (UNMARSHALLING(ps))
2311 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2316 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2319 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2322 switch ((*ctr)->switch_value1) {
2324 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2328 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2332 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2336 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2340 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2347 /*******************************************************************
2348 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2349 ********************************************************************/
2351 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2352 POLICY_HND *pol, const char *acct_desc,
2355 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2359 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2360 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2362 q_e->access_mask = access_mask;
2365 /*******************************************************************
2366 reads or writes a structure.
2367 ********************************************************************/
2369 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2370 prs_struct *ps, int depth)
2375 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2381 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2384 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2386 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2387 q_e->hdr_acct_desc.buffer, ps, depth))
2392 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2398 /*******************************************************************
2399 reads or writes a structure.
2400 ********************************************************************/
2402 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2403 prs_struct *ps, int depth)
2408 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2414 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2417 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2419 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2425 /*******************************************************************
2426 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2427 ********************************************************************/
2429 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2432 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2434 q_c->group_pol = *hnd;
2437 /*******************************************************************
2438 reads or writes a structure.
2439 ********************************************************************/
2441 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2442 prs_struct *ps, int depth)
2447 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2453 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2459 /*******************************************************************
2460 reads or writes a structure.
2461 ********************************************************************/
2463 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2464 prs_struct *ps, int depth)
2469 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2475 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2478 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2484 /*******************************************************************
2485 inits a SAMR_Q_DEL_GROUPMEM structure.
2486 ********************************************************************/
2488 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2489 POLICY_HND *pol, uint32 rid)
2491 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2497 /*******************************************************************
2498 reads or writes a structure.
2499 ********************************************************************/
2501 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2502 prs_struct *ps, int depth)
2507 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2513 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2516 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2522 /*******************************************************************
2523 inits a SAMR_R_DEL_GROUPMEM structure.
2524 ********************************************************************/
2526 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2529 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2531 r_u->status = status;
2534 /*******************************************************************
2535 reads or writes a structure.
2536 ********************************************************************/
2538 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2539 prs_struct *ps, int depth)
2544 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2550 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2556 /*******************************************************************
2557 inits a SAMR_Q_ADD_GROUPMEM structure.
2558 ********************************************************************/
2560 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2561 POLICY_HND *pol, uint32 rid)
2563 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2567 q_e->unknown = 0x0005;
2570 /*******************************************************************
2571 reads or writes a structure.
2572 ********************************************************************/
2574 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2575 prs_struct *ps, int depth)
2580 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2586 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2589 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2591 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2597 /*******************************************************************
2598 inits a SAMR_R_ADD_GROUPMEM structure.
2599 ********************************************************************/
2601 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2604 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2606 r_u->status = status;
2609 /*******************************************************************
2610 reads or writes a structure.
2611 ********************************************************************/
2613 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2614 prs_struct *ps, int depth)
2619 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2625 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2631 /*******************************************************************
2632 inits a SAMR_Q_SET_GROUPINFO structure.
2633 ********************************************************************/
2635 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2636 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2638 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2644 /*******************************************************************
2645 reads or writes a structure.
2646 ********************************************************************/
2648 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2649 prs_struct *ps, int depth)
2654 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2660 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2663 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2669 /*******************************************************************
2670 inits a SAMR_R_SET_GROUPINFO structure.
2671 ********************************************************************/
2673 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2675 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2677 r_u->status = status;
2680 /*******************************************************************
2681 reads or writes a structure.
2682 ********************************************************************/
2684 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2685 prs_struct *ps, int depth)
2690 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2696 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2702 /*******************************************************************
2703 inits a SAMR_Q_QUERY_GROUPINFO structure.
2704 ********************************************************************/
2706 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2707 POLICY_HND *pol, uint16 switch_level)
2709 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2713 q_e->switch_level = switch_level;
2716 /*******************************************************************
2717 reads or writes a structure.
2718 ********************************************************************/
2720 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2721 prs_struct *ps, int depth)
2726 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2732 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2735 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2741 /*******************************************************************
2742 inits a SAMR_R_QUERY_GROUPINFO structure.
2743 ********************************************************************/
2745 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2746 GROUP_INFO_CTR * ctr, NTSTATUS status)
2748 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2750 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2752 r_u->status = status;
2755 /*******************************************************************
2756 reads or writes a structure.
2757 ********************************************************************/
2759 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2760 prs_struct *ps, int depth)
2765 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2771 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2774 if (r_u->ptr != 0) {
2775 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2781 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2787 /*******************************************************************
2788 inits a SAMR_Q_QUERY_GROUPMEM structure.
2789 ********************************************************************/
2791 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2793 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2795 q_c->group_pol = *hnd;
2798 /*******************************************************************
2799 reads or writes a structure.
2800 ********************************************************************/
2802 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2803 prs_struct *ps, int depth)
2808 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2814 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2820 /*******************************************************************
2821 inits a SAMR_R_QUERY_GROUPMEM structure.
2822 ********************************************************************/
2824 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2825 uint32 num_entries, uint32 *rid,
2826 uint32 *attr, NTSTATUS status)
2828 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2830 if (NT_STATUS_IS_OK(status)) {
2832 r_u->num_entries = num_entries;
2834 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2835 r_u->ptr_rids = rid != NULL ? 1 : 0;
2837 r_u->num_rids = num_entries;
2840 r_u->num_attrs = num_entries;
2844 r_u->num_entries = 0;
2847 r_u->status = status;
2850 /*******************************************************************
2851 reads or writes a structure.
2852 ********************************************************************/
2854 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2855 prs_struct *ps, int depth)
2862 if (UNMARSHALLING(ps))
2865 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2871 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2873 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2876 if (r_u->ptr != 0) {
2877 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2879 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2882 if (r_u->ptr_rids != 0) {
2883 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2885 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2886 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2887 if (r_u->rid == NULL)
2891 for (i = 0; i < r_u->num_rids; i++) {
2892 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2897 if (r_u->ptr_attrs != 0) {
2898 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2901 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2902 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2903 if (r_u->attr == NULL)
2907 for (i = 0; i < r_u->num_attrs; i++) {
2908 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2914 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2920 /*******************************************************************
2921 inits a SAMR_Q_QUERY_USERGROUPS structure.
2922 ********************************************************************/
2924 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2927 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2932 /*******************************************************************
2933 reads or writes a structure.
2934 ********************************************************************/
2936 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2937 prs_struct *ps, int depth)
2942 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2948 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2954 /*******************************************************************
2955 inits a SAMR_R_QUERY_USERGROUPS structure.
2956 ********************************************************************/
2958 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2959 uint32 num_gids, DOM_GID * gid,
2962 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2964 if (NT_STATUS_IS_OK(status)) {
2966 r_u->num_entries = num_gids;
2967 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2968 r_u->num_entries2 = num_gids;
2973 r_u->num_entries = 0;
2978 r_u->status = status;
2981 /*******************************************************************
2982 reads or writes a structure.
2983 ********************************************************************/
2985 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
2986 prs_struct *ps, int depth)
2992 prs_debug(ps, depth, desc, "samr_io_gids");
2998 if(!prs_uint32("num_gids", ps, depth, num_gids))
3001 if ((*num_gids) != 0) {
3002 if (UNMARSHALLING(ps)) {
3003 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3006 if ((*gid) == NULL) {
3010 for (i = 0; i < (*num_gids); i++) {
3011 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3019 /*******************************************************************
3020 reads or writes a structure.
3021 ********************************************************************/
3023 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3024 prs_struct *ps, int depth)
3029 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3035 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3038 if (r_u->ptr_0 != 0) {
3039 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3041 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3044 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3045 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3052 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3058 /*******************************************************************
3059 inits a SAMR_Q_ENUM_DOMAINS structure.
3060 ********************************************************************/
3062 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3064 uint32 start_idx, uint32 size)
3066 DEBUG(5, ("init_samr_q_enum_domains\n"));
3070 q_e->start_idx = start_idx;
3071 q_e->max_size = size;
3074 /*******************************************************************
3075 reads or writes a structure.
3076 ********************************************************************/
3078 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3079 prs_struct *ps, int depth)
3084 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3090 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3093 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3095 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3101 /*******************************************************************
3102 inits a SAMR_R_ENUM_DOMAINS structure.
3103 ********************************************************************/
3105 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3106 uint32 next_idx, uint32 num_sam_entries)
3108 DEBUG(5, ("init_samr_r_enum_domains\n"));
3110 r_u->next_idx = next_idx;
3112 if (num_sam_entries != 0) {
3113 r_u->ptr_entries1 = 1;
3114 r_u->ptr_entries2 = 1;
3115 r_u->num_entries2 = num_sam_entries;
3116 r_u->num_entries3 = num_sam_entries;
3118 r_u->num_entries4 = num_sam_entries;
3120 r_u->ptr_entries1 = 0;
3121 r_u->num_entries2 = num_sam_entries;
3122 r_u->ptr_entries2 = 1;
3126 /*******************************************************************
3127 reads or writes a structure.
3128 ********************************************************************/
3130 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3131 prs_struct *ps, int depth)
3138 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3144 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3146 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3149 if (r_u->ptr_entries1 != 0) {
3150 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3152 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3154 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3157 if (UNMARSHALLING(ps)) {
3158 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3159 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3162 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3163 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3164 r_u->num_entries4 = 0;
3165 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3169 for (i = 0; i < r_u->num_entries2; i++) {
3171 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3172 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3176 for (i = 0; i < r_u->num_entries2; i++) {
3178 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3179 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3180 r_u->sam[i].hdr_name.buffer, ps,
3189 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3191 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3197 /*******************************************************************
3198 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3199 ********************************************************************/
3201 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3203 uint32 start_idx, uint32 size)
3205 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3209 q_e->start_idx = start_idx;
3210 q_e->max_size = size;
3213 /*******************************************************************
3214 reads or writes a structure.
3215 ********************************************************************/
3217 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3218 prs_struct *ps, int depth)
3223 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3229 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3232 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3234 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3240 /*******************************************************************
3241 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3242 ********************************************************************/
3244 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3245 uint32 next_idx, uint32 num_sam_entries)
3247 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3249 r_u->next_idx = next_idx;
3251 if (num_sam_entries != 0) {
3252 r_u->ptr_entries1 = 1;
3253 r_u->ptr_entries2 = 1;
3254 r_u->num_entries2 = num_sam_entries;
3255 r_u->num_entries3 = num_sam_entries;
3257 r_u->num_entries4 = num_sam_entries;
3259 r_u->ptr_entries1 = 0;
3260 r_u->num_entries2 = num_sam_entries;
3261 r_u->ptr_entries2 = 1;
3265 /*******************************************************************
3266 reads or writes a structure.
3267 ********************************************************************/
3269 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3270 prs_struct *ps, int depth)
3277 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3283 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3285 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3288 if (r_u->ptr_entries1 != 0) {
3289 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3291 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3293 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3296 if (UNMARSHALLING(ps)) {
3297 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3298 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3301 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3303 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3304 r_u->num_entries4 = 0;
3305 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3309 for (i = 0; i < r_u->num_entries2; i++) {
3310 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3314 for (i = 0; i < r_u->num_entries2; i++) {
3315 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3316 r_u->sam[i].hdr_name.buffer, ps, depth))
3323 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3325 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3331 /*******************************************************************
3332 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3333 ********************************************************************/
3335 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3336 POLICY_HND *pol, uint32 start_idx,
3339 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3343 q_e->start_idx = start_idx;
3344 q_e->max_size = size;
3348 /*******************************************************************
3349 reads or writes a structure.
3350 ********************************************************************/
3352 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3353 prs_struct *ps, int depth)
3358 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3364 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3367 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3369 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3375 /*******************************************************************
3376 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3377 ********************************************************************/
3379 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3381 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3383 r_u->next_idx = next_idx;
3385 if (num_sam_entries != 0) {
3386 r_u->ptr_entries1 = 1;
3387 r_u->ptr_entries2 = 1;
3388 r_u->num_entries2 = num_sam_entries;
3389 r_u->num_entries3 = num_sam_entries;
3391 r_u->num_entries4 = num_sam_entries;
3393 r_u->ptr_entries1 = 0;
3394 r_u->num_entries2 = num_sam_entries;
3395 r_u->ptr_entries2 = 1;
3399 /*******************************************************************
3400 reads or writes a structure.
3401 ********************************************************************/
3403 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3404 prs_struct *ps, int depth)
3411 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3417 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3419 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3422 if (r_u->ptr_entries1 != 0) {
3423 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3425 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3427 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3430 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3431 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3432 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3435 if (r_u->num_entries2 != 0 &&
3436 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3437 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3438 r_u->num_entries4 = 0;
3439 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3443 for (i = 0; i < r_u->num_entries2; i++) {
3444 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3448 for (i = 0; i < r_u->num_entries2; i++) {
3449 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3450 r_u->sam[i].hdr_name.buffer, ps,
3458 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3460 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3466 /*******************************************************************
3467 inits a ALIAS_INFO1 structure.
3468 ********************************************************************/
3470 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3472 DEBUG(5, ("init_samr_alias_info1\n"));
3474 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3475 al1->num_member = num_member;
3476 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3479 /*******************************************************************
3480 reads or writes a structure.
3481 ********************************************************************/
3483 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3484 prs_struct *ps, int depth)
3489 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3495 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3497 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3499 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3502 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3504 if ( !prs_align(ps) )
3506 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3508 if ( !prs_align(ps) )
3514 /*******************************************************************
3515 inits a ALIAS_INFO3 structure.
3516 ********************************************************************/
3518 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3520 DEBUG(5, ("init_samr_alias_info3\n"));
3522 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3525 /*******************************************************************
3526 reads or writes a structure.
3527 ********************************************************************/
3529 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3530 prs_struct *ps, int depth)
3535 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3541 if (!prs_unistr4("description", ps, depth, &al3->description))
3547 /*******************************************************************
3548 reads or writes a structure.
3549 ********************************************************************/
3551 BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3556 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3559 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3564 switch (ctr->level) {
3566 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3570 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3574 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3581 /*******************************************************************
3582 inits a SAMR_Q_QUERY_ALIASINFO structure.
3583 ********************************************************************/
3585 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3586 POLICY_HND *pol, uint32 switch_level)
3588 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3591 q_e->level = switch_level;
3594 /*******************************************************************
3595 reads or writes a structure.
3596 ********************************************************************/
3598 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3599 prs_struct *ps, int depth)
3604 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3610 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3613 if ( !prs_uint16("level", ps, depth, &in->level) )
3619 /*******************************************************************
3620 inits a SAMR_R_QUERY_ALIASINFO structure.
3621 ********************************************************************/
3623 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3624 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3626 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3629 out->status = status;
3632 /*******************************************************************
3633 reads or writes a structure.
3634 ********************************************************************/
3636 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3637 prs_struct *ps, int depth)
3642 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3648 if ( !prs_pointer("alias", ps, depth, (void**)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3653 if(!prs_ntstatus("status", ps, depth, &out->status))
3659 /*******************************************************************
3660 inits a SAMR_Q_SET_ALIASINFO structure.
3661 ********************************************************************/
3663 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3664 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3666 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3668 q_u->alias_pol = *hnd;
3672 /*******************************************************************
3673 reads or writes a structure.
3674 ********************************************************************/
3676 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3677 prs_struct *ps, int depth)
3682 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3688 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3690 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3696 /*******************************************************************
3697 reads or writes a structure.
3698 ********************************************************************/
3700 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3701 prs_struct *ps, int depth)
3706 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3711 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3717 /*******************************************************************
3718 inits a SAMR_Q_QUERY_USERALIASES structure.
3719 ********************************************************************/
3721 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3724 uint32 *ptr_sid, DOM_SID2 * sid)
3726 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3730 q_u->num_sids1 = num_sids;
3732 q_u->num_sids2 = num_sids;
3734 q_u->ptr_sid = ptr_sid;
3738 /*******************************************************************
3739 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3740 ********************************************************************/
3742 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3743 prs_struct *ps, int depth)
3751 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3757 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3760 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3762 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3768 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3771 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3772 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3773 if (q_u->ptr_sid == NULL)
3776 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3777 if (q_u->sid == NULL)
3781 for (i = 0; i < q_u->num_sids2; i++) {
3782 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3783 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3787 for (i = 0; i < q_u->num_sids2; i++) {
3788 if (q_u->ptr_sid[i] != 0) {
3789 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3790 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3798 /*******************************************************************
3799 inits a SAMR_R_QUERY_USERALIASES structure.
3800 ********************************************************************/
3802 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3803 uint32 num_rids, uint32 *rid,
3806 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3808 if (NT_STATUS_IS_OK(status)) {
3809 r_u->num_entries = num_rids;
3811 r_u->num_entries2 = num_rids;
3815 r_u->num_entries = 0;
3817 r_u->num_entries2 = 0;
3820 r_u->status = status;
3823 /*******************************************************************
3824 reads or writes a structure.
3825 ********************************************************************/
3827 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3828 prs_struct *ps, int depth)
3835 prs_debug(ps, depth, desc, "samr_io_rids");
3841 if(!prs_uint32("num_rids", ps, depth, num_rids))
3844 if ((*num_rids) != 0) {
3845 if (UNMARSHALLING(ps)) {
3847 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3852 for (i = 0; i < (*num_rids); i++) {
3853 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3854 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3862 /*******************************************************************
3863 reads or writes a structure.
3864 ********************************************************************/
3866 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3867 prs_struct *ps, int depth)
3872 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3878 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3880 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3883 if (r_u->ptr != 0) {
3884 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3890 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3896 /*******************************************************************
3897 inits a SAMR_Q_OPEN_ALIAS structure.
3898 ********************************************************************/
3900 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3901 uint32 access_mask, uint32 rid)
3903 DEBUG(5, ("init_samr_q_open_alias\n"));
3905 q_u->dom_pol = *pol;
3906 q_u->access_mask = access_mask;
3907 q_u->rid_alias = rid;
3910 /*******************************************************************
3911 reads or writes a structure.
3912 ********************************************************************/
3914 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3915 prs_struct *ps, int depth)
3920 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3926 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3929 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3931 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3937 /*******************************************************************
3938 reads or writes a structure.
3939 ********************************************************************/
3941 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
3942 prs_struct *ps, int depth)
3947 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3953 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3956 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3962 /*******************************************************************
3963 inits a SAMR_Q_LOOKUP_RIDS structure.
3964 ********************************************************************/
3966 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3967 POLICY_HND *pol, uint32 flags,
3968 uint32 num_rids, uint32 *rid)
3970 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3974 q_u->num_rids1 = num_rids;
3977 q_u->num_rids2 = num_rids;
3978 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
3979 if (q_u->rid == NULL) {
3983 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
3987 /*******************************************************************
3988 reads or writes a structure.
3989 ********************************************************************/
3991 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
3992 prs_struct *ps, int depth)
4000 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4003 if (UNMARSHALLING(ps))
4009 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4012 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4014 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4016 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4018 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4021 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4022 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4023 if (q_u->rid == NULL)
4027 for (i = 0; i < q_u->num_rids2; i++) {
4028 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4029 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4036 /*******************************************************************
4037 inits a SAMR_R_LOOKUP_RIDS structure.
4038 ********************************************************************/
4040 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4041 uint32 num_names, UNIHDR * hdr_name,
4042 UNISTR2 *uni_name, uint32 *type)
4044 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4046 r_u->hdr_name = NULL;
4047 r_u->uni_name = NULL;
4050 if (num_names != 0) {
4051 r_u->num_names1 = num_names;
4053 r_u->num_names2 = num_names;
4055 r_u->num_types1 = num_names;
4057 r_u->num_types2 = num_names;
4059 r_u->hdr_name = hdr_name;
4060 r_u->uni_name = uni_name;
4063 r_u->num_names1 = num_names;
4065 r_u->num_names2 = num_names;
4067 r_u->num_types1 = num_names;
4069 r_u->num_types2 = num_names;
4073 /*******************************************************************
4074 reads or writes a structure.
4075 ********************************************************************/
4077 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4078 prs_struct *ps, int depth)
4085 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4091 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4093 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4096 if (r_u->ptr_names != 0) {
4098 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4102 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4103 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4104 if (r_u->hdr_name == NULL)
4107 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4108 if (r_u->uni_name == NULL)
4112 for (i = 0; i < r_u->num_names2; i++) {
4113 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4114 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4117 for (i = 0; i < r_u->num_names2; i++) {
4118 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4119 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4127 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4129 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4132 if (r_u->ptr_types != 0) {
4134 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4137 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4138 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4139 if (r_u->type == NULL)
4143 for (i = 0; i < r_u->num_types2; i++) {
4144 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4145 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4150 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4156 /*******************************************************************
4157 inits a SAMR_Q_OPEN_ALIAS structure.
4158 ********************************************************************/
4160 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4162 DEBUG(5, ("init_samr_q_delete_alias\n"));
4164 q_u->alias_pol = *hnd;
4167 /*******************************************************************
4168 reads or writes a structure.
4169 ********************************************************************/
4171 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4172 prs_struct *ps, int depth)
4177 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4183 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4189 /*******************************************************************
4190 reads or writes a structure.
4191 ********************************************************************/
4193 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4194 prs_struct *ps, int depth)
4199 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4205 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4207 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4213 /*******************************************************************
4214 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4215 ********************************************************************/
4217 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4218 POLICY_HND *hnd, const char *acct_desc)
4220 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4222 q_u->dom_pol = *hnd;
4224 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4225 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4227 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4230 /*******************************************************************
4231 reads or writes a structure.
4232 ********************************************************************/
4234 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4235 prs_struct *ps, int depth)
4240 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4246 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4249 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4251 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4252 q_u->hdr_acct_desc.buffer, ps, depth))
4257 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4263 /*******************************************************************
4264 reads or writes a structure.
4265 ********************************************************************/
4267 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4268 prs_struct *ps, int depth)
4273 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4279 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4282 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4285 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4291 /*******************************************************************
4292 inits a SAMR_Q_ADD_ALIASMEM structure.
4293 ********************************************************************/
4295 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4298 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4300 q_u->alias_pol = *hnd;
4301 init_dom_sid2(&q_u->sid, sid);
4304 /*******************************************************************
4305 reads or writes a structure.
4306 ********************************************************************/
4308 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4309 prs_struct *ps, int depth)
4314 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4320 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4322 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4328 /*******************************************************************
4329 reads or writes a structure.
4330 ********************************************************************/
4332 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4333 prs_struct *ps, int depth)
4338 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4344 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4350 /*******************************************************************
4351 inits a SAMR_Q_DEL_ALIASMEM structure.
4352 ********************************************************************/
4354 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4357 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4359 q_u->alias_pol = *hnd;
4360 init_dom_sid2(&q_u->sid, sid);
4363 /*******************************************************************
4364 reads or writes a structure.
4365 ********************************************************************/
4367 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4368 prs_struct *ps, int depth)
4373 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4379 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4381 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4387 /*******************************************************************
4388 reads or writes a structure.
4389 ********************************************************************/
4391 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4392 prs_struct *ps, int depth)
4397 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4403 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4409 /*******************************************************************
4410 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4411 ********************************************************************/
4413 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4416 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4418 q_c->alias_pol = *hnd;
4421 /*******************************************************************
4422 reads or writes a structure.
4423 ********************************************************************/
4425 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4426 prs_struct *ps, int depth)
4431 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4437 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4443 /*******************************************************************
4444 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4445 ********************************************************************/
4447 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4450 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4452 r_u->status = status;
4455 /*******************************************************************
4456 reads or writes a structure.
4457 ********************************************************************/
4459 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4460 prs_struct *ps, int depth)
4465 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4471 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4477 /*******************************************************************
4478 inits a SAMR_Q_QUERY_ALIASMEM structure.
4479 ********************************************************************/
4481 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4484 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4486 q_c->alias_pol = *hnd;
4489 /*******************************************************************
4490 reads or writes a structure.
4491 ********************************************************************/
4493 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4494 prs_struct *ps, int depth)
4499 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4505 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4511 /*******************************************************************
4512 inits a SAMR_R_QUERY_ALIASMEM structure.
4513 ********************************************************************/
4515 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4516 uint32 num_sids, DOM_SID2 * sid,
4519 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4521 if (NT_STATUS_IS_OK(status)) {
4522 r_u->num_sids = num_sids;
4523 r_u->ptr = (num_sids != 0) ? 1 : 0;
4524 r_u->num_sids1 = num_sids;
4532 r_u->status = status;
4535 /*******************************************************************
4536 reads or writes a structure.
4537 ********************************************************************/
4539 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4540 prs_struct *ps, int depth)
4547 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4553 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4555 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4558 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4559 uint32 *ptr_sid = NULL;
4561 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4564 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4569 for (i = 0; i < r_u->num_sids1; i++) {
4571 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4575 if (UNMARSHALLING(ps)) {
4576 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4579 for (i = 0; i < r_u->num_sids1; i++) {
4580 if (ptr_sid[i] != 0) {
4581 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4589 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4595 /*******************************************************************
4596 inits a SAMR_Q_LOOKUP_NAMES structure.
4597 ********************************************************************/
4599 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4600 POLICY_HND *pol, uint32 flags,
4601 uint32 num_names, const char **name)
4605 DEBUG(5, ("init_samr_q_lookup_names\n"));
4609 q_u->num_names1 = num_names;
4612 q_u->num_names2 = num_names;
4614 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4615 return NT_STATUS_NO_MEMORY;
4617 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4618 return NT_STATUS_NO_MEMORY;
4620 for (i = 0; i < num_names; i++) {
4621 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4622 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4625 return NT_STATUS_OK;
4628 /*******************************************************************
4629 reads or writes a structure.
4630 ********************************************************************/
4632 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4633 prs_struct *ps, int depth)
4640 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4643 if (UNMARSHALLING(ps))
4649 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4652 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4654 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4656 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4658 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4661 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4662 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4663 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4664 if (!q_u->hdr_name || !q_u->uni_name)
4668 for (i = 0; i < q_u->num_names2; i++) {
4669 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4673 for (i = 0; i < q_u->num_names2; i++) {
4674 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4681 /*******************************************************************
4682 inits a SAMR_R_LOOKUP_NAMES structure.
4683 ********************************************************************/
4685 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4687 uint32 *rid, uint32 *type,
4690 DEBUG(5, ("init_samr_r_lookup_names\n"));
4692 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4695 r_u->num_types1 = num_rids;
4697 r_u->num_types2 = num_rids;
4699 r_u->num_rids1 = num_rids;
4701 r_u->num_rids2 = num_rids;
4703 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4704 return NT_STATUS_NO_MEMORY;
4705 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4706 return NT_STATUS_NO_MEMORY;
4708 if (!r_u->rids || !r_u->types)
4711 for (i = 0; i < num_rids; i++) {
4712 r_u->rids[i] = rid[i];
4713 r_u->types[i] = type[i];
4718 r_u->num_types1 = 0;
4720 r_u->num_types2 = 0;
4730 r_u->status = status;
4732 return NT_STATUS_OK;
4735 /*******************************************************************
4736 reads or writes a structure.
4737 ********************************************************************/
4739 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4740 prs_struct *ps, int depth)
4748 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4751 if (UNMARSHALLING(ps))
4757 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4759 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4762 if (r_u->ptr_rids != 0) {
4763 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4766 if (r_u->num_rids2 != r_u->num_rids1) {
4771 if (UNMARSHALLING(ps))
4772 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4775 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4779 for (i = 0; i < r_u->num_rids2; i++) {
4780 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4781 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4786 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4788 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4791 if (r_u->ptr_types != 0) {
4792 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4795 if (r_u->num_types2 != r_u->num_types1) {
4800 if (UNMARSHALLING(ps))
4801 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4804 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4808 for (i = 0; i < r_u->num_types2; i++) {
4809 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4810 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4815 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4821 /*******************************************************************
4822 inits a SAMR_Q_DELETE_DOM_USER structure.
4823 ********************************************************************/
4825 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4828 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4830 q_c->user_pol = *hnd;
4833 /*******************************************************************
4834 reads or writes a structure.
4835 ********************************************************************/
4837 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4838 prs_struct *ps, int depth)
4843 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4849 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4855 /*******************************************************************
4856 reads or writes a structure.
4857 ********************************************************************/
4859 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4860 prs_struct *ps, int depth)
4865 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4871 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4873 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4879 /*******************************************************************
4880 reads or writes a structure.
4881 ********************************************************************/
4883 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4885 uint32 access_mask, uint32 rid)
4887 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4889 q_u->domain_pol = *pol;
4890 q_u->access_mask = access_mask;
4891 q_u->user_rid = rid;
4894 /*******************************************************************
4895 reads or writes a structure.
4896 ********************************************************************/
4898 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4899 prs_struct *ps, int depth)
4904 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4910 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4913 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4915 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4921 /*******************************************************************
4922 reads or writes a structure.
4923 ********************************************************************/
4925 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4926 prs_struct *ps, int depth)
4931 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4937 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4940 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4947 /*******************************************************************
4948 reads or writes a structure.
4949 ********************************************************************/
4951 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4954 uint32 acb_info, uint32 access_mask)
4956 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4958 q_u->domain_pol = *pol;
4960 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
4961 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
4963 q_u->acb_info = acb_info;
4964 q_u->access_mask = access_mask;
4967 /*******************************************************************
4968 reads or writes a structure.
4969 ********************************************************************/
4971 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
4972 prs_struct *ps, int depth)
4977 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4983 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4986 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
4988 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
4993 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
4995 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5001 /*******************************************************************
5002 reads or writes a structure.
5003 ********************************************************************/
5005 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5006 prs_struct *ps, int depth)
5011 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5017 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5020 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5022 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5024 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5030 /*******************************************************************
5031 inits a SAMR_Q_QUERY_USERINFO structure.
5032 ********************************************************************/
5034 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5035 const POLICY_HND *hnd, uint16 switch_value)
5037 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5040 q_u->switch_value = switch_value;
5043 /*******************************************************************
5044 reads or writes a structure.
5045 ********************************************************************/
5047 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5048 prs_struct *ps, int depth)
5053 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5059 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5062 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5068 /*******************************************************************
5069 reads or writes a LOGON_HRS structure.
5070 ********************************************************************/
5072 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5073 prs_struct *ps, int depth)
5078 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5084 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5087 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5090 if(!prs_uint32("len ", ps, depth, &hrs->len))
5093 if (hrs->len > sizeof(hrs->hours)) {
5094 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5095 hrs->len = sizeof(hrs->hours);
5098 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5104 /*******************************************************************
5105 inits a SAM_USER_INFO_18 structure.
5106 ********************************************************************/
5108 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5109 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5111 DEBUG(5, ("init_sam_user_info18\n"));
5113 usr->lm_pwd_active =
5114 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5115 usr->nt_pwd_active =
5116 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5119 /*******************************************************************
5120 reads or writes a structure.
5121 ********************************************************************/
5123 static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5124 prs_struct *ps, int depth)
5129 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5135 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5137 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5140 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5142 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5148 /*******************************************************************
5149 inits a SAM_USER_INFO_7 structure.
5150 ********************************************************************/
5152 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5154 DEBUG(5, ("init_sam_user_info7\n"));
5156 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5157 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5161 /*******************************************************************
5162 reads or writes a structure.
5163 ********************************************************************/
5165 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5166 prs_struct *ps, int depth)
5171 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5177 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5180 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5186 /*******************************************************************
5187 inits a SAM_USER_INFO_9 structure.
5188 ********************************************************************/
5190 void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
5192 DEBUG(5, ("init_sam_user_info9\n"));
5194 usr->rid_group = rid_group;
5197 /*******************************************************************
5198 reads or writes a structure.
5199 ********************************************************************/
5201 static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
5202 prs_struct *ps, int depth)
5207 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
5213 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5219 /*******************************************************************
5220 inits a SAM_USER_INFO_16 structure.
5221 ********************************************************************/
5223 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5225 DEBUG(5, ("init_sam_user_info16\n"));
5227 usr->acb_info = acb_info;
5230 /*******************************************************************
5231 reads or writes a structure.
5232 ********************************************************************/
5234 static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5235 prs_struct *ps, int depth)
5240 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5246 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5252 /*******************************************************************
5253 inits a SAM_USER_INFO_17 structure.
5254 ********************************************************************/
5256 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5259 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5261 DEBUG(5, ("init_sam_user_info17\n"));
5263 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5264 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5266 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5268 usr->ptr_1 = 1; /* pointer */
5269 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5270 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5272 usr->ptr_2 = 1; /* pointer */
5273 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5275 usr->ptr_3 = 1; /* pointer */
5276 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5278 usr->rid_user = rid_user;
5279 usr->rid_group = rid_group;
5281 usr->acct_ctrl = acct_ctrl;
5282 usr->unknown_3 = 0x0000;
5284 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5285 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5287 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5288 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5290 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5291 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5294 /*******************************************************************
5295 reads or writes a structure.
5296 ********************************************************************/
5298 static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5299 prs_struct *ps, int depth)
5304 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5310 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5313 if(!smb_io_time("time", &usr->expiry, ps, depth))
5316 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5319 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5322 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5325 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5327 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5330 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5333 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5335 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5338 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5340 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5343 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5345 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5347 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5349 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5351 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5353 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5356 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5359 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5362 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5368 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5374 /*************************************************************************
5376 *************************************************************************/
5378 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5380 DEBUG(10, ("init_sam_user_info24:\n"));
5381 memcpy(usr->pass, newpass, sizeof(usr->pass));
5382 usr->pw_len = pw_len;
5385 /*******************************************************************
5386 reads or writes a structure.
5387 ********************************************************************/
5389 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5390 prs_struct *ps, int depth)
5395 prs_debug(ps, depth, desc, "sam_io_user_info24");
5401 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5405 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5406 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5408 } else if (UNMARSHALLING(ps)) {
5409 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5416 /*******************************************************************
5417 reads or writes a structure.
5418 ********************************************************************/
5420 static BOOL sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
5421 prs_struct *ps, int depth)
5426 prs_debug(ps, depth, desc, "sam_io_user_info26");
5432 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5436 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5443 /*************************************************************************
5444 init_sam_user_info23
5446 unknown_6 = 0x0000 04ec
5448 *************************************************************************/
5450 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5451 NTTIME * logoff_time, /* all zeros */
5452 NTTIME * kickoff_time, /* all zeros */
5453 NTTIME * pass_last_set_time, /* all zeros */
5454 NTTIME * pass_can_change_time, /* all zeros */
5455 NTTIME * pass_must_change_time, /* all zeros */
5466 uint32 user_rid, /* 0x0000 0000 */
5469 uint32 fields_present,
5472 uint16 bad_password_count,
5476 usr->logon_time = *logon_time; /* all zeros */
5477 usr->logoff_time = *logoff_time; /* all zeros */
5478 usr->kickoff_time = *kickoff_time; /* all zeros */
5479 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5480 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5481 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5483 ZERO_STRUCT(usr->nt_pwd);
5484 ZERO_STRUCT(usr->lm_pwd);
5486 usr->user_rid = user_rid; /* 0x0000 0000 */
5487 usr->group_rid = group_rid;
5488 usr->acb_info = acb_info;
5489 usr->fields_present = fields_present; /* 09f8 27fa */
5491 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5492 usr->ptr_logon_hrs = hrs ? 1 : 0;
5494 if (nt_time_is_zero(pass_must_change_time)) {
5495 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5497 usr->passmustchange=0;
5500 ZERO_STRUCT(usr->padding1);
5501 ZERO_STRUCT(usr->padding2);
5503 usr->bad_password_count = bad_password_count;
5504 usr->logon_count = logon_count;
5506 memcpy(usr->pass, newpass, sizeof(usr->pass));
5508 copy_unistr2(&usr->uni_user_name, user_name);
5509 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5511 copy_unistr2(&usr->uni_full_name, full_name);
5512 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5514 copy_unistr2(&usr->uni_home_dir, home_dir);
5515 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5517 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5518 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5520 copy_unistr2(&usr->uni_logon_script, log_scr);
5521 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5523 copy_unistr2(&usr->uni_profile_path, prof_path);
5524 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5526 copy_unistr2(&usr->uni_acct_desc, desc);
5527 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5529 copy_unistr2(&usr->uni_workstations, wkstas);
5530 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5532 copy_unistr2(&usr->uni_unknown_str, unk_str);
5533 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5535 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5536 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5538 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5541 /*************************************************************************
5542 init_sam_user_info23
5544 unknown_6 = 0x0000 04ec
5546 *************************************************************************/
5548 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5549 NTTIME * logoff_time, /* all zeros */
5550 NTTIME * kickoff_time, /* all zeros */
5551 NTTIME * pass_last_set_time, /* all zeros */
5552 NTTIME * pass_can_change_time, /* all zeros */
5553 NTTIME * pass_must_change_time, /* all zeros */
5554 char *user_name, /* NULL */
5556 char *home_dir, char *dir_drive, char *log_scr,
5557 char *prof_path, const char *desc, char *wkstas,
5558 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5559 uint32 group_rid, uint32 acb_info,
5560 uint32 fields_present, uint16 logon_divs,
5561 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5564 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5566 usr->logon_time = *logon_time; /* all zeros */
5567 usr->logoff_time = *logoff_time; /* all zeros */
5568 usr->kickoff_time = *kickoff_time; /* all zeros */
5569 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5570 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5571 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5573 ZERO_STRUCT(usr->nt_pwd);
5574 ZERO_STRUCT(usr->lm_pwd);
5576 usr->user_rid = user_rid; /* 0x0000 0000 */
5577 usr->group_rid = group_rid;
5578 usr->acb_info = acb_info;
5579 usr->fields_present = fields_present; /* 09f8 27fa */
5581 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5582 usr->ptr_logon_hrs = hrs ? 1 : 0;
5584 if (nt_time_is_zero(pass_must_change_time)) {
5585 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5587 usr->passmustchange=0;
5590 ZERO_STRUCT(usr->padding1);
5591 ZERO_STRUCT(usr->padding2);
5593 usr->bad_password_count = bad_password_count;
5594 usr->logon_count = logon_count;
5596 memcpy(usr->pass, newpass, sizeof(usr->pass));
5598 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5599 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5601 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5602 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5604 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5605 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5607 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5608 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5610 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5611 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5613 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5614 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5616 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5617 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5619 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5620 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5622 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5623 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5625 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5626 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5628 data_blob_free(&blob);
5630 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5633 /*******************************************************************
5634 reads or writes a structure.
5635 ********************************************************************/
5637 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5638 prs_struct *ps, int depth)
5643 prs_debug(ps, depth, desc, "sam_io_user_info23");
5649 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5651 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5653 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5655 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5657 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5659 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5662 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5664 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5666 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5668 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5670 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5672 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5674 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5676 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5678 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5680 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5683 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5685 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5688 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5690 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5692 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5695 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5697 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5701 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5704 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5706 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5709 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5711 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5713 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5717 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5720 /* here begins pointed-to data */
5722 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5725 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5728 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5731 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5734 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5737 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5740 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5743 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5746 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5749 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5752 /* ok, this is only guess-work (as usual) */
5753 if (usr->ptr_logon_hrs) {
5754 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5761 /*******************************************************************
5762 reads or writes a structure.
5763 NB. This structure is *definately* incorrect. It's my best guess
5764 currently for W2K SP2. The password field is encrypted in a different
5765 way than normal... And there are definately other problems. JRA.
5766 ********************************************************************/
5768 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5773 prs_debug(ps, depth, desc, "sam_io_user_info25");
5779 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5781 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5783 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5785 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5787 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5789 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5792 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5794 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5796 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5798 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5800 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5802 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5804 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5806 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5808 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5810 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5813 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5815 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5818 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5820 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5822 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5825 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5828 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5831 /* here begins pointed-to data */
5833 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5836 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5839 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5842 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5845 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5848 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5851 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5854 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5857 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5860 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5863 #if 0 /* JRA - unknown... */
5864 /* ok, this is only guess-work (as usual) */
5865 if (usr->ptr_logon_hrs) {
5866 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5875 /*************************************************************************
5876 init_sam_user_info21W
5878 unknown_6 = 0x0000 04ec
5880 *************************************************************************/
5882 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5883 NTTIME * logon_time,
5884 NTTIME * logoff_time,
5885 NTTIME * kickoff_time,
5886 NTTIME * pass_last_set_time,
5887 NTTIME * pass_can_change_time,
5888 NTTIME * pass_must_change_time,
5904 uint32 fields_present,
5907 uint16 bad_password_count,
5910 usr->logon_time = *logon_time;
5911 usr->logoff_time = *logoff_time;
5912 usr->kickoff_time = *kickoff_time;
5913 usr->pass_last_set_time = *pass_last_set_time;
5914 usr->pass_can_change_time = *pass_can_change_time;
5915 usr->pass_must_change_time = *pass_must_change_time;
5917 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5918 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5920 usr->user_rid = user_rid;
5921 usr->group_rid = group_rid;
5922 usr->acb_info = acb_info;
5923 usr->fields_present = fields_present; /* 0x00ff ffff */
5925 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5926 usr->ptr_logon_hrs = hrs ? 1 : 0;
5927 usr->bad_password_count = bad_password_count;
5928 usr->logon_count = logon_count;
5930 if (nt_time_is_zero(pass_must_change_time)) {
5931 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5933 usr->passmustchange=0;
5936 ZERO_STRUCT(usr->padding1);
5937 ZERO_STRUCT(usr->padding2);
5939 copy_unistr2(&usr->uni_user_name, user_name);
5940 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5942 copy_unistr2(&usr->uni_full_name, full_name);
5943 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5945 copy_unistr2(&usr->uni_home_dir, home_dir);
5946 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5948 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5949 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5951 copy_unistr2(&usr->uni_logon_script, log_scr);
5952 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5954 copy_unistr2(&usr->uni_profile_path, prof_path);
5955 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5957 copy_unistr2(&usr->uni_acct_desc, desc);
5958 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5960 copy_unistr2(&usr->uni_workstations, wkstas);
5961 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5963 copy_unistr2(&usr->uni_unknown_str, unk_str);
5964 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5966 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5967 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5969 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5972 /*************************************************************************
5973 init_sam_user_info21
5975 unknown_6 = 0x0000 04ec
5977 *************************************************************************/
5979 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
5981 NTTIME logon_time, logoff_time, kickoff_time,
5982 pass_last_set_time, pass_can_change_time,
5983 pass_must_change_time;
5985 const char* user_name = pdb_get_username(pw);
5986 const char* full_name = pdb_get_fullname(pw);
5987 const char* home_dir = pdb_get_homedir(pw);
5988 const char* dir_drive = pdb_get_dir_drive(pw);
5989 const char* logon_script = pdb_get_logon_script(pw);
5990 const char* profile_path = pdb_get_profile_path(pw);
5991 const char* description = pdb_get_acct_desc(pw);
5992 const char* workstations = pdb_get_workstations(pw);
5993 const char* munged_dial = pdb_get_munged_dial(pw);
5994 DATA_BLOB munged_dial_blob;
5997 const DOM_SID *user_sid;
6000 const DOM_SID *group_sid;
6003 munged_dial_blob = base64_decode_data_blob(munged_dial);
6005 munged_dial_blob = data_blob(NULL, 0);
6008 /* Create NTTIME structs */
6009 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6010 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6011 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6012 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6013 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6014 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6016 /* structure assignment */
6017 usr->logon_time = logon_time;
6018 usr->logoff_time = logoff_time;
6019 usr->kickoff_time = kickoff_time;
6020 usr->pass_last_set_time = pass_last_set_time;
6021 usr->pass_can_change_time = pass_can_change_time;
6022 usr->pass_must_change_time = pass_must_change_time;
6024 ZERO_STRUCT(usr->nt_pwd);
6025 ZERO_STRUCT(usr->lm_pwd);
6027 user_sid = pdb_get_user_sid(pw);
6029 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6030 fstring user_sid_string;
6031 fstring domain_sid_string;
6032 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6033 "the domain sid %s. Failing operation.\n",
6035 sid_to_string(user_sid_string, user_sid),
6036 sid_to_string(domain_sid_string, domain_sid)));
6037 data_blob_free(&munged_dial_blob);
6038 return NT_STATUS_UNSUCCESSFUL;
6041 group_sid = pdb_get_group_sid(pw);
6043 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6044 fstring group_sid_string;
6045 fstring domain_sid_string;
6046 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6047 "which conflicts with the domain sid %s. Failing operation.\n",
6049 sid_to_string(group_sid_string, group_sid),
6050 sid_to_string(domain_sid_string, domain_sid)));
6051 data_blob_free(&munged_dial_blob);
6052 return NT_STATUS_UNSUCCESSFUL;
6055 usr->user_rid = user_rid;
6056 usr->group_rid = group_rid;
6057 usr->acb_info = pdb_get_acct_ctrl(pw);
6060 Look at a user on a real NT4 PDC with usrmgr, press
6061 'ok'. Then you will see that fields_present is set to
6062 0x08f827fa. Look at the user immediately after that again,
6063 and you will see that 0x00fffff is returned. This solves
6064 the problem that you get access denied after having looked
6068 usr->fields_present = pdb_build_fields_present(pw);
6070 usr->logon_divs = pdb_get_logon_divs(pw);
6071 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6072 usr->bad_password_count = pdb_get_bad_password_count(pw);
6073 usr->logon_count = pdb_get_logon_count(pw);
6075 if (pdb_get_pass_must_change_time(pw) == 0) {
6076 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6078 usr->passmustchange=0;
6081 ZERO_STRUCT(usr->padding1);
6082 ZERO_STRUCT(usr->padding2);
6084 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6085 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6087 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6088 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6090 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6091 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6093 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6094 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6096 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6097 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6099 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6100 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6102 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6103 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6105 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6106 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6108 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6109 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6111 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6112 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6113 data_blob_free(&munged_dial_blob);
6115 if (pdb_get_hours(pw)) {
6116 usr->logon_hrs.max_len = 1260;
6117 usr->logon_hrs.offset = 0;
6118 usr->logon_hrs.len = pdb_get_hours_len(pw);
6119 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6121 usr->logon_hrs.max_len = 1260;
6122 usr->logon_hrs.offset = 0;
6123 usr->logon_hrs.len = 0;
6124 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6127 return NT_STATUS_OK;
6130 /*******************************************************************
6131 reads or writes a structure.
6132 ********************************************************************/
6134 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6135 prs_struct *ps, int depth)
6140 prs_debug(ps, depth, desc, "sam_io_user_info21");
6146 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6148 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6150 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6152 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6154 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6156 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6159 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6161 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6163 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6165 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6167 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6169 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6171 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6173 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6175 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6177 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6180 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6182 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6185 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6187 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6189 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6192 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6194 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6198 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6201 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6203 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6206 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6208 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6210 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6213 /* here begins pointed-to data */
6215 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6217 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6219 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6221 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6223 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6225 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6227 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6229 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6231 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6233 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6236 /* ok, this is only guess-work (as usual) */
6237 if (usr->ptr_logon_hrs) {
6238 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6245 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
6247 const char *munged_dial = pdb_get_munged_dial(pw);
6248 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6250 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6251 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6252 data_blob_free(&blob);
6255 /*******************************************************************
6256 reads or writes a structure.
6257 ********************************************************************/
6259 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6260 prs_struct *ps, int depth)
6265 prs_debug(ps, depth, desc, "sam_io_user_info20");
6271 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6274 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6280 /*******************************************************************
6281 inits a SAM_USERINFO_CTR structure.
6282 ********************************************************************/
6284 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6285 uint16 switch_value,
6286 SAM_USER_INFO_21 * usr)
6288 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6290 ctr->switch_value = switch_value;
6291 ctr->info.id = NULL;
6293 switch (switch_value) {
6295 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6296 if (ctr->info.id16 == NULL)
6297 return NT_STATUS_NO_MEMORY;
6299 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6302 /* whoops - got this wrong. i think. or don't understand what's happening. */
6306 info = (void *)&id11;
6308 expire.low = 0xffffffff;
6309 expire.high = 0x7fffffff;
6311 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6312 init_sam_user_info11(ctr->info.id17, &expire,
6313 "BROOKFIELDS$", /* name */
6314 0x03ef, /* user rid */
6315 0x201, /* group rid */
6316 0x0080); /* acb info */
6322 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6323 if (ctr->info.id18 == NULL)
6324 return NT_STATUS_NO_MEMORY;
6326 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6330 SAM_USER_INFO_21 *cusr;
6331 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6332 ctr->info.id21 = cusr;
6333 if (ctr->info.id21 == NULL)
6334 return NT_STATUS_NO_MEMORY;
6335 memcpy(cusr, usr, sizeof(*usr));
6336 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6337 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6341 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6342 return NT_STATUS_INVALID_INFO_CLASS;
6345 return NT_STATUS_OK;
6348 /*******************************************************************
6349 inits a SAM_USERINFO_CTR structure.
6350 ********************************************************************/
6352 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6353 uint16 switch_value, void *info)
6355 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6357 ctr->switch_value = switch_value;
6358 ctr->info.id = info;
6360 switch (switch_value) {
6362 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6363 dump_data(100, (char *)sess_key->data, sess_key->length);
6364 dump_data(100, (char *)ctr->info.id24->pass, 516);
6367 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6368 dump_data(100, (char *)sess_key->data, sess_key->length);
6369 dump_data(100, (char *)ctr->info.id23->pass, 516);
6374 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6378 /*******************************************************************
6379 reads or writes a structure.
6380 ********************************************************************/
6382 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6383 prs_struct *ps, int depth)
6386 SAM_USERINFO_CTR *ctr;
6388 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6391 if (UNMARSHALLING(ps)) {
6392 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6400 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6402 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6409 switch (ctr->switch_value) {
6411 if (UNMARSHALLING(ps))
6412 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6413 if (ctr->info.id7 == NULL) {
6414 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6417 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6420 if (UNMARSHALLING(ps))
6421 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
6422 if (ctr->info.id9 == NULL) {
6423 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6426 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
6429 if (UNMARSHALLING(ps))
6430 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6431 if (ctr->info.id16 == NULL) {
6432 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6435 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6438 if (UNMARSHALLING(ps))
6439 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6441 if (ctr->info.id17 == NULL) {
6442 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6445 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6448 if (UNMARSHALLING(ps))
6449 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6451 if (ctr->info.id18 == NULL) {
6452 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6455 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6458 if (UNMARSHALLING(ps))
6459 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6461 if (ctr->info.id20 == NULL) {
6462 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6465 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6468 if (UNMARSHALLING(ps))
6469 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6471 if (ctr->info.id21 == NULL) {
6472 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6475 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6478 if (UNMARSHALLING(ps))
6479 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6481 if (ctr->info.id23 == NULL) {
6482 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6485 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6488 if (UNMARSHALLING(ps))
6489 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6491 if (ctr->info.id24 == NULL) {
6492 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6495 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6498 if (UNMARSHALLING(ps))
6499 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6501 if (ctr->info.id25 == NULL) {
6502 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6505 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6508 if (UNMARSHALLING(ps))
6509 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6511 if (ctr->info.id26 == NULL) {
6512 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6515 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6518 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6526 /*******************************************************************
6527 inits a SAMR_R_QUERY_USERINFO structure.
6528 ********************************************************************/
6530 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6531 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6533 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6538 if (NT_STATUS_IS_OK(status)) {
6543 r_u->status = status; /* return status */
6546 /*******************************************************************
6547 reads or writes a structure.
6548 ********************************************************************/
6550 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6551 prs_struct *ps, int depth)
6556 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6562 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6565 if (r_u->ptr != 0) {
6566 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6572 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6578 /*******************************************************************
6579 inits a SAMR_Q_SET_USERINFO structure.
6580 ********************************************************************/
6582 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6583 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6584 uint16 switch_value, void *info)
6586 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6589 q_u->switch_value = switch_value;
6590 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6593 /*******************************************************************
6594 reads or writes a structure.
6595 ********************************************************************/
6597 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6598 prs_struct *ps, int depth)
6603 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6609 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6611 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6613 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6619 /*******************************************************************
6620 inits a SAMR_R_SET_USERINFO structure.
6621 ********************************************************************/
6623 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6625 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6627 r_u->status = status; /* return status */
6630 /*******************************************************************
6631 reads or writes a structure.
6632 ********************************************************************/
6634 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6635 prs_struct *ps, int depth)
6640 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6646 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6652 /*******************************************************************
6653 inits a SAMR_Q_SET_USERINFO2 structure.
6654 ********************************************************************/
6656 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6657 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6658 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6660 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6663 q_u->switch_value = switch_value;
6666 if (q_u->ctr != NULL)
6667 q_u->ctr->switch_value = switch_value;
6669 switch (switch_value) {
6671 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
6672 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
6673 dump_data(100, (char *)sess_key->data, sess_key->length);
6674 dump_data(100, (char *)ctr->info.id18->lm_pwd, 16);
6675 dump_data(100, (char *)ctr->info.id18->nt_pwd, 16);
6680 /*******************************************************************
6681 reads or writes a structure.
6682 ********************************************************************/
6684 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6685 prs_struct *ps, int depth)
6690 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6696 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6699 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6701 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6707 /*******************************************************************
6708 inits a SAMR_R_SET_USERINFO2 structure.
6709 ********************************************************************/
6711 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6713 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6715 r_u->status = status; /* return status */
6718 /*******************************************************************
6719 reads or writes a structure.
6720 ********************************************************************/
6722 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6723 prs_struct *ps, int depth)
6728 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6734 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6740 /*******************************************************************
6741 inits a SAMR_Q_CONNECT structure.
6742 ********************************************************************/
6744 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6745 char *srv_name, uint32 access_mask)
6747 DEBUG(5, ("init_samr_q_connect\n"));
6749 /* make PDC server name \\server */
6750 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6751 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6753 /* example values: 0x0000 0002 */
6754 q_u->access_mask = access_mask;
6757 /*******************************************************************
6758 reads or writes a structure.
6759 ********************************************************************/
6761 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6762 prs_struct *ps, int depth)
6767 prs_debug(ps, depth, desc, "samr_io_q_connect");
6773 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6775 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6780 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6786 /*******************************************************************
6787 reads or writes a structure.
6788 ********************************************************************/
6790 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6791 prs_struct *ps, int depth)
6796 prs_debug(ps, depth, desc, "samr_io_r_connect");
6802 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6805 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6811 /*******************************************************************
6812 inits a SAMR_Q_CONNECT4 structure.
6813 ********************************************************************/
6815 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6816 char *srv_name, uint32 access_mask)
6818 DEBUG(5, ("init_samr_q_connect4\n"));
6820 /* make PDC server name \\server */
6821 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6822 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6824 /* Only value we've seen, possibly an address type ? */
6827 /* example values: 0x0000 0002 */
6828 q_u->access_mask = access_mask;
6831 /*******************************************************************
6832 reads or writes a structure.
6833 ********************************************************************/
6835 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6836 prs_struct *ps, int depth)
6841 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6847 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6849 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6854 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6856 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6862 /*******************************************************************
6863 reads or writes a structure.
6864 ********************************************************************/
6866 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6867 prs_struct *ps, int depth)
6872 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6878 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6881 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6887 /*******************************************************************
6888 inits a SAMR_Q_CONNECT5 structure.
6889 ********************************************************************/
6891 void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
6892 char *srv_name, uint32 access_mask)
6894 DEBUG(5, ("init_samr_q_connect5\n"));
6896 /* make PDC server name \\server */
6897 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6898 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6900 /* example values: 0x0000 0002 */
6901 q_u->access_mask = access_mask;
6904 q_u->info1_unk1 = 3;
6905 q_u->info1_unk2 = 0;
6908 /*******************************************************************
6909 inits a SAMR_R_CONNECT5 structure.
6910 ********************************************************************/
6912 void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
6914 DEBUG(5, ("init_samr_q_connect5\n"));
6917 r_u->info1_unk1 = 3;
6918 r_u->info1_unk2 = 0;
6920 r_u->connect_pol = *pol;
6921 r_u->status = status;
6924 /*******************************************************************
6925 reads or writes a structure.
6926 ********************************************************************/
6928 BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
6929 prs_struct *ps, int depth)
6934 prs_debug(ps, depth, desc, "samr_io_q_connect5");
6940 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6942 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6947 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6950 if(!prs_uint32("level", ps, depth, &q_u->level))
6952 if(!prs_uint32("level", ps, depth, &q_u->level))
6955 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
6957 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
6963 /*******************************************************************
6964 reads or writes a structure.
6965 ********************************************************************/
6967 BOOL samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
6968 prs_struct *ps, int depth)
6973 prs_debug(ps, depth, desc, "samr_io_r_connect5");
6979 if(!prs_uint32("level", ps, depth, &r_u->level))
6981 if(!prs_uint32("level", ps, depth, &r_u->level))
6983 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
6985 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
6988 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6991 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6997 /*******************************************************************
6998 inits a SAMR_Q_CONNECT_ANON structure.
6999 ********************************************************************/
7001 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
7003 DEBUG(5, ("init_samr_q_connect_anon\n"));
7006 q_u->unknown_0 = 0x5c; /* server name (?!!) */
7007 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
7010 /*******************************************************************
7011 reads or writes a structure.
7012 ********************************************************************/
7014 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
7015 prs_struct *ps, int depth)
7020 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
7026 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
7029 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
7034 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7040 /*******************************************************************
7041 reads or writes a structure.
7042 ********************************************************************/
7044 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
7045 prs_struct *ps, int depth)
7050 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
7056 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7059 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7065 /*******************************************************************
7066 inits a SAMR_Q_GET_DOM_PWINFO structure.
7067 ********************************************************************/
7069 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
7072 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7075 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
7076 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
7079 /*******************************************************************
7080 reads or writes a structure.
7081 ********************************************************************/
7083 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
7084 prs_struct *ps, int depth)
7089 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
7095 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
7097 if (q_u->ptr != 0) {
7098 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7100 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7107 /*******************************************************************
7108 reads or writes a structure.
7109 ********************************************************************/
7111 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7112 prs_struct *ps, int depth)
7117 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7123 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
7127 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
7130 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7136 /*******************************************************************
7137 make a SAMR_ENC_PASSWD structure.
7138 ********************************************************************/
7140 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7148 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7152 /*******************************************************************
7153 reads or writes a SAMR_ENC_PASSWD structure.
7154 ********************************************************************/
7156 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7157 prs_struct *ps, int depth)
7162 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7168 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7171 if (pwd->ptr != 0) {
7172 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7179 /*******************************************************************
7180 inits a SAMR_ENC_HASH structure.
7181 ********************************************************************/
7183 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7191 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7195 /*******************************************************************
7196 reads or writes a SAMR_ENC_HASH structure.
7197 ********************************************************************/
7199 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7200 prs_struct *ps, int depth)
7205 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7211 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7213 if (hsh->ptr != 0) {
7214 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7221 /*******************************************************************
7222 inits a SAMR_Q_CHGPASSWD_USER structure.
7223 ********************************************************************/
7225 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7226 const char *dest_host, const char *user_name,
7227 const uchar nt_newpass[516],
7228 const uchar nt_oldhash[16],
7229 const uchar lm_newpass[516],
7230 const uchar lm_oldhash[16])
7232 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7235 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7236 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7238 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7239 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7241 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7242 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7244 q_u->unknown = 0x01;
7246 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7247 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7250 /*******************************************************************
7251 reads or writes a structure.
7252 ********************************************************************/
7254 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7255 prs_struct *ps, int depth)
7260 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7266 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7269 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7271 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7276 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7278 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7281 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7283 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7286 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7289 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7291 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7297 /*******************************************************************
7298 inits a SAMR_R_CHGPASSWD_USER structure.
7299 ********************************************************************/
7301 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7303 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7305 r_u->status = status;
7308 /*******************************************************************
7309 reads or writes a structure.
7310 ********************************************************************/
7312 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7313 prs_struct *ps, int depth)
7318 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7324 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7330 /*******************************************************************
7331 inits a SAMR_Q_CHGPASSWD3 structure.
7332 ********************************************************************/
7334 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
7335 const char *dest_host, const char *user_name,
7336 const uchar nt_newpass[516],
7337 const uchar nt_oldhash[16],
7338 const uchar lm_newpass[516],
7339 const uchar lm_oldhash[16])
7341 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7344 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7345 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7347 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7348 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7350 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7351 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7353 q_u->lm_change = 0x01;
7355 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7356 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7358 init_enc_passwd(&q_u->password3, NULL);
7361 /*******************************************************************
7362 reads or writes a structure.
7363 ********************************************************************/
7365 BOOL samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
7366 prs_struct *ps, int depth)
7371 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
7377 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7380 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7382 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7387 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7389 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7392 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7394 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7397 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
7400 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7402 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7405 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
7411 /*******************************************************************
7412 inits a SAMR_R_CHGPASSWD_USER3 structure.
7413 ********************************************************************/
7415 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
7416 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
7418 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7420 r_u->status = status;
7424 r_u->ptr_reject = 0;
7430 if (reject && (reject->reject_reason != Undefined)) {
7431 r_u->reject = reject;
7432 r_u->ptr_reject = 1;
7436 /*******************************************************************
7437 Reads or writes an SAMR_CHANGE_REJECT structure.
7438 ********************************************************************/
7440 BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
7445 prs_debug(ps, depth, desc, "samr_io_change_reject");
7451 if(UNMARSHALLING(ps))
7452 ZERO_STRUCTP(reject);
7454 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
7457 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
7460 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
7466 /*******************************************************************
7467 reads or writes a structure.
7468 ********************************************************************/
7470 BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
7471 prs_struct *ps, int depth)
7476 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
7482 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
7485 if (r_u->ptr_info && r_u->info != NULL) {
7486 /* SAM_UNK_INFO_1 */
7487 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
7491 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
7494 if (r_u->ptr_reject && r_u->reject != NULL) {
7495 /* SAMR_CHANGE_REJECT */
7496 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
7500 if (!prs_ntstatus("status", ps, depth, &r_u->status))
7506 /*******************************************************************
7507 reads or writes a structure.
7508 ********************************************************************/
7510 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7511 POLICY_HND *domain_pol, uint16 switch_value)
7513 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7515 q_u->domain_pol = *domain_pol;
7516 q_u->switch_value = switch_value;
7519 /*******************************************************************
7520 reads or writes a structure.
7521 ********************************************************************/
7523 BOOL samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7524 prs_struct *ps, int depth)
7529 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7535 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7538 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7544 /*******************************************************************
7545 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7546 ********************************************************************/
7548 void init_samr_r_samr_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7549 uint16 switch_value, SAM_UNK_CTR * ctr,
7552 DEBUG(5, ("init_samr_r_samr_query_domain_info2\n"));
7555 r_u->switch_value = 0;
7556 r_u->status = status; /* return status */
7558 if (NT_STATUS_IS_OK(status)) {
7559 r_u->switch_value = switch_value;
7565 /*******************************************************************
7566 reads or writes a structure.
7567 ********************************************************************/
7569 BOOL samr_io_r_samr_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7570 prs_struct *ps, int depth)
7575 prs_debug(ps, depth, desc, "samr_io_r_samr_query_domain_info2");
7581 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7584 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7585 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7590 switch (r_u->switch_value) {
7592 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7596 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7600 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7604 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7608 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7612 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7616 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7620 DEBUG(0, ("samr_io_r_samr_query_domain_info2: unknown switch level 0x%x\n",
7621 r_u->switch_value));
7622 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7630 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7637 /*******************************************************************
7638 reads or writes a structure.
7639 ********************************************************************/
7641 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7642 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7644 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7646 q_u->domain_pol = *domain_pol;
7647 q_u->switch_value0 = switch_value;
7649 q_u->switch_value = switch_value;
7654 /*******************************************************************
7655 reads or writes a structure.
7656 ********************************************************************/
7658 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7659 prs_struct *ps, int depth)
7664 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7670 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7673 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7676 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7682 if (UNMARSHALLING(ps)) {
7683 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7687 switch (q_u->switch_value) {
7690 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7694 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7698 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7702 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7706 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7710 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7714 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7718 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7719 q_u->switch_value));
7726 /*******************************************************************
7727 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7728 ********************************************************************/
7730 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7732 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7734 r_u->status = status; /* return status */
7737 /*******************************************************************
7738 reads or writes a structure.
7739 ********************************************************************/
7741 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7742 prs_struct *ps, int depth)
7747 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7753 if(!prs_ntstatus("status", ps, depth, &r_u->status))