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.
28 #include "rpc_parse.h"
32 #define DBGC_CLASS DBGC_RPC_PARSE
34 /*******************************************************************
35 inits a SAMR_Q_CLOSE_HND structure.
36 ********************************************************************/
38 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
40 DEBUG(5, ("init_samr_q_close_hnd\n"));
45 /*******************************************************************
46 reads or writes a structure.
47 ********************************************************************/
49 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
50 prs_struct *ps, int depth)
55 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
61 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
64 /*******************************************************************
65 reads or writes a structure.
66 ********************************************************************/
68 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
69 prs_struct *ps, int depth)
74 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
80 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
83 if(!prs_ntstatus("status", ps, depth, &r_u->status))
89 /*******************************************************************
90 inits a SAMR_Q_LOOKUP_DOMAIN structure.
91 ********************************************************************/
93 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
94 POLICY_HND *pol, char *dom_name)
96 DEBUG(5, ("init_samr_q_lookup_domain\n"));
98 q_u->connect_pol = *pol;
100 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
101 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
104 /*******************************************************************
105 reads or writes a structure.
106 ********************************************************************/
107 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
108 prs_struct *ps, int depth)
113 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
119 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
122 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
125 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
131 /*******************************************************************
132 inits a SAMR_R_LOOKUP_DOMAIN structure.
133 ********************************************************************/
135 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
136 DOM_SID *dom_sid, NTSTATUS status)
138 DEBUG(5, ("init_samr_r_lookup_domain\n"));
140 r_u->status = status;
142 if (NT_STATUS_IS_OK(status)) {
144 init_dom_sid2(&r_u->dom_sid, dom_sid);
148 /*******************************************************************
149 reads or writes a structure.
150 ********************************************************************/
152 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
153 prs_struct *ps, int depth)
158 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
164 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
167 if (r_u->ptr_sid != 0) {
168 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
174 if(!prs_ntstatus("status", ps, depth, &r_u->status))
180 /*******************************************************************
181 reads or writes a structure.
182 ********************************************************************/
184 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
186 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
188 q_u->dom_pol = *dom_pol;
189 init_dom_sid2(&q_u->sid, sid);
192 /*******************************************************************
193 reads or writes a structure.
194 ********************************************************************/
196 BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
197 prs_struct *ps, int depth)
202 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
208 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
211 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
220 /*******************************************************************
221 reads or writes a structure.
222 ********************************************************************/
224 BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
225 prs_struct *ps, int depth)
230 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
236 if(!prs_ntstatus("status", ps, depth, &r_u->status))
242 /*******************************************************************
243 reads or writes a structure.
244 ********************************************************************/
246 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
247 POLICY_HND *pol, uint32 flags,
250 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
254 init_dom_sid2(&q_u->dom_sid, sid);
257 /*******************************************************************
258 reads or writes a structure.
259 ********************************************************************/
261 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
262 prs_struct *ps, int depth)
267 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
273 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
276 if(!prs_uint32("flags", ps, depth, &q_u->flags))
279 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
285 /*******************************************************************
286 reads or writes a structure.
287 ********************************************************************/
289 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
290 prs_struct *ps, int depth)
295 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
301 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
304 if(!prs_ntstatus("status", ps, depth, &r_u->status))
310 /*******************************************************************
311 reads or writes a structure.
312 ********************************************************************/
314 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
315 POLICY_HND *user_pol)
317 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
319 q_u->user_pol = *user_pol;
322 /*******************************************************************
323 reads or writes a structure.
324 ********************************************************************/
326 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
327 prs_struct *ps, int depth)
332 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
338 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
341 /*******************************************************************
343 ********************************************************************/
345 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
347 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
349 r_u->unknown_0 = 0x0000;
353 * r_u->unknown_1 = 0x0015;
356 r_u->unknown_1 = 0x01D1;
357 r_u->unknown_1 = 0x0015;
359 r_u->unknown_2 = 0x00000000;
361 r_u->status = status;
364 /*******************************************************************
365 reads or writes a structure.
366 ********************************************************************/
368 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
369 prs_struct *ps, int depth)
374 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
380 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
382 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
384 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
386 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
393 /*******************************************************************
394 reads or writes a structure.
395 ********************************************************************/
397 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
398 prs_struct *ps, int depth)
403 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
409 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
412 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
415 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
422 /*******************************************************************
423 reads or writes a structure.
424 ********************************************************************/
426 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
427 POLICY_HND *user_pol, uint32 sec_info)
429 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
431 q_u->user_pol = *user_pol;
432 q_u->sec_info = sec_info;
436 /*******************************************************************
437 reads or writes a structure.
438 ********************************************************************/
440 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
441 prs_struct *ps, int depth)
446 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
452 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
455 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
461 /*******************************************************************
462 reads or writes a structure.
463 ********************************************************************/
465 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
466 POLICY_HND *domain_pol, uint16 switch_value)
468 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
470 q_u->domain_pol = *domain_pol;
471 q_u->switch_value = switch_value;
474 /*******************************************************************
475 reads or writes a structure.
476 ********************************************************************/
478 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
479 prs_struct *ps, int depth)
484 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
490 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
493 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
500 /*******************************************************************
502 ********************************************************************/
504 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
506 u_3->logout.low = nt_logout.low;
507 u_3->logout.high = nt_logout.high;
510 /*******************************************************************
511 reads or writes a structure.
512 ********************************************************************/
514 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
515 prs_struct *ps, int depth)
520 prs_debug(ps, depth, desc, "sam_io_unk_info3");
523 if(!smb_io_time("logout", &u_3->logout, ps, depth))
529 /*******************************************************************
531 ********************************************************************/
533 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
535 u_6->unknown_0 = 0x00000000;
537 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
540 /*******************************************************************
541 reads or writes a structure.
542 ********************************************************************/
544 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
545 prs_struct *ps, int depth)
550 prs_debug(ps, depth, desc, "sam_io_unk_info6");
553 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
555 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
557 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
563 /*******************************************************************
565 ********************************************************************/
567 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
569 u_7->unknown_0 = 0x0003;
572 /*******************************************************************
573 reads or writes a structure.
574 ********************************************************************/
576 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
577 prs_struct *ps, int depth)
582 prs_debug(ps, depth, desc, "sam_io_unk_info7");
585 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
591 /*******************************************************************
593 ********************************************************************/
595 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
597 u_12->duration.low = nt_lock_duration.low;
598 u_12->duration.high = nt_lock_duration.high;
599 u_12->reset_count.low = nt_reset_time.low;
600 u_12->reset_count.high = nt_reset_time.high;
602 u_12->bad_attempt_lockout = lockout;
605 /*******************************************************************
606 reads or writes a structure.
607 ********************************************************************/
609 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
610 prs_struct *ps, int depth)
615 prs_debug(ps, depth, desc, "sam_io_unk_info12");
618 if(!smb_io_time("duration", &u_12->duration, ps, depth))
620 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
622 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
628 /*******************************************************************
630 ********************************************************************/
632 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
634 init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE);
635 init_uni_hdr(&u_5->hdr_server, &u_5->uni_server);
638 /*******************************************************************
639 reads or writes a structure.
640 ********************************************************************/
642 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
643 prs_struct *ps, int depth)
648 prs_debug(ps, depth, desc, "sam_io_unk_info5");
651 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
654 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
660 /*******************************************************************
662 ********************************************************************/
664 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
665 const char *domain, const char *server,
666 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
668 u_2->unknown_0 = 0x00000000;
669 u_2->unknown_1 = 0x80000000;
670 u_2->unknown_2 = 0x00000000;
674 u_2->seq_num = seq_num;
675 u_2->unknown_3 = 0x00000000;
677 u_2->unknown_4 = 0x00000001;
678 u_2->unknown_5 = 0x00000003;
679 u_2->unknown_6 = 0x00000001;
680 u_2->num_domain_usrs = num_users;
681 u_2->num_domain_grps = num_groups;
682 u_2->num_local_grps = num_alias;
684 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
686 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
687 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
688 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
689 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
692 /*******************************************************************
693 reads or writes a structure.
694 ********************************************************************/
696 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
697 prs_struct *ps, int depth)
702 prs_debug(ps, depth, desc, "sam_io_unk_info2");
705 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
707 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
709 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
712 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
714 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
716 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
719 /* put all the data in here, at the moment, including what the above
720 pointer is referring to
723 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
725 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
728 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
730 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
732 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
734 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
736 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
738 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
742 /* this was originally marked as 'padding'. It isn't
743 padding, it is some sort of optional 12 byte
744 structure. When it is present it contains zeros
746 if(!prs_uint8s(False, "unknown", ps, depth, u_2->padding,sizeof(u_2->padding)))
750 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
752 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
758 /*******************************************************************
760 ********************************************************************/
762 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
763 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
765 u_1->min_length_password = min_pass_len;
766 u_1->password_history = pass_hist;
769 /* password never expire */
770 u_1->expire.high = nt_expire.high;
771 u_1->expire.low = nt_expire.low;
773 /* can change the password now */
774 u_1->min_passwordage.high = nt_min_age.high;
775 u_1->min_passwordage.low = nt_min_age.low;
779 /*******************************************************************
780 reads or writes a structure.
781 ********************************************************************/
783 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
784 prs_struct *ps, int depth)
789 prs_debug(ps, depth, desc, "sam_io_unk_info1");
792 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
794 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
796 if(!prs_uint32("flag", ps, depth, &u_1->flag))
798 if(!smb_io_time("expire", &u_1->expire, ps, depth))
800 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
806 /*******************************************************************
807 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
808 ********************************************************************/
810 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
811 uint16 switch_value, SAM_UNK_CTR * ctr,
814 DEBUG(5, ("init_samr_r_query_dom_info\n"));
817 r_u->switch_value = 0;
818 r_u->status = status; /* return status */
820 if (NT_STATUS_IS_OK(status)) {
821 r_u->switch_value = switch_value;
827 /*******************************************************************
828 reads or writes a structure.
829 ********************************************************************/
831 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
832 prs_struct *ps, int depth)
837 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
843 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
846 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
847 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
852 switch (r_u->switch_value) {
854 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
858 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
862 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
866 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
870 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
874 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
878 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
882 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
884 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
892 if(!prs_ntstatus("status", ps, depth, &r_u->status))
898 /*******************************************************************
899 reads or writes a SAMR_R_SET_SEC_OBJ structure.
900 ********************************************************************/
902 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
903 prs_struct *ps, int depth)
908 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
914 if(!prs_ntstatus("status", ps, depth, &r_u->status))
920 /*******************************************************************
921 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
922 ********************************************************************/
924 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
925 prs_struct *ps, int depth)
930 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
936 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
939 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
943 if(!prs_ntstatus("status", ps, depth, &r_u->status))
949 /*******************************************************************
950 reads or writes a SAM_STR1 structure.
951 ********************************************************************/
953 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
954 uint32 name_buf, uint32 desc_buf,
955 prs_struct *ps, int depth)
960 prs_debug(ps, depth, desc, "sam_io_sam_str1");
965 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
968 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
971 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
977 /*******************************************************************
978 inits a SAM_ENTRY1 structure.
979 ********************************************************************/
981 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
982 UNISTR2 *sam_name, UNISTR2 *sam_full,
983 UNISTR2 *sam_desc, uint32 rid_user,
986 DEBUG(5, ("init_sam_entry1\n"));
990 sam->user_idx = user_idx;
991 sam->rid_user = rid_user;
992 sam->acb_info = acb_info;
994 init_uni_hdr(&sam->hdr_acct_name, sam_name);
995 init_uni_hdr(&sam->hdr_user_name, sam_full);
996 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
999 /*******************************************************************
1000 reads or writes a SAM_ENTRY1 structure.
1001 ********************************************************************/
1003 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1004 prs_struct *ps, int depth)
1009 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1015 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1018 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1020 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1026 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1028 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1030 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1036 /*******************************************************************
1037 reads or writes a SAM_STR2 structure.
1038 ********************************************************************/
1040 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1041 uint32 desc_buf, prs_struct *ps, int depth)
1046 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1052 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1054 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1060 /*******************************************************************
1061 inits a SAM_ENTRY2 structure.
1062 ********************************************************************/
1063 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1064 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1065 uint32 rid_user, uint16 acb_info)
1067 DEBUG(5, ("init_sam_entry2\n"));
1069 sam->user_idx = user_idx;
1070 sam->rid_user = rid_user;
1071 sam->acb_info = acb_info;
1073 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1074 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1077 /*******************************************************************
1078 reads or writes a SAM_ENTRY2 structure.
1079 ********************************************************************/
1081 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1082 prs_struct *ps, int depth)
1087 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1093 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1096 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1098 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1104 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1106 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1112 /*******************************************************************
1113 reads or writes a SAM_STR3 structure.
1114 ********************************************************************/
1116 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1117 uint32 desc_buf, prs_struct *ps, int depth)
1122 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1128 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1130 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1136 /*******************************************************************
1137 inits a SAM_ENTRY3 structure.
1138 ********************************************************************/
1140 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1141 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1144 DEBUG(5, ("init_sam_entry3\n"));
1146 sam->grp_idx = grp_idx;
1147 sam->rid_grp = rid_grp;
1148 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1150 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1151 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1154 /*******************************************************************
1155 reads or writes a SAM_ENTRY3 structure.
1156 ********************************************************************/
1158 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1159 prs_struct *ps, int depth)
1164 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1170 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1173 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1175 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1178 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1180 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1186 /*******************************************************************
1187 inits a SAM_ENTRY4 structure.
1188 ********************************************************************/
1190 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1191 uint32 len_acct_name)
1193 DEBUG(5, ("init_sam_entry4\n"));
1195 sam->user_idx = user_idx;
1196 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1199 /*******************************************************************
1200 reads or writes a SAM_ENTRY4 structure.
1201 ********************************************************************/
1203 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1204 prs_struct *ps, int depth)
1209 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1215 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1217 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1223 /*******************************************************************
1224 inits a SAM_ENTRY5 structure.
1225 ********************************************************************/
1227 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1228 uint32 len_grp_name)
1230 DEBUG(5, ("init_sam_entry5\n"));
1232 sam->grp_idx = grp_idx;
1233 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1237 /*******************************************************************
1238 reads or writes a SAM_ENTRY5 structure.
1239 ********************************************************************/
1241 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1242 prs_struct *ps, int depth)
1247 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1253 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1255 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1261 /*******************************************************************
1262 inits a SAM_ENTRY structure.
1263 ********************************************************************/
1265 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1267 DEBUG(10, ("init_sam_entry: %d\n", rid));
1270 init_uni_hdr(&sam->hdr_name, uni2);
1273 /*******************************************************************
1274 reads or writes a SAM_ENTRY structure.
1275 ********************************************************************/
1277 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1278 prs_struct *ps, int depth)
1283 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1288 if(!prs_uint32("rid", ps, depth, &sam->rid))
1290 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1296 /*******************************************************************
1297 inits a SAMR_Q_ENUM_DOM_USERS structure.
1298 ********************************************************************/
1300 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1302 uint16 acb_mask, uint16 unk_1, uint32 size)
1304 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1308 q_e->start_idx = start_idx; /* zero indicates lots */
1309 q_e->acb_mask = acb_mask;
1310 q_e->unknown_1 = unk_1;
1311 q_e->max_size = size;
1314 /*******************************************************************
1315 reads or writes a structure.
1316 ********************************************************************/
1318 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1319 prs_struct *ps, int depth)
1324 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1330 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1333 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1335 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1337 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1340 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1347 /*******************************************************************
1348 inits a SAMR_R_ENUM_DOM_USERS structure.
1349 ********************************************************************/
1351 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1352 uint32 next_idx, uint32 num_sam_entries)
1354 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1356 r_u->next_idx = next_idx;
1358 if (num_sam_entries != 0) {
1359 r_u->ptr_entries1 = 1;
1360 r_u->ptr_entries2 = 1;
1361 r_u->num_entries2 = num_sam_entries;
1362 r_u->num_entries3 = num_sam_entries;
1364 r_u->num_entries4 = num_sam_entries;
1366 r_u->ptr_entries1 = 0;
1367 r_u->num_entries2 = num_sam_entries;
1368 r_u->ptr_entries2 = 1;
1372 /*******************************************************************
1373 reads or writes a structure.
1374 ********************************************************************/
1376 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1377 prs_struct *ps, int depth)
1384 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1390 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1392 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1395 if (r_u->ptr_entries1 != 0) {
1396 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1398 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1400 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1403 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1404 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1405 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1408 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1409 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1410 r_u->num_entries4 = 0;
1411 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1415 for (i = 0; i < r_u->num_entries2; i++) {
1416 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1420 for (i = 0; i < r_u->num_entries2; i++) {
1421 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1430 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1432 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1438 /*******************************************************************
1439 inits a SAMR_Q_QUERY_DISPINFO structure.
1440 ********************************************************************/
1442 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1443 uint16 switch_level, uint32 start_idx,
1444 uint32 max_entries, uint32 max_size)
1446 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1448 q_e->domain_pol = *pol;
1450 q_e->switch_level = switch_level;
1452 q_e->start_idx = start_idx;
1453 q_e->max_entries = max_entries;
1454 q_e->max_size = max_size;
1457 /*******************************************************************
1458 reads or writes a structure.
1459 ********************************************************************/
1461 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1462 prs_struct *ps, int depth)
1467 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1473 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1476 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1481 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1483 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1485 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1491 /*******************************************************************
1492 inits a SAM_DISPINFO_1 structure.
1493 ********************************************************************/
1495 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1496 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1497 DOM_SID *domain_sid)
1501 SAM_ACCOUNT *pwd = NULL;
1504 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1507 return NT_STATUS_OK;
1509 sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1511 return NT_STATUS_NO_MEMORY;
1513 sam->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1515 return NT_STATUS_NO_MEMORY;
1517 ZERO_STRUCTP(sam->sam);
1518 ZERO_STRUCTP(sam->str);
1520 for (i = 0; i < num_entries ; i++) {
1521 const char *username;
1522 const char *fullname;
1523 const char *acct_desc;
1525 const DOM_SID *user_sid;
1526 fstring user_sid_string, domain_sid_string;
1528 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1530 pwd=&disp_user_info[i+start_idx];
1532 username = pdb_get_username(pwd);
1533 fullname = pdb_get_fullname(pwd);
1534 acct_desc = pdb_get_acct_desc(pwd);
1545 user_sid = pdb_get_user_sid(pwd);
1547 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1548 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1549 "the domain sid %s. Failing operation.\n",
1551 sid_to_string(user_sid_string, user_sid),
1552 sid_to_string(domain_sid_string, domain_sid)));
1553 return NT_STATUS_UNSUCCESSFUL;
1556 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), UNI_FLAGS_NONE);
1557 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), UNI_FLAGS_NONE);
1558 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), UNI_FLAGS_NONE);
1560 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1561 &sam->str[i].uni_acct_name, &sam->str[i].uni_full_name, &sam->str[i].uni_acct_desc,
1562 user_rid, pdb_get_acct_ctrl(pwd));
1566 return NT_STATUS_OK;
1569 /*******************************************************************
1570 reads or writes a structure.
1571 ********************************************************************/
1573 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1575 prs_struct *ps, int depth)
1579 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1585 if (UNMARSHALLING(ps) && num_entries > 0) {
1587 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1588 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1592 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1593 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1598 for (i = 0; i < num_entries; i++) {
1599 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1603 for (i = 0; i < num_entries; i++) {
1604 if(!sam_io_sam_str1("", &sam->str[i],
1605 sam->sam[i].hdr_acct_name.buffer,
1606 sam->sam[i].hdr_user_name.buffer,
1607 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1614 /*******************************************************************
1615 inits a SAM_DISPINFO_2 structure.
1616 ********************************************************************/
1618 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1619 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1620 DOM_SID *domain_sid )
1624 SAM_ACCOUNT *pwd = NULL;
1627 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1630 return NT_STATUS_OK;
1632 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries)))
1633 return NT_STATUS_NO_MEMORY;
1635 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries)))
1636 return NT_STATUS_NO_MEMORY;
1638 ZERO_STRUCTP(sam->sam);
1639 ZERO_STRUCTP(sam->str);
1641 for (i = 0; i < num_entries; i++) {
1643 const DOM_SID *user_sid;
1644 const char *username;
1645 const char *acct_desc;
1646 fstring user_sid_string, domain_sid_string;
1648 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1649 pwd=&disp_user_info[i+start_idx];
1651 username = pdb_get_username(pwd);
1652 acct_desc = pdb_get_acct_desc(pwd);
1653 user_sid = pdb_get_user_sid(pwd);
1655 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1656 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1657 "the domain sid %s. Failing operation.\n",
1659 sid_to_string(user_sid_string, user_sid),
1660 sid_to_string(domain_sid_string, domain_sid)));
1661 return NT_STATUS_UNSUCCESSFUL;
1664 init_unistr2(&sam->str[i].uni_srv_name, username, UNI_FLAGS_NONE);
1665 init_unistr2(&sam->str[i].uni_srv_desc, acct_desc, UNI_FLAGS_NONE);
1667 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1668 &sam->str[i].uni_srv_name, &sam->str[i].uni_srv_desc,
1669 user_rid, pdb_get_acct_ctrl(pwd));
1672 return NT_STATUS_OK;
1675 /*******************************************************************
1676 reads or writes a structure.
1677 ********************************************************************/
1679 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1681 prs_struct *ps, int depth)
1688 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1694 if (UNMARSHALLING(ps) && num_entries > 0) {
1696 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1697 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1701 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1702 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1707 for (i = 0; i < num_entries; i++) {
1708 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1712 for (i = 0; i < num_entries; i++) {
1713 if(!sam_io_sam_str2("", &sam->str[i],
1714 sam->sam[i].hdr_srv_name.buffer,
1715 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1722 /*******************************************************************
1723 inits a SAM_DISPINFO_3 structure.
1724 ********************************************************************/
1726 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1727 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1733 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1736 return NT_STATUS_OK;
1738 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1739 return NT_STATUS_NO_MEMORY;
1741 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1742 return NT_STATUS_NO_MEMORY;
1744 ZERO_STRUCTP(sam->sam);
1745 ZERO_STRUCTP(sam->str);
1747 for (i = 0; i < num_entries; i++) {
1748 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1750 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1752 init_unistr2(&sam->str[i].uni_grp_name, grp->name, UNI_FLAGS_NONE);
1753 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, UNI_FLAGS_NONE);
1755 init_sam_entry3(&sam->sam[i], start_idx + i + 1, &sam->str[i].uni_grp_name,
1756 &sam->str[i].uni_grp_desc, grp->rid);
1759 return NT_STATUS_OK;
1762 /*******************************************************************
1763 reads or writes a structure.
1764 ********************************************************************/
1766 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1768 prs_struct *ps, int depth)
1775 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1781 if (UNMARSHALLING(ps) && num_entries > 0) {
1783 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1784 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1788 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1789 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1794 for (i = 0; i < num_entries; i++) {
1795 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1799 for (i = 0; i < num_entries; i++) {
1800 if(!sam_io_sam_str3("", &sam->str[i],
1801 sam->sam[i].hdr_grp_name.buffer,
1802 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1809 /*******************************************************************
1810 inits a SAM_DISPINFO_4 structure.
1811 ********************************************************************/
1813 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1814 uint32 start_idx, SAM_ACCOUNT *disp_user_info)
1816 uint32 len_sam_name;
1819 SAM_ACCOUNT *pwd = NULL;
1822 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1825 return NT_STATUS_OK;
1827 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries)))
1828 return NT_STATUS_NO_MEMORY;
1830 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries)))
1831 return NT_STATUS_NO_MEMORY;
1833 ZERO_STRUCTP(sam->sam);
1834 ZERO_STRUCTP(sam->str);
1836 for (i = 0; i < num_entries; i++) {
1837 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1838 pwd=&disp_user_info[i+start_idx];
1840 len_sam_name = strlen(pdb_get_username(pwd));
1842 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1844 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1847 return NT_STATUS_OK;
1850 /*******************************************************************
1851 reads or writes a structure.
1852 ********************************************************************/
1854 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1856 prs_struct *ps, int depth)
1863 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1869 if (UNMARSHALLING(ps) && num_entries > 0) {
1871 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1872 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1876 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1877 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1882 for (i = 0; i < num_entries; i++) {
1883 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1887 for (i = 0; i < num_entries; i++) {
1888 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1889 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1896 /*******************************************************************
1897 inits a SAM_DISPINFO_5 structure.
1898 ********************************************************************/
1900 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1901 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1903 uint32 len_sam_name;
1908 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1911 return NT_STATUS_OK;
1913 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1914 return NT_STATUS_NO_MEMORY;
1916 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1917 return NT_STATUS_NO_MEMORY;
1919 ZERO_STRUCTP(sam->sam);
1920 ZERO_STRUCTP(sam->str);
1922 for (i = 0; i < num_entries; i++) {
1923 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1925 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1927 len_sam_name = strlen(grp->name);
1929 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1930 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1933 return NT_STATUS_OK;
1936 /*******************************************************************
1937 reads or writes a structure.
1938 ********************************************************************/
1940 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1942 prs_struct *ps, int depth)
1949 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1955 if (UNMARSHALLING(ps) && num_entries > 0) {
1957 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1958 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1962 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1963 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1968 for (i = 0; i < num_entries; i++) {
1969 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1973 for (i = 0; i < num_entries; i++) {
1974 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1975 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1982 /*******************************************************************
1983 inits a SAMR_R_QUERY_DISPINFO structure.
1984 ********************************************************************/
1986 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1987 uint32 num_entries, uint32 total_size, uint32 data_size,
1988 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1991 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1993 r_u->total_size = total_size;
1995 r_u->data_size = data_size;
1997 r_u->switch_level = switch_level;
1998 r_u->num_entries = num_entries;
2001 r_u->ptr_entries = 0;
2003 r_u->ptr_entries = 1;
2005 r_u->num_entries2 = num_entries;
2008 r_u->status = status;
2011 /*******************************************************************
2012 reads or writes a structure.
2013 ********************************************************************/
2015 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2016 prs_struct *ps, int depth)
2021 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2027 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2029 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2031 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2036 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2038 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2041 if (r_u->ptr_entries==0) {
2044 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2050 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2053 switch (r_u->switch_level) {
2055 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2056 r_u->num_entries, ps, depth))
2060 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2061 r_u->num_entries, ps, depth))
2065 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2066 r_u->num_entries, ps, depth))
2070 if(!sam_io_sam_dispinfo_4("user list",
2071 r_u->ctr->sam.info4,
2072 r_u->num_entries, ps, depth))
2076 if(!sam_io_sam_dispinfo_5("group list",
2077 r_u->ctr->sam.info5,
2078 r_u->num_entries, ps, depth))
2082 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2088 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2094 /*******************************************************************
2095 inits a SAMR_Q_OPEN_GROUP structure.
2096 ********************************************************************/
2098 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2100 uint32 access_mask, uint32 rid)
2102 DEBUG(5, ("init_samr_q_open_group\n"));
2104 q_c->domain_pol = *hnd;
2105 q_c->access_mask = access_mask;
2106 q_c->rid_group = rid;
2109 /*******************************************************************
2110 reads or writes a structure.
2111 ********************************************************************/
2113 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2114 prs_struct *ps, int depth)
2119 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2125 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2128 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2130 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2136 /*******************************************************************
2137 reads or writes a structure.
2138 ********************************************************************/
2140 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2141 prs_struct *ps, int depth)
2146 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2152 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2155 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2161 /*******************************************************************
2162 inits a GROUP_INFO1 structure.
2163 ********************************************************************/
2165 void init_samr_group_info1(GROUP_INFO1 * gr1,
2166 char *acct_name, char *acct_desc,
2169 DEBUG(5, ("init_samr_group_info1\n"));
2171 gr1->unknown_1 = 0x3;
2172 gr1->num_members = num_members;
2174 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2175 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2176 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2177 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2180 /*******************************************************************
2181 reads or writes a structure.
2182 ********************************************************************/
2184 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2185 prs_struct *ps, int depth)
2192 prs_debug(ps, depth, desc, "samr_io_group_info1");
2195 if(!prs_uint16("level", ps, depth, &dummy))
2201 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2204 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2206 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2209 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2212 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2213 gr1->hdr_acct_name.buffer, ps, depth))
2216 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2217 gr1->hdr_acct_desc.buffer, ps, depth))
2223 /*******************************************************************
2224 inits a GROUP_INFO2 structure.
2225 ********************************************************************/
2227 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2229 DEBUG(5, ("init_samr_group_info2\n"));
2232 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2233 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2236 /*******************************************************************
2237 reads or writes a structure.
2238 ********************************************************************/
2240 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2245 prs_debug(ps, depth, desc, "samr_io_group_info2");
2248 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2251 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2253 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2254 gr2->hdr_acct_name.buffer, ps, depth))
2260 /*******************************************************************
2261 inits a GROUP_INFO3 structure.
2262 ********************************************************************/
2264 void init_samr_group_info3(GROUP_INFO3 *gr3)
2266 DEBUG(5, ("init_samr_group_info3\n"));
2268 gr3->unknown_1 = 0x3;
2271 /*******************************************************************
2272 reads or writes a structure.
2273 ********************************************************************/
2275 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2280 prs_debug(ps, depth, desc, "samr_io_group_info3");
2286 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2292 /*******************************************************************
2293 inits a GROUP_INFO4 structure.
2294 ********************************************************************/
2296 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2298 DEBUG(5, ("init_samr_group_info4\n"));
2301 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2302 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2305 /*******************************************************************
2306 reads or writes a structure.
2307 ********************************************************************/
2309 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2310 prs_struct *ps, int depth)
2315 prs_debug(ps, depth, desc, "samr_io_group_info4");
2318 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2320 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2322 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2323 gr4->hdr_acct_desc.buffer, ps, depth))
2329 /*******************************************************************
2330 reads or writes a structure.
2331 ********************************************************************/
2333 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2334 prs_struct *ps, int depth)
2336 if (UNMARSHALLING(ps))
2337 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2342 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2345 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2348 switch ((*ctr)->switch_value1) {
2350 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2354 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2358 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2362 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2366 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2373 /*******************************************************************
2374 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2375 ********************************************************************/
2377 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2378 POLICY_HND *pol, const char *acct_desc,
2381 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2385 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2386 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2388 q_e->access_mask = access_mask;
2391 /*******************************************************************
2392 reads or writes a structure.
2393 ********************************************************************/
2395 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2396 prs_struct *ps, int depth)
2401 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2407 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2410 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2412 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2413 q_e->hdr_acct_desc.buffer, ps, depth))
2418 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2424 /*******************************************************************
2425 reads or writes a structure.
2426 ********************************************************************/
2428 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2429 prs_struct *ps, int depth)
2434 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2440 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2443 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2445 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2451 /*******************************************************************
2452 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2453 ********************************************************************/
2455 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2458 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2460 q_c->group_pol = *hnd;
2463 /*******************************************************************
2464 reads or writes a structure.
2465 ********************************************************************/
2467 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2468 prs_struct *ps, int depth)
2473 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2479 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2485 /*******************************************************************
2486 reads or writes a structure.
2487 ********************************************************************/
2489 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2490 prs_struct *ps, int depth)
2495 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2501 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2504 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2510 /*******************************************************************
2511 inits a SAMR_Q_DEL_GROUPMEM structure.
2512 ********************************************************************/
2514 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2515 POLICY_HND *pol, uint32 rid)
2517 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2523 /*******************************************************************
2524 reads or writes a structure.
2525 ********************************************************************/
2527 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2528 prs_struct *ps, int depth)
2533 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2539 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2542 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2548 /*******************************************************************
2549 inits a SAMR_R_DEL_GROUPMEM structure.
2550 ********************************************************************/
2552 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2555 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2557 r_u->status = status;
2560 /*******************************************************************
2561 reads or writes a structure.
2562 ********************************************************************/
2564 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2565 prs_struct *ps, int depth)
2570 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2576 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2582 /*******************************************************************
2583 inits a SAMR_Q_ADD_GROUPMEM structure.
2584 ********************************************************************/
2586 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2587 POLICY_HND *pol, uint32 rid)
2589 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2593 q_e->unknown = 0x0005;
2596 /*******************************************************************
2597 reads or writes a structure.
2598 ********************************************************************/
2600 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2601 prs_struct *ps, int depth)
2606 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2612 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2615 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2617 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2623 /*******************************************************************
2624 inits a SAMR_R_ADD_GROUPMEM structure.
2625 ********************************************************************/
2627 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2630 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2632 r_u->status = status;
2635 /*******************************************************************
2636 reads or writes a structure.
2637 ********************************************************************/
2639 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2640 prs_struct *ps, int depth)
2645 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2651 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2657 /*******************************************************************
2658 inits a SAMR_Q_SET_GROUPINFO structure.
2659 ********************************************************************/
2661 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2662 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2664 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2670 /*******************************************************************
2671 reads or writes a structure.
2672 ********************************************************************/
2674 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2675 prs_struct *ps, int depth)
2680 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2686 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2689 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2695 /*******************************************************************
2696 inits a SAMR_R_SET_GROUPINFO structure.
2697 ********************************************************************/
2699 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2701 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2703 r_u->status = status;
2706 /*******************************************************************
2707 reads or writes a structure.
2708 ********************************************************************/
2710 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2711 prs_struct *ps, int depth)
2716 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2722 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2728 /*******************************************************************
2729 inits a SAMR_Q_QUERY_GROUPINFO structure.
2730 ********************************************************************/
2732 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2733 POLICY_HND *pol, uint16 switch_level)
2735 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2739 q_e->switch_level = switch_level;
2742 /*******************************************************************
2743 reads or writes a structure.
2744 ********************************************************************/
2746 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2747 prs_struct *ps, int depth)
2752 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2758 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2761 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2767 /*******************************************************************
2768 inits a SAMR_R_QUERY_GROUPINFO structure.
2769 ********************************************************************/
2771 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2772 GROUP_INFO_CTR * ctr, NTSTATUS status)
2774 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2776 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2778 r_u->status = status;
2781 /*******************************************************************
2782 reads or writes a structure.
2783 ********************************************************************/
2785 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2786 prs_struct *ps, int depth)
2791 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2797 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2800 if (r_u->ptr != 0) {
2801 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2807 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2813 /*******************************************************************
2814 inits a SAMR_Q_QUERY_GROUPMEM structure.
2815 ********************************************************************/
2817 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2819 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2821 q_c->group_pol = *hnd;
2824 /*******************************************************************
2825 reads or writes a structure.
2826 ********************************************************************/
2828 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2829 prs_struct *ps, int depth)
2834 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2840 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2846 /*******************************************************************
2847 inits a SAMR_R_QUERY_GROUPMEM structure.
2848 ********************************************************************/
2850 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2851 uint32 num_entries, uint32 *rid,
2852 uint32 *attr, NTSTATUS status)
2854 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2856 if (NT_STATUS_IS_OK(status)) {
2858 r_u->num_entries = num_entries;
2860 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2861 r_u->ptr_rids = rid != NULL ? 1 : 0;
2863 r_u->num_rids = num_entries;
2866 r_u->num_attrs = num_entries;
2870 r_u->num_entries = 0;
2873 r_u->status = status;
2876 /*******************************************************************
2877 reads or writes a structure.
2878 ********************************************************************/
2880 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2881 prs_struct *ps, int depth)
2888 if (UNMARSHALLING(ps))
2891 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2897 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2899 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2902 if (r_u->ptr != 0) {
2903 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2905 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2908 if (r_u->ptr_rids != 0) {
2909 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2911 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2912 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2913 if (r_u->rid == NULL)
2917 for (i = 0; i < r_u->num_rids; i++) {
2918 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2923 if (r_u->ptr_attrs != 0) {
2924 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2927 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2928 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2929 if (r_u->attr == NULL)
2933 for (i = 0; i < r_u->num_attrs; i++) {
2934 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2940 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2946 /*******************************************************************
2947 inits a SAMR_Q_QUERY_USERGROUPS structure.
2948 ********************************************************************/
2950 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2953 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2958 /*******************************************************************
2959 reads or writes a structure.
2960 ********************************************************************/
2962 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2963 prs_struct *ps, int depth)
2968 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2974 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2980 /*******************************************************************
2981 inits a SAMR_R_QUERY_USERGROUPS structure.
2982 ********************************************************************/
2984 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2985 uint32 num_gids, DOM_GID * gid,
2988 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2990 if (NT_STATUS_IS_OK(status)) {
2992 r_u->num_entries = num_gids;
2993 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2994 r_u->num_entries2 = num_gids;
2999 r_u->num_entries = 0;
3004 r_u->status = status;
3007 /*******************************************************************
3008 reads or writes a structure.
3009 ********************************************************************/
3011 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3012 prs_struct *ps, int depth)
3018 prs_debug(ps, depth, desc, "samr_io_gids");
3024 if(!prs_uint32("num_gids", ps, depth, num_gids))
3027 if ((*num_gids) != 0) {
3028 if (UNMARSHALLING(ps)) {
3029 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3032 if ((*gid) == NULL) {
3036 for (i = 0; i < (*num_gids); i++) {
3037 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3045 /*******************************************************************
3046 reads or writes a structure.
3047 ********************************************************************/
3049 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3050 prs_struct *ps, int depth)
3055 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3061 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3064 if (r_u->ptr_0 != 0) {
3065 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3067 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3070 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3071 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3078 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3084 /*******************************************************************
3085 inits a SAMR_Q_ENUM_DOMAINS structure.
3086 ********************************************************************/
3088 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3090 uint32 start_idx, uint32 size)
3092 DEBUG(5, ("init_samr_q_enum_domains\n"));
3096 q_e->start_idx = start_idx;
3097 q_e->max_size = size;
3100 /*******************************************************************
3101 reads or writes a structure.
3102 ********************************************************************/
3104 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3105 prs_struct *ps, int depth)
3110 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3116 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3119 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3121 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3127 /*******************************************************************
3128 inits a SAMR_R_ENUM_DOMAINS structure.
3129 ********************************************************************/
3131 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3132 uint32 next_idx, uint32 num_sam_entries)
3134 DEBUG(5, ("init_samr_r_enum_domains\n"));
3136 r_u->next_idx = next_idx;
3138 if (num_sam_entries != 0) {
3139 r_u->ptr_entries1 = 1;
3140 r_u->ptr_entries2 = 1;
3141 r_u->num_entries2 = num_sam_entries;
3142 r_u->num_entries3 = num_sam_entries;
3144 r_u->num_entries4 = num_sam_entries;
3146 r_u->ptr_entries1 = 0;
3147 r_u->num_entries2 = num_sam_entries;
3148 r_u->ptr_entries2 = 1;
3152 /*******************************************************************
3153 reads or writes a structure.
3154 ********************************************************************/
3156 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3157 prs_struct *ps, int depth)
3164 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3170 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3172 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3175 if (r_u->ptr_entries1 != 0) {
3176 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3178 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3180 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3183 if (UNMARSHALLING(ps)) {
3184 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3185 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3188 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3189 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3190 r_u->num_entries4 = 0;
3191 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3195 for (i = 0; i < r_u->num_entries2; i++) {
3197 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3198 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3202 for (i = 0; i < r_u->num_entries2; i++) {
3204 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3205 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3206 r_u->sam[i].hdr_name.buffer, ps,
3215 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3217 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3223 /*******************************************************************
3224 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3225 ********************************************************************/
3227 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3229 uint32 start_idx, uint32 size)
3231 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3235 q_e->start_idx = start_idx;
3236 q_e->max_size = size;
3239 /*******************************************************************
3240 reads or writes a structure.
3241 ********************************************************************/
3243 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3244 prs_struct *ps, int depth)
3249 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3255 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3258 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3260 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3266 /*******************************************************************
3267 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3268 ********************************************************************/
3270 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3271 uint32 next_idx, uint32 num_sam_entries)
3273 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3275 r_u->next_idx = next_idx;
3277 if (num_sam_entries != 0) {
3278 r_u->ptr_entries1 = 1;
3279 r_u->ptr_entries2 = 1;
3280 r_u->num_entries2 = num_sam_entries;
3281 r_u->num_entries3 = num_sam_entries;
3283 r_u->num_entries4 = num_sam_entries;
3285 r_u->ptr_entries1 = 0;
3286 r_u->num_entries2 = num_sam_entries;
3287 r_u->ptr_entries2 = 1;
3291 /*******************************************************************
3292 reads or writes a structure.
3293 ********************************************************************/
3295 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3296 prs_struct *ps, int depth)
3303 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3309 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3311 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3314 if (r_u->ptr_entries1 != 0) {
3315 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3317 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3319 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3322 if (UNMARSHALLING(ps)) {
3323 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3324 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3327 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3329 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3330 r_u->num_entries4 = 0;
3331 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3335 for (i = 0; i < r_u->num_entries2; i++) {
3336 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3340 for (i = 0; i < r_u->num_entries2; i++) {
3341 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3342 r_u->sam[i].hdr_name.buffer, ps, depth))
3349 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3351 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3357 /*******************************************************************
3358 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3359 ********************************************************************/
3361 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3362 POLICY_HND *pol, uint32 start_idx,
3365 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3369 q_e->start_idx = start_idx;
3370 q_e->max_size = size;
3374 /*******************************************************************
3375 reads or writes a structure.
3376 ********************************************************************/
3378 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3379 prs_struct *ps, int depth)
3384 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3390 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3393 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3395 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3401 /*******************************************************************
3402 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3403 ********************************************************************/
3405 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3407 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3409 r_u->next_idx = next_idx;
3411 if (num_sam_entries != 0) {
3412 r_u->ptr_entries1 = 1;
3413 r_u->ptr_entries2 = 1;
3414 r_u->num_entries2 = num_sam_entries;
3415 r_u->num_entries3 = num_sam_entries;
3417 r_u->num_entries4 = num_sam_entries;
3419 r_u->ptr_entries1 = 0;
3420 r_u->num_entries2 = num_sam_entries;
3421 r_u->ptr_entries2 = 1;
3425 /*******************************************************************
3426 reads or writes a structure.
3427 ********************************************************************/
3429 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3430 prs_struct *ps, int depth)
3437 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3443 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3445 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3448 if (r_u->ptr_entries1 != 0) {
3449 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3451 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3453 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3456 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3457 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3458 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3461 if (r_u->num_entries2 != 0 &&
3462 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3463 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3464 r_u->num_entries4 = 0;
3465 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3469 for (i = 0; i < r_u->num_entries2; i++) {
3470 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3474 for (i = 0; i < r_u->num_entries2; i++) {
3475 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3476 r_u->sam[i].hdr_name.buffer, ps,
3484 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3486 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3492 /*******************************************************************
3493 inits a ALIAS_INFO1 structure.
3494 ********************************************************************/
3496 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3498 DEBUG(5, ("init_samr_alias_info1\n"));
3500 init_unistr2(&al1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
3501 init_uni_hdr(&al1->hdr_acct_name, &al1->uni_acct_name);
3503 al1->num_member=num_member;
3505 init_unistr2(&al1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3506 init_uni_hdr(&al1->hdr_acct_desc, &al1->uni_acct_name);
3509 /*******************************************************************
3510 reads or writes a structure.
3511 ********************************************************************/
3513 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3514 prs_struct *ps, int depth)
3519 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3525 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3527 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3529 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3532 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3533 al1->hdr_acct_name.buffer, ps, depth))
3539 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3540 al1->hdr_acct_desc.buffer, ps, depth))
3546 /*******************************************************************
3547 inits a ALIAS_INFO3 structure.
3548 ********************************************************************/
3550 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3552 DEBUG(5, ("init_samr_alias_info3\n"));
3554 init_unistr2(&al3->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3555 init_uni_hdr(&al3->hdr_acct_desc, &al3->uni_acct_desc);
3558 /*******************************************************************
3559 reads or writes a structure.
3560 ********************************************************************/
3562 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
3563 prs_struct *ps, int depth)
3568 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3574 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3576 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3577 al3->hdr_acct_desc.buffer, ps, depth))
3583 /*******************************************************************
3584 reads or writes a structure.
3585 ********************************************************************/
3587 BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr,
3588 prs_struct *ps, int depth)
3593 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3596 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3598 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3601 switch (ctr->switch_value1) {
3603 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3607 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3611 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3618 /*******************************************************************
3619 inits a SAMR_Q_QUERY_ALIASINFO structure.
3620 ********************************************************************/
3622 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3623 POLICY_HND *pol, uint16 switch_level)
3625 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3628 q_e->switch_level = switch_level;
3631 /*******************************************************************
3632 reads or writes a structure.
3633 ********************************************************************/
3635 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3636 prs_struct *ps, int depth)
3641 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3647 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3650 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3656 /*******************************************************************
3657 inits a SAMR_R_QUERY_ALIASINFO structure.
3658 ********************************************************************/
3660 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3661 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3663 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3665 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3667 r_u->status = status;
3670 /*******************************************************************
3671 reads or writes a structure.
3672 ********************************************************************/
3674 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3675 prs_struct *ps, int depth)
3680 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3686 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3689 if (r_u->ptr != 0) {
3690 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3696 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3702 /*******************************************************************
3703 inits a SAMR_Q_SET_ALIASINFO structure.
3704 ********************************************************************/
3706 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3707 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3709 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3711 q_u->alias_pol = *hnd;
3715 /*******************************************************************
3716 reads or writes a structure.
3717 ********************************************************************/
3719 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3720 prs_struct *ps, int depth)
3725 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3731 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3733 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3739 /*******************************************************************
3740 reads or writes a structure.
3741 ********************************************************************/
3743 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3744 prs_struct *ps, int depth)
3749 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3754 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3760 /*******************************************************************
3761 inits a SAMR_Q_QUERY_USERALIASES structure.
3762 ********************************************************************/
3764 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3767 uint32 *ptr_sid, DOM_SID2 * sid)
3769 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3773 q_u->num_sids1 = num_sids;
3775 q_u->num_sids2 = num_sids;
3777 q_u->ptr_sid = ptr_sid;
3781 /*******************************************************************
3782 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3783 ********************************************************************/
3785 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3786 prs_struct *ps, int depth)
3794 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3800 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3803 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3805 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3811 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3814 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3815 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3816 if (q_u->ptr_sid == NULL)
3819 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3820 if (q_u->sid == NULL)
3824 for (i = 0; i < q_u->num_sids2; i++) {
3825 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3826 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3830 for (i = 0; i < q_u->num_sids2; i++) {
3831 if (q_u->ptr_sid[i] != 0) {
3832 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3833 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3841 /*******************************************************************
3842 inits a SAMR_R_QUERY_USERALIASES structure.
3843 ********************************************************************/
3845 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3846 uint32 num_rids, uint32 *rid,
3849 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3851 if (NT_STATUS_IS_OK(status)) {
3852 r_u->num_entries = num_rids;
3854 r_u->num_entries2 = num_rids;
3858 r_u->num_entries = 0;
3860 r_u->num_entries2 = 0;
3863 r_u->status = status;
3866 /*******************************************************************
3867 reads or writes a structure.
3868 ********************************************************************/
3870 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3871 prs_struct *ps, int depth)
3878 prs_debug(ps, depth, desc, "samr_io_rids");
3884 if(!prs_uint32("num_rids", ps, depth, num_rids))
3887 if ((*num_rids) != 0) {
3888 if (UNMARSHALLING(ps)) {
3890 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3895 for (i = 0; i < (*num_rids); i++) {
3896 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3897 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3905 /*******************************************************************
3906 reads or writes a structure.
3907 ********************************************************************/
3909 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3910 prs_struct *ps, int depth)
3915 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3921 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3923 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3926 if (r_u->ptr != 0) {
3927 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3933 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3939 /*******************************************************************
3940 inits a SAMR_Q_OPEN_ALIAS structure.
3941 ********************************************************************/
3943 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3944 uint32 access_mask, uint32 rid)
3946 DEBUG(5, ("init_samr_q_open_alias\n"));
3948 q_u->dom_pol = *pol;
3949 q_u->access_mask = access_mask;
3950 q_u->rid_alias = rid;
3953 /*******************************************************************
3954 reads or writes a structure.
3955 ********************************************************************/
3957 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3958 prs_struct *ps, int depth)
3963 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3969 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3972 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3974 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3980 /*******************************************************************
3981 reads or writes a structure.
3982 ********************************************************************/
3984 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
3985 prs_struct *ps, int depth)
3990 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3996 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3999 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4005 /*******************************************************************
4006 inits a SAMR_Q_LOOKUP_RIDS structure.
4007 ********************************************************************/
4009 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4010 POLICY_HND *pol, uint32 flags,
4011 uint32 num_rids, uint32 *rid)
4013 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4017 q_u->num_rids1 = num_rids;
4020 q_u->num_rids2 = num_rids;
4021 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4022 if (q_u->rid == NULL) {
4026 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4030 /*******************************************************************
4031 reads or writes a structure.
4032 ********************************************************************/
4034 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4035 prs_struct *ps, int depth)
4043 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4046 if (UNMARSHALLING(ps))
4052 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4055 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4057 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4059 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4061 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4064 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4065 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4066 if (q_u->rid == NULL)
4070 for (i = 0; i < q_u->num_rids2; i++) {
4071 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4072 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4079 /*******************************************************************
4080 inits a SAMR_R_LOOKUP_RIDS structure.
4081 ********************************************************************/
4083 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4084 uint32 num_names, UNIHDR * hdr_name,
4085 UNISTR2 *uni_name, uint32 *type)
4087 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4089 r_u->hdr_name = NULL;
4090 r_u->uni_name = NULL;
4093 if (num_names != 0) {
4094 r_u->num_names1 = num_names;
4096 r_u->num_names2 = num_names;
4098 r_u->num_types1 = num_names;
4100 r_u->num_types2 = num_names;
4102 r_u->hdr_name = hdr_name;
4103 r_u->uni_name = uni_name;
4106 r_u->num_names1 = num_names;
4108 r_u->num_names2 = num_names;
4110 r_u->num_types1 = num_names;
4112 r_u->num_types2 = num_names;
4116 /*******************************************************************
4117 reads or writes a structure.
4118 ********************************************************************/
4120 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4121 prs_struct *ps, int depth)
4128 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4134 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4136 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4139 if (r_u->ptr_names != 0) {
4141 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4145 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4146 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4147 if (r_u->hdr_name == NULL)
4150 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4151 if (r_u->uni_name == NULL)
4155 for (i = 0; i < r_u->num_names2; i++) {
4156 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4157 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4160 for (i = 0; i < r_u->num_names2; i++) {
4161 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4162 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4170 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4172 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4175 if (r_u->ptr_types != 0) {
4177 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4180 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4181 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4182 if (r_u->type == NULL)
4186 for (i = 0; i < r_u->num_types2; i++) {
4187 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4188 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4193 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4199 /*******************************************************************
4200 inits a SAMR_Q_OPEN_ALIAS structure.
4201 ********************************************************************/
4203 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4205 DEBUG(5, ("init_samr_q_delete_alias\n"));
4207 q_u->alias_pol = *hnd;
4210 /*******************************************************************
4211 reads or writes a structure.
4212 ********************************************************************/
4214 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4215 prs_struct *ps, int depth)
4220 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4226 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4232 /*******************************************************************
4233 reads or writes a structure.
4234 ********************************************************************/
4236 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4237 prs_struct *ps, int depth)
4242 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4248 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4250 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4256 /*******************************************************************
4257 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4258 ********************************************************************/
4260 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4261 POLICY_HND *hnd, const char *acct_desc)
4263 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4265 q_u->dom_pol = *hnd;
4267 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4268 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4270 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4273 /*******************************************************************
4274 reads or writes a structure.
4275 ********************************************************************/
4277 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4278 prs_struct *ps, int depth)
4283 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4289 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4292 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4294 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4295 q_u->hdr_acct_desc.buffer, ps, depth))
4300 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4306 /*******************************************************************
4307 reads or writes a structure.
4308 ********************************************************************/
4310 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4311 prs_struct *ps, int depth)
4316 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4322 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4325 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4328 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4334 /*******************************************************************
4335 inits a SAMR_Q_ADD_ALIASMEM structure.
4336 ********************************************************************/
4338 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4341 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4343 q_u->alias_pol = *hnd;
4344 init_dom_sid2(&q_u->sid, sid);
4347 /*******************************************************************
4348 reads or writes a structure.
4349 ********************************************************************/
4351 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4352 prs_struct *ps, int depth)
4357 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4363 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4365 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4371 /*******************************************************************
4372 reads or writes a structure.
4373 ********************************************************************/
4375 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4376 prs_struct *ps, int depth)
4381 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4387 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4393 /*******************************************************************
4394 inits a SAMR_Q_DEL_ALIASMEM structure.
4395 ********************************************************************/
4397 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4400 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4402 q_u->alias_pol = *hnd;
4403 init_dom_sid2(&q_u->sid, sid);
4406 /*******************************************************************
4407 reads or writes a structure.
4408 ********************************************************************/
4410 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4411 prs_struct *ps, int depth)
4416 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4422 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4424 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4430 /*******************************************************************
4431 reads or writes a structure.
4432 ********************************************************************/
4434 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4435 prs_struct *ps, int depth)
4440 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4446 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4452 /*******************************************************************
4453 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4454 ********************************************************************/
4456 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4459 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4461 q_c->alias_pol = *hnd;
4464 /*******************************************************************
4465 reads or writes a structure.
4466 ********************************************************************/
4468 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4469 prs_struct *ps, int depth)
4474 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4480 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4486 /*******************************************************************
4487 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4488 ********************************************************************/
4490 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4493 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4495 r_u->status = status;
4498 /*******************************************************************
4499 reads or writes a structure.
4500 ********************************************************************/
4502 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4503 prs_struct *ps, int depth)
4508 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4514 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4520 /*******************************************************************
4521 inits a SAMR_Q_QUERY_ALIASMEM structure.
4522 ********************************************************************/
4524 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4527 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4529 q_c->alias_pol = *hnd;
4532 /*******************************************************************
4533 reads or writes a structure.
4534 ********************************************************************/
4536 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4537 prs_struct *ps, int depth)
4542 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4548 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4554 /*******************************************************************
4555 inits a SAMR_R_QUERY_ALIASMEM structure.
4556 ********************************************************************/
4558 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4559 uint32 num_sids, DOM_SID2 * sid,
4562 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4564 if (NT_STATUS_IS_OK(status)) {
4565 r_u->num_sids = num_sids;
4566 r_u->ptr = (num_sids != 0) ? 1 : 0;
4567 r_u->num_sids1 = num_sids;
4575 r_u->status = status;
4578 /*******************************************************************
4579 reads or writes a structure.
4580 ********************************************************************/
4582 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4583 prs_struct *ps, int depth)
4590 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4596 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4598 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4601 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4602 uint32 *ptr_sid = NULL;
4604 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4607 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4612 for (i = 0; i < r_u->num_sids1; i++) {
4614 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4618 if (UNMARSHALLING(ps)) {
4619 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4622 for (i = 0; i < r_u->num_sids1; i++) {
4623 if (ptr_sid[i] != 0) {
4624 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4632 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4638 /*******************************************************************
4639 inits a SAMR_Q_LOOKUP_NAMES structure.
4640 ********************************************************************/
4642 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4643 POLICY_HND *pol, uint32 flags,
4644 uint32 num_names, const char **name)
4648 DEBUG(5, ("init_samr_q_lookup_names\n"));
4652 q_u->num_names1 = num_names;
4655 q_u->num_names2 = num_names;
4657 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4658 return NT_STATUS_NO_MEMORY;
4660 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4661 return NT_STATUS_NO_MEMORY;
4663 for (i = 0; i < num_names; i++) {
4664 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4665 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4668 return NT_STATUS_OK;
4671 /*******************************************************************
4672 reads or writes a structure.
4673 ********************************************************************/
4675 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4676 prs_struct *ps, int depth)
4683 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4686 if (UNMARSHALLING(ps))
4692 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4695 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4697 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4699 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4701 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4704 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4705 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4706 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4707 if (!q_u->hdr_name || !q_u->uni_name)
4711 for (i = 0; i < q_u->num_names2; i++) {
4712 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4716 for (i = 0; i < q_u->num_names2; i++) {
4717 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4724 /*******************************************************************
4725 inits a SAMR_R_LOOKUP_NAMES structure.
4726 ********************************************************************/
4728 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4730 uint32 *rid, uint32 *type,
4733 DEBUG(5, ("init_samr_r_lookup_names\n"));
4735 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4738 r_u->num_types1 = num_rids;
4740 r_u->num_types2 = num_rids;
4742 r_u->num_rids1 = num_rids;
4744 r_u->num_rids2 = num_rids;
4746 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4747 return NT_STATUS_NO_MEMORY;
4748 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4749 return NT_STATUS_NO_MEMORY;
4751 if (!r_u->rids || !r_u->types)
4754 for (i = 0; i < num_rids; i++) {
4755 r_u->rids[i] = rid[i];
4756 r_u->types[i] = type[i];
4761 r_u->num_types1 = 0;
4763 r_u->num_types2 = 0;
4773 r_u->status = status;
4775 return NT_STATUS_OK;
4778 /*******************************************************************
4779 reads or writes a structure.
4780 ********************************************************************/
4782 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4783 prs_struct *ps, int depth)
4791 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4794 if (UNMARSHALLING(ps))
4800 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4802 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4805 if (r_u->ptr_rids != 0) {
4806 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4809 if (r_u->num_rids2 != r_u->num_rids1) {
4814 if (UNMARSHALLING(ps))
4815 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4818 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4822 for (i = 0; i < r_u->num_rids2; i++) {
4823 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4824 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4829 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4831 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4834 if (r_u->ptr_types != 0) {
4835 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4838 if (r_u->num_types2 != r_u->num_types1) {
4843 if (UNMARSHALLING(ps))
4844 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4847 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4851 for (i = 0; i < r_u->num_types2; i++) {
4852 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4853 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4858 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4864 /*******************************************************************
4865 inits a SAMR_Q_DELETE_DOM_USER structure.
4866 ********************************************************************/
4868 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4871 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4873 q_c->user_pol = *hnd;
4876 /*******************************************************************
4877 reads or writes a structure.
4878 ********************************************************************/
4880 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4881 prs_struct *ps, int depth)
4886 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4892 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4898 /*******************************************************************
4899 reads or writes a structure.
4900 ********************************************************************/
4902 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4903 prs_struct *ps, int depth)
4908 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4914 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4916 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4922 /*******************************************************************
4923 reads or writes a structure.
4924 ********************************************************************/
4926 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4928 uint32 access_mask, uint32 rid)
4930 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4932 q_u->domain_pol = *pol;
4933 q_u->access_mask = access_mask;
4934 q_u->user_rid = rid;
4937 /*******************************************************************
4938 reads or writes a structure.
4939 ********************************************************************/
4941 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4942 prs_struct *ps, int depth)
4947 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4953 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4956 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4958 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4964 /*******************************************************************
4965 reads or writes a structure.
4966 ********************************************************************/
4968 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4969 prs_struct *ps, int depth)
4974 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4980 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4983 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4990 /*******************************************************************
4991 reads or writes a structure.
4992 ********************************************************************/
4994 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4997 uint32 acb_info, uint32 access_mask)
4999 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5001 q_u->domain_pol = *pol;
5003 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5004 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5006 q_u->acb_info = acb_info;
5007 q_u->access_mask = access_mask;
5010 /*******************************************************************
5011 reads or writes a structure.
5012 ********************************************************************/
5014 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5015 prs_struct *ps, int depth)
5020 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5026 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5029 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5031 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5036 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5038 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5044 /*******************************************************************
5045 reads or writes a structure.
5046 ********************************************************************/
5048 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5049 prs_struct *ps, int depth)
5054 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5060 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5063 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5065 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5067 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5073 /*******************************************************************
5074 inits a SAMR_Q_QUERY_USERINFO structure.
5075 ********************************************************************/
5077 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5078 POLICY_HND *hnd, uint16 switch_value)
5080 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5083 q_u->switch_value = switch_value;
5086 /*******************************************************************
5087 reads or writes a structure.
5088 ********************************************************************/
5090 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5091 prs_struct *ps, int depth)
5096 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5102 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5105 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5111 /*******************************************************************
5112 reads or writes a LOGON_HRS structure.
5113 ********************************************************************/
5115 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5116 prs_struct *ps, int depth)
5121 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5127 if(!prs_uint32("len ", ps, depth, &hrs->len))
5130 if (hrs->len > sizeof(hrs->hours)) {
5131 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5132 hrs->len = sizeof(hrs->hours);
5135 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5141 /*******************************************************************
5142 inits a SAM_USER_INFO_12 structure.
5143 ********************************************************************/
5145 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5146 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5148 DEBUG(5, ("init_sam_user_info12\n"));
5150 usr->lm_pwd_active =
5151 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5152 usr->nt_pwd_active =
5153 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5156 /*******************************************************************
5157 reads or writes a structure.
5158 ********************************************************************/
5160 static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u,
5161 prs_struct *ps, int depth)
5166 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5172 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5174 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5177 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5179 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5185 /*******************************************************************
5186 inits a SAM_USER_INFO_10 structure.
5187 ********************************************************************/
5189 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5191 DEBUG(5, ("init_sam_user_info10\n"));
5193 usr->acb_info = acb_info;
5196 /*******************************************************************
5197 reads or writes a structure.
5198 ********************************************************************/
5200 static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr,
5201 prs_struct *ps, int depth)
5206 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5212 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5218 /*******************************************************************
5219 inits a SAM_USER_INFO_11 structure.
5220 ********************************************************************/
5222 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5225 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5227 DEBUG(5, ("init_sam_user_info11\n"));
5229 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5230 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5232 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5234 usr->ptr_1 = 1; /* pointer */
5235 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5236 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5238 usr->ptr_2 = 1; /* pointer */
5239 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5241 usr->ptr_3 = 1; /* pointer */
5242 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5244 usr->rid_user = rid_user;
5245 usr->rid_group = rid_group;
5247 usr->acct_ctrl = acct_ctrl;
5248 usr->unknown_3 = 0x0000;
5250 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5251 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5253 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5254 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5256 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5257 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5260 /*******************************************************************
5261 reads or writes a structure.
5262 ********************************************************************/
5264 static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr,
5265 prs_struct *ps, int depth)
5270 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5276 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5279 if(!smb_io_time("time", &usr->expiry, ps, depth))
5282 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5285 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5288 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5291 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5293 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5296 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5299 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5301 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5304 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5306 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5309 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5311 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5313 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5315 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5317 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5319 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5322 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5325 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5328 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5334 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5340 /*************************************************************************
5342 *************************************************************************/
5344 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5346 DEBUG(10, ("init_sam_user_info24:\n"));
5347 memcpy(usr->pass, newpass, sizeof(usr->pass));
5348 usr->pw_len = pw_len;
5351 /*******************************************************************
5352 reads or writes a structure.
5353 ********************************************************************/
5355 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5356 prs_struct *ps, int depth)
5361 prs_debug(ps, depth, desc, "sam_io_user_info24");
5367 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5371 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5372 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5381 /*************************************************************************
5382 init_sam_user_info23
5384 unknown_6 = 0x0000 04ec
5386 *************************************************************************/
5388 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5389 NTTIME * logoff_time, /* all zeros */
5390 NTTIME * kickoff_time, /* all zeros */
5391 NTTIME * pass_last_set_time, /* all zeros */
5392 NTTIME * pass_can_change_time, /* all zeros */
5393 NTTIME * pass_must_change_time, /* all zeros */
5404 uint32 user_rid, /* 0x0000 0000 */
5407 uint32 fields_present,
5410 uint16 bad_password_count,
5412 char newpass[516], uint32 unknown_6)
5414 usr->logon_time = *logon_time; /* all zeros */
5415 usr->logoff_time = *logoff_time; /* all zeros */
5416 usr->kickoff_time = *kickoff_time; /* all zeros */
5417 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5418 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5419 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5421 ZERO_STRUCT(usr->nt_pwd);
5422 ZERO_STRUCT(usr->lm_pwd);
5424 usr->user_rid = user_rid; /* 0x0000 0000 */
5425 usr->group_rid = group_rid;
5426 usr->acb_info = acb_info;
5427 usr->fields_present = fields_present; /* 09f8 27fa */
5429 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5430 usr->ptr_logon_hrs = hrs ? 1 : 0;
5432 if (nt_time_is_zero(pass_must_change_time)) {
5433 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5435 usr->passmustchange=0;
5438 ZERO_STRUCT(usr->padding1);
5439 ZERO_STRUCT(usr->padding2);
5441 usr->bad_password_count = bad_password_count;
5442 usr->logon_count = logon_count;
5444 memcpy(usr->pass, newpass, sizeof(usr->pass));
5446 copy_unistr2(&usr->uni_user_name, user_name);
5447 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5449 copy_unistr2(&usr->uni_full_name, full_name);
5450 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5452 copy_unistr2(&usr->uni_home_dir, home_dir);
5453 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5455 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5456 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5458 copy_unistr2(&usr->uni_logon_script, log_scr);
5459 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5461 copy_unistr2(&usr->uni_profile_path, prof_path);
5462 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5464 copy_unistr2(&usr->uni_acct_desc, desc);
5465 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5467 copy_unistr2(&usr->uni_workstations, wkstas);
5468 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5470 copy_unistr2(&usr->uni_unknown_str, unk_str);
5471 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5473 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5474 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5476 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5479 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5482 /*************************************************************************
5483 init_sam_user_info23
5485 unknown_6 = 0x0000 04ec
5487 *************************************************************************/
5489 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5490 NTTIME * logoff_time, /* all zeros */
5491 NTTIME * kickoff_time, /* all zeros */
5492 NTTIME * pass_last_set_time, /* all zeros */
5493 NTTIME * pass_can_change_time, /* all zeros */
5494 NTTIME * pass_must_change_time, /* all zeros */
5495 char *user_name, /* NULL */
5497 char *home_dir, char *dir_drive, char *log_scr,
5498 char *prof_path, const char *desc, char *wkstas,
5499 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5500 uint32 group_rid, uint32 acb_info,
5501 uint32 fields_present, uint16 logon_divs,
5502 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5503 char newpass[516], uint32 unknown_6)
5505 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5507 usr->logon_time = *logon_time; /* all zeros */
5508 usr->logoff_time = *logoff_time; /* all zeros */
5509 usr->kickoff_time = *kickoff_time; /* all zeros */
5510 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5511 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5512 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5514 ZERO_STRUCT(usr->nt_pwd);
5515 ZERO_STRUCT(usr->lm_pwd);
5517 usr->user_rid = user_rid; /* 0x0000 0000 */
5518 usr->group_rid = group_rid;
5519 usr->acb_info = acb_info;
5520 usr->fields_present = fields_present; /* 09f8 27fa */
5522 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5523 usr->ptr_logon_hrs = hrs ? 1 : 0;
5525 if (nt_time_is_zero(pass_must_change_time)) {
5526 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5528 usr->passmustchange=0;
5531 ZERO_STRUCT(usr->padding1);
5532 ZERO_STRUCT(usr->padding2);
5534 usr->bad_password_count = bad_password_count;
5535 usr->logon_count = logon_count;
5537 memcpy(usr->pass, newpass, sizeof(usr->pass));
5539 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5540 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5542 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5543 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5545 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5546 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5548 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5549 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5551 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5552 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5554 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5555 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5557 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5558 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5560 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5561 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5563 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5564 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5566 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5567 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5569 data_blob_free(&blob);
5571 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5574 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5577 /*******************************************************************
5578 reads or writes a structure.
5579 ********************************************************************/
5581 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5582 prs_struct *ps, int depth)
5587 prs_debug(ps, depth, desc, "sam_io_user_info23");
5593 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5595 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5597 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5599 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5601 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5603 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5606 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5608 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5610 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5612 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5614 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5616 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5618 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5620 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5622 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5624 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5627 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5629 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5632 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5634 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5636 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5639 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5641 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5645 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5648 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5650 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5653 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5655 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5657 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5661 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5664 /* here begins pointed-to data */
5666 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5669 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5672 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5675 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5678 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5681 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5684 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5687 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5690 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5693 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5696 /* ok, this is only guess-work (as usual) */
5697 if (usr->ptr_logon_hrs) {
5698 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5700 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5702 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5704 } else if (UNMARSHALLING(ps)) {
5712 /*******************************************************************
5713 reads or writes a structure.
5714 NB. This structure is *definately* incorrect. It's my best guess
5715 currently for W2K SP2. The password field is encrypted in a different
5716 way than normal... And there are definately other problems. JRA.
5717 ********************************************************************/
5719 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5724 prs_debug(ps, depth, desc, "sam_io_user_info25");
5730 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5732 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5734 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5736 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5738 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5740 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5743 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5745 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5747 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5749 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5751 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5753 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5755 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5757 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5759 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5761 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5764 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5766 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5769 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5771 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5773 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5776 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5779 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5782 /* here begins pointed-to data */
5784 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5787 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5790 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5793 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5796 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5799 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5802 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5805 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5808 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5811 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5814 #if 0 /* JRA - unknown... */
5815 /* ok, this is only guess-work (as usual) */
5816 if (usr->ptr_logon_hrs) {
5817 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5819 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5821 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5823 } else if (UNMARSHALLING(ps)) {
5833 /*************************************************************************
5834 init_sam_user_info21W
5836 unknown_6 = 0x0000 04ec
5838 *************************************************************************/
5840 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5841 NTTIME * logon_time,
5842 NTTIME * logoff_time,
5843 NTTIME * kickoff_time,
5844 NTTIME * pass_last_set_time,
5845 NTTIME * pass_can_change_time,
5846 NTTIME * pass_must_change_time,
5862 uint32 fields_present,
5865 uint16 bad_password_count,
5869 usr->logon_time = *logon_time;
5870 usr->logoff_time = *logoff_time;
5871 usr->kickoff_time = *kickoff_time;
5872 usr->pass_last_set_time = *pass_last_set_time;
5873 usr->pass_can_change_time = *pass_can_change_time;
5874 usr->pass_must_change_time = *pass_must_change_time;
5876 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5877 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5879 usr->user_rid = user_rid;
5880 usr->group_rid = group_rid;
5881 usr->acb_info = acb_info;
5882 usr->fields_present = fields_present; /* 0x00ff ffff */
5884 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5885 usr->ptr_logon_hrs = hrs ? 1 : 0;
5886 usr->bad_password_count = bad_password_count;
5887 usr->logon_count = logon_count;
5889 if (nt_time_is_zero(pass_must_change_time)) {
5890 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5892 usr->passmustchange=0;
5895 ZERO_STRUCT(usr->padding1);
5896 ZERO_STRUCT(usr->padding2);
5898 copy_unistr2(&usr->uni_user_name, user_name);
5899 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5901 copy_unistr2(&usr->uni_full_name, full_name);
5902 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5904 copy_unistr2(&usr->uni_home_dir, home_dir);
5905 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5907 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5908 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5910 copy_unistr2(&usr->uni_logon_script, log_scr);
5911 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5913 copy_unistr2(&usr->uni_profile_path, prof_path);
5914 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5916 copy_unistr2(&usr->uni_acct_desc, desc);
5917 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5919 copy_unistr2(&usr->uni_workstations, wkstas);
5920 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5922 copy_unistr2(&usr->uni_unknown_str, unk_str);
5923 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5925 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5926 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5928 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5931 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5934 /*************************************************************************
5935 init_sam_user_info21
5937 unknown_6 = 0x0000 04ec
5939 *************************************************************************/
5941 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5943 NTTIME logon_time, logoff_time, kickoff_time,
5944 pass_last_set_time, pass_can_change_time,
5945 pass_must_change_time;
5947 const char* user_name = pdb_get_username(pw);
5948 const char* full_name = pdb_get_fullname(pw);
5949 const char* home_dir = pdb_get_homedir(pw);
5950 const char* dir_drive = pdb_get_dir_drive(pw);
5951 const char* logon_script = pdb_get_logon_script(pw);
5952 const char* profile_path = pdb_get_profile_path(pw);
5953 const char* description = pdb_get_acct_desc(pw);
5954 const char* workstations = pdb_get_workstations(pw);
5955 const char* munged_dial = pdb_get_munged_dial(pw);
5956 DATA_BLOB munged_dial_blob;
5959 const DOM_SID *user_sid;
5962 const DOM_SID *group_sid;
5965 munged_dial_blob = base64_decode_data_blob(munged_dial);
5967 munged_dial_blob = data_blob(NULL, 0);
5970 /* Create NTTIME structs */
5971 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5972 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5973 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5974 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5975 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
5976 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
5978 /* structure assignment */
5979 usr->logon_time = logon_time;
5980 usr->logoff_time = logoff_time;
5981 usr->kickoff_time = kickoff_time;
5982 usr->pass_last_set_time = pass_last_set_time;
5983 usr->pass_can_change_time = pass_can_change_time;
5984 usr->pass_must_change_time = pass_must_change_time;
5986 ZERO_STRUCT(usr->nt_pwd);
5987 ZERO_STRUCT(usr->lm_pwd);
5989 user_sid = pdb_get_user_sid(pw);
5991 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
5992 fstring user_sid_string;
5993 fstring domain_sid_string;
5994 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
5995 "the domain sid %s. Failing operation.\n",
5997 sid_to_string(user_sid_string, user_sid),
5998 sid_to_string(domain_sid_string, domain_sid)));
5999 data_blob_free(&munged_dial_blob);
6000 return NT_STATUS_UNSUCCESSFUL;
6003 group_sid = pdb_get_group_sid(pw);
6005 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6006 fstring group_sid_string;
6007 fstring domain_sid_string;
6008 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6009 "which conflicts with the domain sid %s. Failing operation.\n",
6011 sid_to_string(group_sid_string, group_sid),
6012 sid_to_string(domain_sid_string, domain_sid)));
6013 data_blob_free(&munged_dial_blob);
6014 return NT_STATUS_UNSUCCESSFUL;
6017 usr->user_rid = user_rid;
6018 usr->group_rid = group_rid;
6019 usr->acb_info = pdb_get_acct_ctrl(pw);
6022 Look at a user on a real NT4 PDC with usrmgr, press
6023 'ok'. Then you will see that fields_present is set to
6024 0x08f827fa. Look at the user immediately after that again,
6025 and you will see that 0x00fffff is returned. This solves
6026 the problem that you get access denied after having looked
6030 usr->fields_present = pdb_build_fields_present(pw);
6032 usr->logon_divs = pdb_get_logon_divs(pw);
6033 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6034 usr->bad_password_count = pdb_get_bad_password_count(pw);
6035 usr->logon_count = pdb_get_logon_count(pw);
6037 if (pdb_get_pass_must_change_time(pw) == 0) {
6038 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6040 usr->passmustchange=0;
6043 ZERO_STRUCT(usr->padding1);
6044 ZERO_STRUCT(usr->padding2);
6046 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6047 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6049 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6050 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6052 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6053 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6055 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6056 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6058 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6059 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6061 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6062 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6064 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6065 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6067 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6068 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6070 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6071 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6073 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6074 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6075 data_blob_free(&munged_dial_blob);
6077 usr->unknown_6 = pdb_get_unknown_6(pw);
6080 if (pdb_get_hours(pw)) {
6081 usr->logon_hrs.len = pdb_get_hours_len(pw);
6082 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6084 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6086 return NT_STATUS_OK;
6089 /*******************************************************************
6090 reads or writes a structure.
6091 ********************************************************************/
6093 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6094 prs_struct *ps, int depth)
6099 prs_debug(ps, depth, desc, "sam_io_user_info21");
6105 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6107 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6109 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6111 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6113 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6115 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6118 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6120 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6122 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6124 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6126 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6128 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6130 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6132 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6134 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6136 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6139 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6141 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6144 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6146 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6148 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6151 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6153 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6157 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6160 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6162 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6165 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6167 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6169 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6172 /* here begins pointed-to data */
6174 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6176 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6178 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6180 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6182 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6184 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6186 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6188 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6190 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6192 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6195 /* ok, this is only guess-work (as usual) */
6196 if (usr->ptr_logon_hrs) {
6199 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6201 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6203 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6205 } else if (UNMARSHALLING(ps)) {
6213 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6215 const char *munged_dial = pdb_get_munged_dial(pw);
6216 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6218 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6219 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6220 data_blob_free(&blob);
6223 /*******************************************************************
6224 reads or writes a structure.
6225 ********************************************************************/
6227 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6228 prs_struct *ps, int depth)
6233 prs_debug(ps, depth, desc, "sam_io_user_info20");
6239 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6242 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6248 /*******************************************************************
6249 inits a SAM_USERINFO_CTR structure.
6250 ********************************************************************/
6252 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6253 uint16 switch_value,
6254 SAM_USER_INFO_21 * usr)
6256 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6258 ctr->switch_value = switch_value;
6259 ctr->info.id = NULL;
6261 switch (switch_value) {
6263 ctr->info.id10 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_10);
6264 if (ctr->info.id10 == NULL)
6265 return NT_STATUS_NO_MEMORY;
6267 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6270 /* whoops - got this wrong. i think. or don't understand what's happening. */
6274 info = (void *)&id11;
6276 expire.low = 0xffffffff;
6277 expire.high = 0x7fffffff;
6279 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_11);
6280 init_sam_user_info11(ctr->info.id11, &expire,
6281 "BROOKFIELDS$", /* name */
6282 0x03ef, /* user rid */
6283 0x201, /* group rid */
6284 0x0080); /* acb info */
6290 ctr->info.id12 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_12);
6291 if (ctr->info.id12 == NULL)
6292 return NT_STATUS_NO_MEMORY;
6294 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6298 SAM_USER_INFO_21 *cusr;
6299 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6300 ctr->info.id21 = cusr;
6301 if (ctr->info.id21 == NULL)
6302 return NT_STATUS_NO_MEMORY;
6303 memcpy(cusr, usr, sizeof(*usr));
6304 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6305 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6309 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6310 return NT_STATUS_INVALID_INFO_CLASS;
6313 return NT_STATUS_OK;
6316 /*******************************************************************
6317 inits a SAM_USERINFO_CTR structure.
6318 ********************************************************************/
6320 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6321 uint16 switch_value, void *info)
6323 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6325 ctr->switch_value = switch_value;
6326 ctr->info.id = info;
6328 switch (switch_value) {
6330 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6331 dump_data(100, (char *)sess_key->data, sess_key->length);
6332 dump_data(100, (char *)ctr->info.id24->pass, 516);
6335 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6336 dump_data(100, (char *)sess_key->data, sess_key->length);
6337 dump_data(100, (char *)ctr->info.id23->pass, 516);
6340 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6344 /*******************************************************************
6345 reads or writes a structure.
6346 ********************************************************************/
6348 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6349 prs_struct *ps, int depth)
6352 SAM_USERINFO_CTR *ctr;
6354 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6357 if (UNMARSHALLING(ps)) {
6358 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6366 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6368 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6375 switch (ctr->switch_value) {
6377 if (UNMARSHALLING(ps))
6378 ctr->info.id10 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_10,1);
6379 if (ctr->info.id10 == NULL) {
6380 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6383 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6386 if (UNMARSHALLING(ps))
6387 ctr->info.id11 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_11,1);
6389 if (ctr->info.id11 == NULL) {
6390 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6393 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6396 if (UNMARSHALLING(ps))
6397 ctr->info.id12 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_12,1);
6399 if (ctr->info.id12 == NULL) {
6400 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6403 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6406 if (UNMARSHALLING(ps))
6407 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6409 if (ctr->info.id20 == NULL) {
6410 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6413 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6416 if (UNMARSHALLING(ps))
6417 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6419 if (ctr->info.id21 == NULL) {
6420 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6423 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6426 if (UNMARSHALLING(ps))
6427 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6429 if (ctr->info.id23 == NULL) {
6430 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6433 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6436 if (UNMARSHALLING(ps))
6437 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6439 if (ctr->info.id24 == NULL) {
6440 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6443 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6446 if (UNMARSHALLING(ps))
6447 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6449 if (ctr->info.id25 == NULL) {
6450 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6453 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6456 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6464 /*******************************************************************
6465 inits a SAMR_R_QUERY_USERINFO structure.
6466 ********************************************************************/
6468 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6469 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6471 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6476 if (NT_STATUS_IS_OK(status)) {
6481 r_u->status = status; /* return status */
6484 /*******************************************************************
6485 reads or writes a structure.
6486 ********************************************************************/
6488 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6489 prs_struct *ps, int depth)
6494 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6500 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6503 if (r_u->ptr != 0) {
6504 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6510 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6516 /*******************************************************************
6517 inits a SAMR_Q_SET_USERINFO structure.
6518 ********************************************************************/
6520 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6521 POLICY_HND *hnd, DATA_BLOB *sess_key,
6522 uint16 switch_value, void *info)
6524 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6527 q_u->switch_value = switch_value;
6528 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6531 /*******************************************************************
6532 reads or writes a structure.
6533 ********************************************************************/
6535 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6536 prs_struct *ps, int depth)
6541 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6547 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6549 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6551 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6557 /*******************************************************************
6558 inits a SAMR_R_SET_USERINFO structure.
6559 ********************************************************************/
6561 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6563 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6565 r_u->status = status; /* return status */
6568 /*******************************************************************
6569 reads or writes a structure.
6570 ********************************************************************/
6572 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6573 prs_struct *ps, int depth)
6578 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6584 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6590 /*******************************************************************
6591 inits a SAMR_Q_SET_USERINFO2 structure.
6592 ********************************************************************/
6594 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6595 POLICY_HND *hnd, DATA_BLOB *sess_key,
6596 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6598 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6601 q_u->switch_value = switch_value;
6604 if (q_u->ctr != NULL)
6605 q_u->ctr->switch_value = switch_value;
6607 switch (switch_value) {
6609 SamOEMhashBlob(ctr->info.id12->lm_pwd, 16, sess_key);
6610 SamOEMhashBlob(ctr->info.id12->nt_pwd, 16, sess_key);
6611 dump_data(100, (char *)sess_key->data, sess_key->length);
6612 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6613 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6618 /*******************************************************************
6619 reads or writes a structure.
6620 ********************************************************************/
6622 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6623 prs_struct *ps, int depth)
6628 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6634 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6637 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6639 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6645 /*******************************************************************
6646 inits a SAMR_R_SET_USERINFO2 structure.
6647 ********************************************************************/
6649 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6651 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6653 r_u->status = status; /* return status */
6656 /*******************************************************************
6657 reads or writes a structure.
6658 ********************************************************************/
6660 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6661 prs_struct *ps, int depth)
6666 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6672 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6678 /*******************************************************************
6679 inits a SAMR_Q_CONNECT structure.
6680 ********************************************************************/
6682 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6683 char *srv_name, uint32 access_mask)
6685 DEBUG(5, ("init_samr_q_connect\n"));
6687 /* make PDC server name \\server */
6688 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6689 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6691 /* example values: 0x0000 0002 */
6692 q_u->access_mask = access_mask;
6695 /*******************************************************************
6696 reads or writes a structure.
6697 ********************************************************************/
6699 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6700 prs_struct *ps, int depth)
6705 prs_debug(ps, depth, desc, "samr_io_q_connect");
6711 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6713 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6718 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6724 /*******************************************************************
6725 reads or writes a structure.
6726 ********************************************************************/
6728 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6729 prs_struct *ps, int depth)
6734 prs_debug(ps, depth, desc, "samr_io_r_connect");
6740 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6743 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6749 /*******************************************************************
6750 inits a SAMR_Q_CONNECT4 structure.
6751 ********************************************************************/
6753 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6754 char *srv_name, uint32 access_mask)
6756 DEBUG(5, ("init_samr_q_connect\n"));
6758 /* make PDC server name \\server */
6759 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6760 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6762 /* Only value we've seen, possibly an address type ? */
6765 /* example values: 0x0000 0002 */
6766 q_u->access_mask = access_mask;
6769 /*******************************************************************
6770 reads or writes a structure.
6771 ********************************************************************/
6773 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6774 prs_struct *ps, int depth)
6779 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6785 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6787 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6792 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6794 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6800 /*******************************************************************
6801 reads or writes a structure.
6802 ********************************************************************/
6804 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6805 prs_struct *ps, int depth)
6810 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6816 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6819 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6825 /*******************************************************************
6826 inits a SAMR_Q_CONNECT_ANON structure.
6827 ********************************************************************/
6829 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6831 DEBUG(5, ("init_samr_q_connect_anon\n"));
6834 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6835 q_u->unknown_1 = 0x01;
6836 q_u->access_mask = 0x20;
6839 /*******************************************************************
6840 reads or writes a structure.
6841 ********************************************************************/
6843 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6844 prs_struct *ps, int depth)
6849 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6855 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6857 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6859 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6861 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6867 /*******************************************************************
6868 reads or writes a structure.
6869 ********************************************************************/
6871 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6872 prs_struct *ps, int depth)
6877 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6883 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6886 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6892 /*******************************************************************
6893 inits a SAMR_Q_GET_DOM_PWINFO structure.
6894 ********************************************************************/
6896 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6899 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6902 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
6903 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
6906 /*******************************************************************
6907 reads or writes a structure.
6908 ********************************************************************/
6910 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6911 prs_struct *ps, int depth)
6916 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6922 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6924 if (q_u->ptr != 0) {
6925 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6927 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6934 /*******************************************************************
6935 reads or writes a structure.
6936 ********************************************************************/
6938 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6939 prs_struct *ps, int depth)
6944 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6951 * see the Samba4 IDL for what these actually are.
6954 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
6958 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
6961 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6967 /*******************************************************************
6968 make a SAMR_ENC_PASSWD structure.
6969 ********************************************************************/
6971 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
6979 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6983 /*******************************************************************
6984 reads or writes a SAMR_ENC_PASSWD structure.
6985 ********************************************************************/
6987 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
6988 prs_struct *ps, int depth)
6993 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6999 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7002 if (pwd->ptr != 0) {
7003 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7010 /*******************************************************************
7011 inits a SAMR_ENC_HASH structure.
7012 ********************************************************************/
7014 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7022 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7026 /*******************************************************************
7027 reads or writes a SAMR_ENC_HASH structure.
7028 ********************************************************************/
7030 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7031 prs_struct *ps, int depth)
7036 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7042 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7044 if (hsh->ptr != 0) {
7045 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7052 /*******************************************************************
7053 inits a SAMR_R_GET_DOM_PWINFO structure.
7054 ********************************************************************/
7056 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7057 const char *dest_host, const char *user_name,
7058 const char nt_newpass[516],
7059 const uchar nt_oldhash[16],
7060 const char lm_newpass[516],
7061 const uchar lm_oldhash[16])
7063 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7066 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7067 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7069 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7070 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7072 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7073 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7075 q_u->unknown = 0x01;
7077 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7078 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7081 /*******************************************************************
7082 reads or writes a structure.
7083 ********************************************************************/
7085 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7086 prs_struct *ps, int depth)
7091 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7097 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7100 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7102 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7107 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7109 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7112 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7114 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7117 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7120 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7122 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7128 /*******************************************************************
7129 inits a SAMR_R_CHGPASSWD_USER structure.
7130 ********************************************************************/
7132 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7134 DEBUG(5, ("init_r_chgpasswd_user\n"));
7136 r_u->status = status;
7139 /*******************************************************************
7140 reads or writes a structure.
7141 ********************************************************************/
7143 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7144 prs_struct *ps, int depth)
7149 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7155 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7161 /*******************************************************************
7162 reads or writes a structure.
7163 ********************************************************************/
7165 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7166 POLICY_HND *domain_pol, uint16 switch_value)
7168 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7170 q_u->domain_pol = *domain_pol;
7171 q_u->switch_value = switch_value;
7174 /*******************************************************************
7175 reads or writes a structure.
7176 ********************************************************************/
7178 BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7179 prs_struct *ps, int depth)
7184 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7190 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7193 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7199 /*******************************************************************
7200 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7201 ********************************************************************/
7203 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7204 uint16 switch_value, SAM_UNK_CTR * ctr,
7207 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7210 r_u->switch_value = 0;
7211 r_u->status = status; /* return status */
7213 if (NT_STATUS_IS_OK(status)) {
7214 r_u->switch_value = switch_value;
7220 /*******************************************************************
7221 reads or writes a structure.
7222 ********************************************************************/
7224 BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u,
7225 prs_struct *ps, int depth)
7230 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7236 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7239 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7240 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7245 switch (r_u->switch_value) {
7247 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7251 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7255 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7259 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7263 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7267 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7271 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7275 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7276 r_u->switch_value));
7277 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7285 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7292 /*******************************************************************
7293 reads or writes a structure.
7294 ********************************************************************/
7296 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7297 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7299 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7301 q_u->domain_pol = *domain_pol;
7302 q_u->switch_value0 = switch_value;
7304 q_u->switch_value = switch_value;
7309 /*******************************************************************
7310 reads or writes a structure.
7311 ********************************************************************/
7313 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7314 prs_struct *ps, int depth)
7319 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7325 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7328 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7331 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7337 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7340 switch (q_u->switch_value) {
7343 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7347 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7351 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7355 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7359 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7363 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7367 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7371 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7372 q_u->switch_value));
7379 /*******************************************************************
7380 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7381 ********************************************************************/
7383 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7385 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7387 r_u->status = status; /* return status */
7390 /*******************************************************************
7391 reads or writes a structure.
7392 ********************************************************************/
7394 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7395 prs_struct *ps, int depth)
7400 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7406 if(!prs_ntstatus("status", ps, depth, &r_u->status))