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.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "rpc_parse.h"
30 /*******************************************************************
31 inits a SAMR_Q_CLOSE_HND structure.
32 ********************************************************************/
34 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
36 DEBUG(5, ("init_samr_q_close_hnd\n"));
41 /*******************************************************************
42 reads or writes a structure.
43 ********************************************************************/
45 BOOL samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND * q_u,
46 prs_struct *ps, int depth)
51 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
57 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
60 /*******************************************************************
61 reads or writes a structure.
62 ********************************************************************/
64 BOOL samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND * r_u,
65 prs_struct *ps, int depth)
70 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
76 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
79 if(!prs_ntstatus("status", ps, depth, &r_u->status))
85 /*******************************************************************
86 inits a SAMR_Q_LOOKUP_DOMAIN structure.
87 ********************************************************************/
89 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
90 POLICY_HND *pol, char *dom_name)
92 int len_name = strlen(dom_name);
94 DEBUG(5, ("init_samr_q_lookup_domain\n"));
96 q_u->connect_pol = *pol;
98 init_uni_hdr(&q_u->hdr_domain, len_name);
99 init_unistr2(&q_u->uni_domain, dom_name, len_name);
102 /*******************************************************************
103 reads or writes a structure.
104 ********************************************************************/
105 BOOL samr_io_q_lookup_domain(char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
106 prs_struct *ps, int depth)
111 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
117 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
120 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
123 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
129 /*******************************************************************
130 inits a SAMR_R_LOOKUP_DOMAIN structure.
131 ********************************************************************/
133 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
134 DOM_SID *dom_sid, NTSTATUS status)
136 DEBUG(5, ("init_samr_r_lookup_domain\n"));
138 r_u->status = status;
140 if (NT_STATUS_IS_OK(status)) {
142 init_dom_sid2(&r_u->dom_sid, dom_sid);
146 /*******************************************************************
147 reads or writes a structure.
148 ********************************************************************/
150 BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
151 prs_struct *ps, int depth)
156 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
162 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
165 if (r_u->ptr_sid != 0) {
166 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
172 if(!prs_ntstatus("status", ps, depth, &r_u->status))
178 /*******************************************************************
179 reads or writes a structure.
180 ********************************************************************/
182 void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
184 DEBUG(5, ("samr_init_samr_q_unknown_2d\n"));
186 q_u->dom_pol = *dom_pol;
187 init_dom_sid2(&q_u->sid, sid);
190 /*******************************************************************
191 reads or writes a structure.
192 ********************************************************************/
194 BOOL samr_io_q_unknown_2d(char *desc, SAMR_Q_UNKNOWN_2D * q_u,
195 prs_struct *ps, int depth)
200 prs_debug(ps, depth, desc, "samr_io_q_unknown_2d");
206 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
209 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
218 /*******************************************************************
219 reads or writes a structure.
220 ********************************************************************/
222 BOOL samr_io_r_unknown_2d(char *desc, SAMR_R_UNKNOWN_2D * r_u,
223 prs_struct *ps, int depth)
228 prs_debug(ps, depth, desc, "samr_io_r_unknown_2d");
234 if(!prs_ntstatus("status", ps, depth, &r_u->status))
240 /*******************************************************************
241 reads or writes a structure.
242 ********************************************************************/
244 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
245 POLICY_HND *pol, uint32 flags,
248 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
252 init_dom_sid2(&q_u->dom_sid, sid);
255 /*******************************************************************
256 reads or writes a structure.
257 ********************************************************************/
259 BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
260 prs_struct *ps, int depth)
265 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
271 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
274 if(!prs_uint32("flags", ps, depth, &q_u->flags))
277 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
283 /*******************************************************************
284 reads or writes a structure.
285 ********************************************************************/
287 BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN * r_u,
288 prs_struct *ps, int depth)
293 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
299 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
302 if(!prs_ntstatus("status", ps, depth, &r_u->status))
308 /*******************************************************************
309 reads or writes a structure.
310 ********************************************************************/
312 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
313 POLICY_HND *user_pol)
315 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
317 q_u->user_pol = *user_pol;
320 /*******************************************************************
321 reads or writes a structure.
322 ********************************************************************/
324 BOOL samr_io_q_get_usrdom_pwinfo(char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
325 prs_struct *ps, int depth)
330 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
336 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
339 /*******************************************************************
341 ********************************************************************/
343 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
345 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
347 r_u->unknown_0 = 0x0000;
351 * r_u->unknown_1 = 0x0015;
354 r_u->unknown_1 = 0x01D1;
355 r_u->unknown_1 = 0x0015;
357 r_u->unknown_2 = 0x00000000;
359 r_u->status = status;
362 /*******************************************************************
363 reads or writes a structure.
364 ********************************************************************/
366 BOOL samr_io_r_get_usrdom_pwinfo(char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
367 prs_struct *ps, int depth)
372 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
378 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
380 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
382 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
384 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
390 /*******************************************************************
391 reads or writes a structure.
392 ********************************************************************/
394 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
395 POLICY_HND *user_pol, uint32 sec_info)
397 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
399 q_u->user_pol = *user_pol;
400 q_u->sec_info = sec_info;
404 /*******************************************************************
405 reads or writes a structure.
406 ********************************************************************/
408 BOOL samr_io_q_query_sec_obj(char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
409 prs_struct *ps, int depth)
414 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
420 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
423 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
429 /*******************************************************************
430 reads or writes a structure.
431 ********************************************************************/
433 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
434 POLICY_HND *domain_pol, uint16 switch_value)
436 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
438 q_u->domain_pol = *domain_pol;
439 q_u->switch_value = switch_value;
442 /*******************************************************************
443 reads or writes a structure.
444 ********************************************************************/
446 BOOL samr_io_q_query_dom_info(char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
447 prs_struct *ps, int depth)
452 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
458 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
461 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
468 /*******************************************************************
470 ********************************************************************/
472 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
474 u_3->logout.low = nt_logout.low;
475 u_3->logout.high = nt_logout.high;
478 /*******************************************************************
479 reads or writes a structure.
480 ********************************************************************/
482 static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 * u_3,
483 prs_struct *ps, int depth)
488 prs_debug(ps, depth, desc, "sam_io_unk_info3");
491 if(!smb_io_time("logout", &u_3->logout, ps, depth))
497 /*******************************************************************
499 ********************************************************************/
501 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
503 u_6->unknown_0 = 0x00000000;
505 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
508 /*******************************************************************
509 reads or writes a structure.
510 ********************************************************************/
512 static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 * u_6,
513 prs_struct *ps, int depth)
518 prs_debug(ps, depth, desc, "sam_io_unk_info6");
521 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
523 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
525 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
531 /*******************************************************************
533 ********************************************************************/
535 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
537 u_7->unknown_0 = 0x0003;
540 /*******************************************************************
541 reads or writes a structure.
542 ********************************************************************/
544 static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 * u_7,
545 prs_struct *ps, int depth)
550 prs_debug(ps, depth, desc, "sam_io_unk_info7");
553 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
559 /*******************************************************************
561 ********************************************************************/
563 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
565 u_12->duration.low = nt_lock_duration.low;
566 u_12->duration.high = nt_lock_duration.high;
567 u_12->reset_count.low = nt_reset_time.low;
568 u_12->reset_count.high = nt_reset_time.high;
570 u_12->bad_attempt_lockout = lockout;
573 /*******************************************************************
574 reads or writes a structure.
575 ********************************************************************/
577 static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
578 prs_struct *ps, int depth)
583 prs_debug(ps, depth, desc, "sam_io_unk_info12");
586 if(!smb_io_time("duration", &u_12->duration, ps, depth))
588 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
590 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
596 /*******************************************************************
598 ********************************************************************/
599 void init_unk_info5(SAM_UNK_INFO_5 * u_5,char *server)
601 int len_server = strlen(server);
603 init_uni_hdr(&u_5->hdr_server, len_server);
605 init_unistr2(&u_5->uni_server, server, len_server);
608 /*******************************************************************
609 reads or writes a structure.
610 ********************************************************************/
612 static BOOL sam_io_unk_info5(char *desc, SAM_UNK_INFO_5 * u_5,
613 prs_struct *ps, int depth)
618 prs_debug(ps, depth, desc, "sam_io_unk_info5");
621 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
624 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
630 /*******************************************************************
632 ********************************************************************/
633 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
634 char *domain, char *server,
635 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
637 int len_domain = strlen(domain);
638 int len_server = strlen(server);
640 u_2->unknown_0 = 0x00000000;
641 u_2->unknown_1 = 0x80000000;
642 u_2->unknown_2 = 0x00000000;
645 init_uni_hdr(&u_2->hdr_domain, len_domain);
646 init_uni_hdr(&u_2->hdr_server, len_server);
648 u_2->seq_num = seq_num;
649 u_2->unknown_3 = 0x00000000;
651 u_2->unknown_4 = 0x00000001;
652 u_2->unknown_5 = 0x00000003;
653 u_2->unknown_6 = 0x00000001;
654 u_2->num_domain_usrs = num_users;
655 u_2->num_domain_grps = num_groups;
656 u_2->num_local_grps = num_alias;
658 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
660 init_unistr2(&u_2->uni_domain, domain, len_domain);
661 init_unistr2(&u_2->uni_server, server, len_server);
664 /*******************************************************************
665 reads or writes a structure.
666 ********************************************************************/
668 static BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 * u_2,
669 prs_struct *ps, int depth)
674 prs_debug(ps, depth, desc, "sam_io_unk_info2");
677 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
679 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
681 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
684 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
686 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
688 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
691 /* put all the data in here, at the moment, including what the above
692 pointer is referring to
695 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
697 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
700 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
702 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
704 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
706 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
708 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
710 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
713 if(!prs_uint8s(False, "padding", ps, depth, u_2->padding,sizeof(u_2->padding)))
716 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
718 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
724 /*******************************************************************
726 ********************************************************************/
728 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
729 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
731 u_1->min_length_password = min_pass_len;
732 u_1->password_history = pass_hist;
735 /* password never expire */
736 u_1->expire.high = nt_expire.high;
737 u_1->expire.low = nt_expire.low;
739 /* can change the password now */
740 u_1->min_passwordage.high = nt_min_age.high;
741 u_1->min_passwordage.low = nt_min_age.low;
745 /*******************************************************************
746 reads or writes a structure.
747 ********************************************************************/
749 static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 * u_1,
750 prs_struct *ps, int depth)
755 prs_debug(ps, depth, desc, "sam_io_unk_info1");
758 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
760 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
762 if(!prs_uint32("flag", ps, depth, &u_1->flag))
764 if(!smb_io_time("expire", &u_1->expire, ps, depth))
766 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
772 /*******************************************************************
773 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
774 ********************************************************************/
776 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
777 uint16 switch_value, SAM_UNK_CTR * ctr,
780 DEBUG(5, ("init_samr_r_query_dom_info\n"));
783 r_u->switch_value = 0;
784 r_u->status = status; /* return status */
786 if (NT_STATUS_IS_OK(status)) {
787 r_u->switch_value = switch_value;
793 /*******************************************************************
794 reads or writes a structure.
795 ********************************************************************/
797 BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
798 prs_struct *ps, int depth)
803 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
809 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
812 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
813 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
818 switch (r_u->switch_value) {
820 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
824 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
828 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
832 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
836 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
840 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
844 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
848 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
850 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
858 if(!prs_ntstatus("status", ps, depth, &r_u->status))
864 /*******************************************************************
865 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
866 ********************************************************************/
868 BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
869 prs_struct *ps, int depth)
874 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
880 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
883 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
887 if(!prs_ntstatus("status", ps, depth, &r_u->status))
893 /*******************************************************************
894 reads or writes a SAM_STR1 structure.
895 ********************************************************************/
897 static BOOL sam_io_sam_str1(char *desc, SAM_STR1 * sam, uint32 acct_buf,
898 uint32 name_buf, uint32 desc_buf,
899 prs_struct *ps, int depth)
904 prs_debug(ps, depth, desc, "sam_io_sam_str1");
909 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
912 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
915 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
921 /*******************************************************************
922 inits a SAM_ENTRY1 structure.
923 ********************************************************************/
925 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
926 uint32 len_sam_name, uint32 len_sam_full,
927 uint32 len_sam_desc, uint32 rid_user,
930 DEBUG(5, ("init_sam_entry1\n"));
934 sam->user_idx = user_idx;
935 sam->rid_user = rid_user;
936 sam->acb_info = acb_info;
938 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
939 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
940 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
943 /*******************************************************************
944 reads or writes a SAM_ENTRY1 structure.
945 ********************************************************************/
947 static BOOL sam_io_sam_entry1(char *desc, SAM_ENTRY1 * sam,
948 prs_struct *ps, int depth)
953 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
959 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
962 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
964 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
970 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
972 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
974 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
980 /*******************************************************************
981 reads or writes a SAM_STR2 structure.
982 ********************************************************************/
984 static BOOL sam_io_sam_str2(char *desc, SAM_STR2 * sam, uint32 acct_buf,
985 uint32 desc_buf, prs_struct *ps, int depth)
990 prs_debug(ps, depth, desc, "sam_io_sam_str2");
996 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
998 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1004 /*******************************************************************
1005 inits a SAM_ENTRY2 structure.
1006 ********************************************************************/
1007 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1008 uint32 len_sam_name, uint32 len_sam_desc,
1009 uint32 rid_user, uint16 acb_info)
1011 DEBUG(5, ("init_sam_entry2\n"));
1013 sam->user_idx = user_idx;
1014 sam->rid_user = rid_user;
1015 sam->acb_info = acb_info;
1017 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
1018 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
1021 /*******************************************************************
1022 reads or writes a SAM_ENTRY2 structure.
1023 ********************************************************************/
1025 static BOOL sam_io_sam_entry2(char *desc, SAM_ENTRY2 * sam,
1026 prs_struct *ps, int depth)
1031 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1037 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1040 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1042 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1048 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1050 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1056 /*******************************************************************
1057 reads or writes a SAM_STR3 structure.
1058 ********************************************************************/
1060 static BOOL sam_io_sam_str3(char *desc, SAM_STR3 * sam, uint32 acct_buf,
1061 uint32 desc_buf, prs_struct *ps, int depth)
1066 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1072 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1074 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1080 /*******************************************************************
1081 inits a SAM_ENTRY3 structure.
1082 ********************************************************************/
1084 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1085 uint32 len_grp_name, uint32 len_grp_desc,
1088 DEBUG(5, ("init_sam_entry3\n"));
1090 sam->grp_idx = grp_idx;
1091 sam->rid_grp = rid_grp;
1092 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1094 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1095 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1098 /*******************************************************************
1099 reads or writes a SAM_ENTRY3 structure.
1100 ********************************************************************/
1102 static BOOL sam_io_sam_entry3(char *desc, SAM_ENTRY3 * sam,
1103 prs_struct *ps, int depth)
1108 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1114 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1117 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1119 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1122 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1124 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1130 /*******************************************************************
1131 inits a SAM_ENTRY4 structure.
1132 ********************************************************************/
1134 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1135 uint32 len_acct_name)
1137 DEBUG(5, ("init_sam_entry4\n"));
1139 sam->user_idx = user_idx;
1140 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1143 /*******************************************************************
1144 reads or writes a SAM_ENTRY4 structure.
1145 ********************************************************************/
1147 static BOOL sam_io_sam_entry4(char *desc, SAM_ENTRY4 * sam,
1148 prs_struct *ps, int depth)
1153 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1159 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1161 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1167 /*******************************************************************
1168 inits a SAM_ENTRY5 structure.
1169 ********************************************************************/
1171 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1172 uint32 len_grp_name)
1174 DEBUG(5, ("init_sam_entry5\n"));
1176 sam->grp_idx = grp_idx;
1177 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1181 /*******************************************************************
1182 reads or writes a SAM_ENTRY5 structure.
1183 ********************************************************************/
1185 static BOOL sam_io_sam_entry5(char *desc, SAM_ENTRY5 * sam,
1186 prs_struct *ps, int depth)
1191 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1197 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1199 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1205 /*******************************************************************
1206 inits a SAM_ENTRY structure.
1207 ********************************************************************/
1209 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1211 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1214 init_uni_hdr(&sam->hdr_name, len_sam_name);
1217 /*******************************************************************
1218 reads or writes a SAM_ENTRY structure.
1219 ********************************************************************/
1221 static BOOL sam_io_sam_entry(char *desc, SAM_ENTRY * sam,
1222 prs_struct *ps, int depth)
1227 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1232 if(!prs_uint32("rid", ps, depth, &sam->rid))
1234 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1240 /*******************************************************************
1241 inits a SAMR_Q_ENUM_DOM_USERS structure.
1242 ********************************************************************/
1244 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1246 uint16 acb_mask, uint16 unk_1, uint32 size)
1248 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1252 q_e->start_idx = start_idx; /* zero indicates lots */
1253 q_e->acb_mask = acb_mask;
1254 q_e->unknown_1 = unk_1;
1255 q_e->max_size = size;
1258 /*******************************************************************
1259 reads or writes a structure.
1260 ********************************************************************/
1262 BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1263 prs_struct *ps, int depth)
1268 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1274 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1277 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1279 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1281 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1284 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1291 /*******************************************************************
1292 inits a SAMR_R_ENUM_DOM_USERS structure.
1293 ********************************************************************/
1295 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1296 uint32 next_idx, uint32 num_sam_entries)
1298 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1300 r_u->next_idx = next_idx;
1302 if (num_sam_entries != 0) {
1303 r_u->ptr_entries1 = 1;
1304 r_u->ptr_entries2 = 1;
1305 r_u->num_entries2 = num_sam_entries;
1306 r_u->num_entries3 = num_sam_entries;
1308 r_u->num_entries4 = num_sam_entries;
1310 r_u->ptr_entries1 = 0;
1311 r_u->num_entries2 = num_sam_entries;
1312 r_u->ptr_entries2 = 1;
1316 /*******************************************************************
1317 reads or writes a structure.
1318 ********************************************************************/
1320 BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1321 prs_struct *ps, int depth)
1328 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1334 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1336 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1339 if (r_u->ptr_entries1 != 0) {
1340 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1342 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1344 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1347 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1348 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1349 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
1352 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1353 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1354 r_u->num_entries4 = 0;
1355 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1359 for (i = 0; i < r_u->num_entries2; i++) {
1360 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1364 for (i = 0; i < r_u->num_entries2; i++) {
1365 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1374 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1376 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1382 /*******************************************************************
1383 inits a SAMR_Q_QUERY_DISPINFO structure.
1384 ********************************************************************/
1386 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1387 uint16 switch_level, uint32 start_idx,
1390 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1392 q_e->domain_pol = *pol;
1394 q_e->switch_level = switch_level;
1396 q_e->start_idx = start_idx;
1397 q_e->max_entries = max_entries;
1398 q_e->max_size = 0xffff; /* Not especially useful */
1401 /*******************************************************************
1402 reads or writes a structure.
1403 ********************************************************************/
1405 BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1406 prs_struct *ps, int depth)
1411 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1417 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1420 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1425 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1427 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1429 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1435 /*******************************************************************
1436 inits a SAM_DISPINFO_1 structure.
1437 ********************************************************************/
1439 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1440 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1442 uint32 len_sam_name, len_sam_full, len_sam_desc;
1445 SAM_ACCOUNT *pwd = NULL;
1448 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1451 return NT_STATUS_OK;
1453 sam->sam=(SAM_ENTRY1 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY1));
1455 return NT_STATUS_NO_MEMORY;
1457 sam->str=(SAM_STR1 *)talloc(ctx, num_entries*sizeof(SAM_STR1));
1459 return NT_STATUS_NO_MEMORY;
1461 ZERO_STRUCTP(sam->sam);
1462 ZERO_STRUCTP(sam->str);
1464 for (i = 0; i < num_entries ; i++) {
1465 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1467 pwd=disp_user_info[i+start_idx].sam;
1469 len_sam_name = strlen(pdb_get_username(pwd));
1470 len_sam_full = strlen(pdb_get_fullname(pwd));
1471 len_sam_desc = strlen(pdb_get_acct_desc(pwd));
1473 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1474 len_sam_name, len_sam_full, len_sam_desc,
1475 pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd));
1477 ZERO_STRUCTP(&sam->str[i].uni_acct_name);
1478 ZERO_STRUCTP(&sam->str[i].uni_full_name);
1479 ZERO_STRUCTP(&sam->str[i].uni_acct_desc);
1481 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), len_sam_name);
1482 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), len_sam_full);
1483 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1486 return NT_STATUS_OK;
1489 /*******************************************************************
1490 reads or writes a structure.
1491 ********************************************************************/
1493 static BOOL sam_io_sam_dispinfo_1(char *desc, SAM_DISPINFO_1 * sam,
1495 prs_struct *ps, int depth)
1499 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1505 if (UNMARSHALLING(ps) && num_entries > 0) {
1507 if ((sam->sam = (SAM_ENTRY1 *)
1508 prs_alloc_mem(ps, sizeof(SAM_ENTRY1) *
1509 num_entries)) == NULL) {
1510 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1514 if ((sam->str = (SAM_STR1 *)
1515 prs_alloc_mem(ps, sizeof(SAM_STR1) *
1516 num_entries)) == NULL) {
1517 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1522 for (i = 0; i < num_entries; i++) {
1523 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1527 for (i = 0; i < num_entries; i++) {
1528 if(!sam_io_sam_str1("", &sam->str[i],
1529 sam->sam[i].hdr_acct_name.buffer,
1530 sam->sam[i].hdr_user_name.buffer,
1531 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1538 /*******************************************************************
1539 inits a SAM_DISPINFO_2 structure.
1540 ********************************************************************/
1542 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1543 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1545 uint32 len_sam_name, len_sam_desc;
1548 SAM_ACCOUNT *pwd = NULL;
1551 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1554 return NT_STATUS_OK;
1556 if (!(sam->sam=(SAM_ENTRY2 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY2))))
1557 return NT_STATUS_NO_MEMORY;
1559 if (!(sam->str=(SAM_STR2 *)talloc(ctx, num_entries*sizeof(SAM_STR2))))
1560 return NT_STATUS_NO_MEMORY;
1562 ZERO_STRUCTP(sam->sam);
1563 ZERO_STRUCTP(sam->str);
1565 for (i = 0; i < num_entries; i++) {
1566 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1567 pwd=disp_user_info[i+start_idx].sam;
1569 len_sam_name = strlen(pdb_get_username(pwd));
1570 len_sam_desc = strlen(pdb_get_acct_desc(pwd));
1572 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1573 len_sam_name, len_sam_desc,
1574 pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd));
1576 ZERO_STRUCTP(&sam->str[i].uni_srv_name);
1577 ZERO_STRUCTP(&sam->str[i].uni_srv_desc);
1579 init_unistr2(&sam->str[i].uni_srv_name, pdb_get_username(pwd), len_sam_name);
1580 init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1583 return NT_STATUS_OK;
1586 /*******************************************************************
1587 reads or writes a structure.
1588 ********************************************************************/
1590 static BOOL sam_io_sam_dispinfo_2(char *desc, SAM_DISPINFO_2 * sam,
1592 prs_struct *ps, int depth)
1599 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1605 if (UNMARSHALLING(ps) && num_entries > 0) {
1607 if ((sam->sam = (SAM_ENTRY2 *)
1608 prs_alloc_mem(ps, sizeof(SAM_ENTRY2) *
1609 num_entries)) == NULL) {
1610 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1614 if ((sam->str = (SAM_STR2 *)
1615 prs_alloc_mem(ps, sizeof(SAM_STR2) *
1616 num_entries)) == NULL) {
1617 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1622 for (i = 0; i < num_entries; i++) {
1623 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1627 for (i = 0; i < num_entries; i++) {
1628 if(!sam_io_sam_str2("", &sam->str[i],
1629 sam->sam[i].hdr_srv_name.buffer,
1630 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1637 /*******************************************************************
1638 inits a SAM_DISPINFO_3 structure.
1639 ********************************************************************/
1641 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1642 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1644 uint32 len_sam_name, len_sam_desc;
1649 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1652 return NT_STATUS_OK;
1654 if (!(sam->sam=(SAM_ENTRY3 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY3))))
1655 return NT_STATUS_NO_MEMORY;
1657 if (!(sam->str=(SAM_STR3 *)talloc(ctx, num_entries*sizeof(SAM_STR3))))
1658 return NT_STATUS_NO_MEMORY;
1660 ZERO_STRUCTP(sam->sam);
1661 ZERO_STRUCTP(sam->str);
1663 for (i = 0; i < num_entries; i++) {
1664 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1666 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1668 len_sam_name = strlen(grp->name);
1669 len_sam_desc = strlen(grp->comment);
1671 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp->rid);
1673 init_unistr2(&sam->str[i].uni_grp_name, grp->name, len_sam_name);
1674 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, len_sam_desc);
1677 return NT_STATUS_OK;
1680 /*******************************************************************
1681 reads or writes a structure.
1682 ********************************************************************/
1684 static BOOL sam_io_sam_dispinfo_3(char *desc, SAM_DISPINFO_3 * sam,
1686 prs_struct *ps, int depth)
1693 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1699 if (UNMARSHALLING(ps) && num_entries > 0) {
1701 if ((sam->sam = (SAM_ENTRY3 *)
1702 prs_alloc_mem(ps, sizeof(SAM_ENTRY3) *
1703 num_entries)) == NULL) {
1704 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1708 if ((sam->str = (SAM_STR3 *)
1709 prs_alloc_mem(ps, sizeof(SAM_STR3) *
1710 num_entries)) == NULL) {
1711 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1716 for (i = 0; i < num_entries; i++) {
1717 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1721 for (i = 0; i < num_entries; i++) {
1722 if(!sam_io_sam_str3("", &sam->str[i],
1723 sam->sam[i].hdr_grp_name.buffer,
1724 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1731 /*******************************************************************
1732 inits a SAM_DISPINFO_4 structure.
1733 ********************************************************************/
1735 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1736 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1738 uint32 len_sam_name;
1741 SAM_ACCOUNT *pwd = NULL;
1744 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1747 return NT_STATUS_OK;
1749 if (!(sam->sam=(SAM_ENTRY4 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY4))))
1750 return NT_STATUS_NO_MEMORY;
1752 if (!(sam->str=(SAM_STR4 *)talloc(ctx, num_entries*sizeof(SAM_STR4))))
1753 return NT_STATUS_NO_MEMORY;
1755 ZERO_STRUCTP(sam->sam);
1756 ZERO_STRUCTP(sam->str);
1758 for (i = 0; i < num_entries; i++) {
1759 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1760 pwd=disp_user_info[i+start_idx].sam;
1762 len_sam_name = strlen(pdb_get_username(pwd));
1764 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1766 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1769 return NT_STATUS_OK;
1772 /*******************************************************************
1773 reads or writes a structure.
1774 ********************************************************************/
1776 static BOOL sam_io_sam_dispinfo_4(char *desc, SAM_DISPINFO_4 * sam,
1778 prs_struct *ps, int depth)
1785 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1791 if (UNMARSHALLING(ps) && num_entries > 0) {
1793 if ((sam->sam = (SAM_ENTRY4 *)
1794 prs_alloc_mem(ps, sizeof(SAM_ENTRY4) *
1795 num_entries)) == NULL) {
1796 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1800 if ((sam->str = (SAM_STR4 *)
1801 prs_alloc_mem(ps, sizeof(SAM_STR4) *
1802 num_entries)) == NULL) {
1803 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1808 for (i = 0; i < num_entries; i++) {
1809 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1813 for (i = 0; i < num_entries; i++) {
1814 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1815 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1822 /*******************************************************************
1823 inits a SAM_DISPINFO_5 structure.
1824 ********************************************************************/
1826 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1827 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1829 uint32 len_sam_name;
1834 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1837 return NT_STATUS_OK;
1839 if (!(sam->sam=(SAM_ENTRY5 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY5))))
1840 return NT_STATUS_NO_MEMORY;
1842 if (!(sam->str=(SAM_STR5 *)talloc(ctx, num_entries*sizeof(SAM_STR5))))
1843 return NT_STATUS_NO_MEMORY;
1845 ZERO_STRUCTP(sam->sam);
1846 ZERO_STRUCTP(sam->str);
1848 for (i = 0; i < num_entries; i++) {
1849 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1851 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1853 len_sam_name = strlen(grp->name);
1855 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1856 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1859 return NT_STATUS_OK;
1862 /*******************************************************************
1863 reads or writes a structure.
1864 ********************************************************************/
1866 static BOOL sam_io_sam_dispinfo_5(char *desc, SAM_DISPINFO_5 * sam,
1868 prs_struct *ps, int depth)
1875 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1881 if (UNMARSHALLING(ps) && num_entries > 0) {
1883 if ((sam->sam = (SAM_ENTRY5 *)
1884 prs_alloc_mem(ps, sizeof(SAM_ENTRY5) *
1885 num_entries)) == NULL) {
1886 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1890 if ((sam->str = (SAM_STR5 *)
1891 prs_alloc_mem(ps, sizeof(SAM_STR5) *
1892 num_entries)) == NULL) {
1893 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1898 for (i = 0; i < num_entries; i++) {
1899 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1903 for (i = 0; i < num_entries; i++) {
1904 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1905 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1912 /*******************************************************************
1913 inits a SAMR_R_QUERY_DISPINFO structure.
1914 ********************************************************************/
1916 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1917 uint32 num_entries, uint32 total_size, uint32 data_size,
1918 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1921 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1923 r_u->total_size = total_size;
1925 r_u->data_size = data_size;
1927 r_u->switch_level = switch_level;
1928 r_u->num_entries = num_entries;
1931 r_u->ptr_entries = 0;
1933 r_u->ptr_entries = 1;
1935 r_u->num_entries2 = num_entries;
1938 r_u->status = status;
1941 /*******************************************************************
1942 reads or writes a structure.
1943 ********************************************************************/
1945 BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1946 prs_struct *ps, int depth)
1951 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
1957 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
1959 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
1961 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
1966 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
1968 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
1971 if (r_u->ptr_entries==0) {
1974 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1980 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1983 switch (r_u->switch_level) {
1985 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
1986 r_u->num_entries, ps, depth))
1990 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
1991 r_u->num_entries, ps, depth))
1995 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
1996 r_u->num_entries, ps, depth))
2000 if(!sam_io_sam_dispinfo_4("user list",
2001 r_u->ctr->sam.info4,
2002 r_u->num_entries, ps, depth))
2006 if(!sam_io_sam_dispinfo_5("group list",
2007 r_u->ctr->sam.info5,
2008 r_u->num_entries, ps, depth))
2012 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2018 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2024 /*******************************************************************
2025 inits a SAMR_Q_OPEN_GROUP structure.
2026 ********************************************************************/
2028 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2030 uint32 access_mask, uint32 rid)
2032 DEBUG(5, ("init_samr_q_open_group\n"));
2034 q_c->domain_pol = *hnd;
2035 q_c->access_mask = access_mask;
2036 q_c->rid_group = rid;
2039 /*******************************************************************
2040 reads or writes a structure.
2041 ********************************************************************/
2043 BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
2044 prs_struct *ps, int depth)
2049 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2055 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2058 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2060 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2066 /*******************************************************************
2067 reads or writes a structure.
2068 ********************************************************************/
2070 BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
2071 prs_struct *ps, int depth)
2076 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2082 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2085 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2091 /*******************************************************************
2092 inits a GROUP_INFO1 structure.
2093 ********************************************************************/
2095 void init_samr_group_info1(GROUP_INFO1 * gr1,
2096 char *acct_name, char *acct_desc,
2099 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2100 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
2102 DEBUG(5, ("init_samr_group_info1\n"));
2104 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
2106 gr1->unknown_1 = 0x3;
2107 gr1->num_members = num_members;
2109 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
2111 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
2112 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
2115 /*******************************************************************
2116 reads or writes a structure.
2117 ********************************************************************/
2119 BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
2120 prs_struct *ps, int depth)
2125 prs_debug(ps, depth, desc, "samr_io_group_info1");
2131 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2134 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2136 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2139 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2142 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2143 gr1->hdr_acct_name.buffer, ps, depth))
2146 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2147 gr1->hdr_acct_desc.buffer, ps, depth))
2153 /*******************************************************************
2154 inits a GROUP_INFO3 structure.
2155 ********************************************************************/
2157 void init_samr_group_info3(GROUP_INFO3 *gr3)
2159 DEBUG(5, ("init_samr_group_info3\n"));
2161 gr3->unknown_1 = 0x3;
2164 /*******************************************************************
2165 reads or writes a structure.
2166 ********************************************************************/
2168 BOOL samr_io_group_info3(char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2173 prs_debug(ps, depth, desc, "samr_io_group_info3");
2179 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2185 /*******************************************************************
2186 inits a GROUP_INFO4 structure.
2187 ********************************************************************/
2189 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2191 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2193 DEBUG(5, ("init_samr_group_info4\n"));
2195 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2196 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2199 /*******************************************************************
2200 reads or writes a structure.
2201 ********************************************************************/
2203 BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
2204 prs_struct *ps, int depth)
2209 prs_debug(ps, depth, desc, "samr_io_group_info4");
2215 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2217 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2218 gr4->hdr_acct_desc.buffer, ps, depth))
2224 /*******************************************************************
2225 reads or writes a structure.
2226 ********************************************************************/
2228 static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR **ctr,
2229 prs_struct *ps, int depth)
2231 if (UNMARSHALLING(ps))
2232 *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
2237 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2240 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2243 switch ((*ctr)->switch_value1) {
2245 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2249 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2253 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2257 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2264 /*******************************************************************
2265 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2266 ********************************************************************/
2268 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2269 POLICY_HND *pol, char *acct_desc,
2272 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2274 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2278 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2279 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2281 q_e->access_mask = access_mask;
2284 /*******************************************************************
2285 reads or writes a structure.
2286 ********************************************************************/
2288 BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2289 prs_struct *ps, int depth)
2294 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2300 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2303 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2305 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2306 q_e->hdr_acct_desc.buffer, ps, depth))
2311 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2317 /*******************************************************************
2318 reads or writes a structure.
2319 ********************************************************************/
2321 BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2322 prs_struct *ps, int depth)
2327 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2333 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2336 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2338 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2344 /*******************************************************************
2345 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2346 ********************************************************************/
2348 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2351 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2353 q_c->group_pol = *hnd;
2356 /*******************************************************************
2357 reads or writes a structure.
2358 ********************************************************************/
2360 BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2361 prs_struct *ps, int depth)
2366 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2372 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2378 /*******************************************************************
2379 reads or writes a structure.
2380 ********************************************************************/
2382 BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2383 prs_struct *ps, int depth)
2388 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2394 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2397 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2403 /*******************************************************************
2404 inits a SAMR_Q_DEL_GROUPMEM structure.
2405 ********************************************************************/
2407 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2408 POLICY_HND *pol, uint32 rid)
2410 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2416 /*******************************************************************
2417 reads or writes a structure.
2418 ********************************************************************/
2420 BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2421 prs_struct *ps, int depth)
2426 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2432 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2435 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2441 /*******************************************************************
2442 inits a SAMR_R_DEL_GROUPMEM structure.
2443 ********************************************************************/
2445 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2448 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2450 r_u->status = status;
2453 /*******************************************************************
2454 reads or writes a structure.
2455 ********************************************************************/
2457 BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2458 prs_struct *ps, int depth)
2463 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2469 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2475 /*******************************************************************
2476 inits a SAMR_Q_ADD_GROUPMEM structure.
2477 ********************************************************************/
2479 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2480 POLICY_HND *pol, uint32 rid)
2482 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2486 q_e->unknown = 0x0005;
2489 /*******************************************************************
2490 reads or writes a structure.
2491 ********************************************************************/
2493 BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2494 prs_struct *ps, int depth)
2499 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2505 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2508 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2510 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2516 /*******************************************************************
2517 inits a SAMR_R_ADD_GROUPMEM structure.
2518 ********************************************************************/
2520 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2523 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2525 r_u->status = status;
2528 /*******************************************************************
2529 reads or writes a structure.
2530 ********************************************************************/
2532 BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2533 prs_struct *ps, int depth)
2538 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2544 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2550 /*******************************************************************
2551 inits a SAMR_Q_SET_GROUPINFO structure.
2552 ********************************************************************/
2554 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2555 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2557 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2563 /*******************************************************************
2564 reads or writes a structure.
2565 ********************************************************************/
2567 BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2568 prs_struct *ps, int depth)
2573 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2579 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2582 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2588 /*******************************************************************
2589 inits a SAMR_R_SET_GROUPINFO structure.
2590 ********************************************************************/
2592 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2594 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2596 r_u->status = status;
2599 /*******************************************************************
2600 reads or writes a structure.
2601 ********************************************************************/
2603 BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
2604 prs_struct *ps, int depth)
2609 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2615 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2621 /*******************************************************************
2622 inits a SAMR_Q_QUERY_GROUPINFO structure.
2623 ********************************************************************/
2625 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2626 POLICY_HND *pol, uint16 switch_level)
2628 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2632 q_e->switch_level = switch_level;
2635 /*******************************************************************
2636 reads or writes a structure.
2637 ********************************************************************/
2639 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2640 prs_struct *ps, int depth)
2645 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2651 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2654 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2660 /*******************************************************************
2661 inits a SAMR_R_QUERY_GROUPINFO structure.
2662 ********************************************************************/
2664 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2665 GROUP_INFO_CTR * ctr, NTSTATUS status)
2667 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2669 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2671 r_u->status = status;
2674 /*******************************************************************
2675 reads or writes a structure.
2676 ********************************************************************/
2678 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2679 prs_struct *ps, int depth)
2684 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2690 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2693 if (r_u->ptr != 0) {
2694 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2700 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2706 /*******************************************************************
2707 inits a SAMR_Q_QUERY_GROUPMEM structure.
2708 ********************************************************************/
2710 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2712 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2714 q_c->group_pol = *hnd;
2717 /*******************************************************************
2718 reads or writes a structure.
2719 ********************************************************************/
2721 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2722 prs_struct *ps, int depth)
2727 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2733 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2739 /*******************************************************************
2740 inits a SAMR_R_QUERY_GROUPMEM structure.
2741 ********************************************************************/
2743 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2744 uint32 num_entries, uint32 *rid,
2745 uint32 *attr, NTSTATUS status)
2747 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2749 if (NT_STATUS_IS_OK(status)) {
2751 r_u->num_entries = num_entries;
2753 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2754 r_u->ptr_rids = rid != NULL ? 1 : 0;
2756 r_u->num_rids = num_entries;
2759 r_u->num_attrs = num_entries;
2763 r_u->num_entries = 0;
2766 r_u->status = status;
2769 /*******************************************************************
2770 reads or writes a structure.
2771 ********************************************************************/
2773 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2774 prs_struct *ps, int depth)
2781 if (UNMARSHALLING(ps))
2784 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2790 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2792 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2795 if (r_u->ptr != 0) {
2796 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2798 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2801 if (r_u->ptr_rids != 0) {
2802 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2804 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2805 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2806 if (r_u->rid == NULL)
2810 for (i = 0; i < r_u->num_rids; i++) {
2811 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2816 if (r_u->ptr_attrs != 0) {
2817 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2820 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2821 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2822 if (r_u->attr == NULL)
2826 for (i = 0; i < r_u->num_attrs; i++) {
2827 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2833 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2839 /*******************************************************************
2840 inits a SAMR_Q_QUERY_USERGROUPS structure.
2841 ********************************************************************/
2843 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2846 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2851 /*******************************************************************
2852 reads or writes a structure.
2853 ********************************************************************/
2855 BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2856 prs_struct *ps, int depth)
2861 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2867 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2873 /*******************************************************************
2874 inits a SAMR_R_QUERY_USERGROUPS structure.
2875 ********************************************************************/
2877 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2878 uint32 num_gids, DOM_GID * gid,
2881 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2883 if (NT_STATUS_IS_OK(status)) {
2885 r_u->num_entries = num_gids;
2886 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2887 r_u->num_entries2 = num_gids;
2892 r_u->num_entries = 0;
2897 r_u->status = status;
2900 /*******************************************************************
2901 reads or writes a structure.
2902 ********************************************************************/
2904 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
2905 prs_struct *ps, int depth)
2911 prs_debug(ps, depth, desc, "samr_io_gids");
2917 if(!prs_uint32("num_gids", ps, depth, num_gids))
2920 if ((*num_gids) != 0) {
2921 if (UNMARSHALLING(ps)) {
2922 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
2925 if ((*gid) == NULL) {
2929 for (i = 0; i < (*num_gids); i++) {
2930 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
2938 /*******************************************************************
2939 reads or writes a structure.
2940 ********************************************************************/
2942 BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
2943 prs_struct *ps, int depth)
2948 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
2954 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
2957 if (r_u->ptr_0 != 0) {
2958 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2960 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
2963 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
2964 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
2971 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2977 /*******************************************************************
2978 inits a SAMR_Q_ENUM_DOMAINS structure.
2979 ********************************************************************/
2981 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
2983 uint32 start_idx, uint32 size)
2985 DEBUG(5, ("init_samr_q_enum_domains\n"));
2989 q_e->start_idx = start_idx;
2990 q_e->max_size = size;
2993 /*******************************************************************
2994 reads or writes a structure.
2995 ********************************************************************/
2997 BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
2998 prs_struct *ps, int depth)
3003 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3009 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3012 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3014 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3020 /*******************************************************************
3021 inits a SAMR_R_ENUM_DOMAINS structure.
3022 ********************************************************************/
3024 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3025 uint32 next_idx, uint32 num_sam_entries)
3027 DEBUG(5, ("init_samr_r_enum_domains\n"));
3029 r_u->next_idx = next_idx;
3031 if (num_sam_entries != 0) {
3032 r_u->ptr_entries1 = 1;
3033 r_u->ptr_entries2 = 1;
3034 r_u->num_entries2 = num_sam_entries;
3035 r_u->num_entries3 = num_sam_entries;
3037 r_u->num_entries4 = num_sam_entries;
3039 r_u->ptr_entries1 = 0;
3040 r_u->num_entries2 = num_sam_entries;
3041 r_u->ptr_entries2 = 1;
3045 /*******************************************************************
3046 reads or writes a structure.
3047 ********************************************************************/
3049 BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3050 prs_struct *ps, int depth)
3057 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3063 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3065 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3068 if (r_u->ptr_entries1 != 0) {
3069 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3071 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3073 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3076 if (UNMARSHALLING(ps)) {
3077 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3078 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3081 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3082 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3083 r_u->num_entries4 = 0;
3084 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3088 for (i = 0; i < r_u->num_entries2; i++) {
3090 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3091 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3095 for (i = 0; i < r_u->num_entries2; i++) {
3097 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3098 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3099 r_u->sam[i].hdr_name.buffer, ps,
3108 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3110 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3116 /*******************************************************************
3117 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3118 ********************************************************************/
3120 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3122 uint32 start_idx, uint32 size)
3124 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3128 q_e->start_idx = start_idx;
3129 q_e->max_size = size;
3132 /*******************************************************************
3133 reads or writes a structure.
3134 ********************************************************************/
3136 BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3137 prs_struct *ps, int depth)
3142 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3148 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3151 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3153 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3159 /*******************************************************************
3160 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3161 ********************************************************************/
3163 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3164 uint32 next_idx, uint32 num_sam_entries)
3166 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3168 r_u->next_idx = next_idx;
3170 if (num_sam_entries != 0) {
3171 r_u->ptr_entries1 = 1;
3172 r_u->ptr_entries2 = 1;
3173 r_u->num_entries2 = num_sam_entries;
3174 r_u->num_entries3 = num_sam_entries;
3176 r_u->num_entries4 = num_sam_entries;
3178 r_u->ptr_entries1 = 0;
3179 r_u->num_entries2 = num_sam_entries;
3180 r_u->ptr_entries2 = 1;
3184 /*******************************************************************
3185 reads or writes a structure.
3186 ********************************************************************/
3188 BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3189 prs_struct *ps, int depth)
3196 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3202 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3204 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3207 if (r_u->ptr_entries1 != 0) {
3208 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3210 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3212 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3215 if (UNMARSHALLING(ps)) {
3216 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3217 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3220 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3222 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3223 r_u->num_entries4 = 0;
3224 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3228 for (i = 0; i < r_u->num_entries2; i++) {
3229 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3233 for (i = 0; i < r_u->num_entries2; i++) {
3234 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3235 r_u->sam[i].hdr_name.buffer, ps, depth))
3242 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3244 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3250 /*******************************************************************
3251 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3252 ********************************************************************/
3254 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3255 POLICY_HND *pol, uint32 start_idx,
3258 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3262 q_e->start_idx = start_idx;
3263 q_e->max_size = size;
3267 /*******************************************************************
3268 reads or writes a structure.
3269 ********************************************************************/
3271 BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3272 prs_struct *ps, int depth)
3277 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3283 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3286 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3288 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3294 /*******************************************************************
3295 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3296 ********************************************************************/
3298 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3300 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3302 r_u->next_idx = next_idx;
3304 if (num_sam_entries != 0) {
3305 r_u->ptr_entries1 = 1;
3306 r_u->ptr_entries2 = 1;
3307 r_u->num_entries2 = num_sam_entries;
3308 r_u->num_entries3 = num_sam_entries;
3310 r_u->num_entries4 = num_sam_entries;
3312 r_u->ptr_entries1 = 0;
3313 r_u->num_entries2 = num_sam_entries;
3314 r_u->ptr_entries2 = 1;
3318 /*******************************************************************
3319 reads or writes a structure.
3320 ********************************************************************/
3322 BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3323 prs_struct *ps, int depth)
3330 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3336 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3338 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3341 if (r_u->ptr_entries1 != 0) {
3342 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3344 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3346 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3349 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3350 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3351 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3354 if (r_u->num_entries2 != 0 &&
3355 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3356 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3357 r_u->num_entries4 = 0;
3358 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3362 for (i = 0; i < r_u->num_entries2; i++) {
3363 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3367 for (i = 0; i < r_u->num_entries2; i++) {
3368 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3369 r_u->sam[i].hdr_name.buffer, ps,
3377 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3379 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3385 /*******************************************************************
3386 inits a ALIAS_INFO1 structure.
3387 ********************************************************************/
3389 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3391 int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0;
3392 int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0;
3394 DEBUG(5, ("init_samr_alias_info1\n"));
3396 init_uni_hdr(&al1->hdr_acct_name, acct_len_name);
3397 init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name);
3399 al1->num_member=num_member;
3401 init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc);
3402 init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc);
3405 /*******************************************************************
3406 reads or writes a structure.
3407 ********************************************************************/
3409 BOOL samr_io_alias_info1(char *desc, ALIAS_INFO1 * al1,
3410 prs_struct *ps, int depth)
3415 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3421 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3423 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3425 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3428 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3429 al1->hdr_acct_name.buffer, ps, depth))
3435 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3436 al1->hdr_acct_desc.buffer, ps, depth))
3442 /*******************************************************************
3443 inits a ALIAS_INFO3 structure.
3444 ********************************************************************/
3446 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3448 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3450 DEBUG(5, ("init_samr_alias_info3\n"));
3452 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3453 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3456 /*******************************************************************
3457 reads or writes a structure.
3458 ********************************************************************/
3460 BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
3461 prs_struct *ps, int depth)
3466 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3472 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3474 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3475 al3->hdr_acct_desc.buffer, ps, depth))
3481 /*******************************************************************
3482 reads or writes a structure.
3483 ********************************************************************/
3485 BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
3486 prs_struct *ps, int depth)
3491 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3494 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3496 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3499 switch (ctr->switch_value1) {
3501 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3505 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3509 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3516 /*******************************************************************
3517 inits a SAMR_Q_QUERY_ALIASINFO structure.
3518 ********************************************************************/
3520 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3521 POLICY_HND *pol, uint16 switch_level)
3523 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3526 q_e->switch_level = switch_level;
3529 /*******************************************************************
3530 reads or writes a structure.
3531 ********************************************************************/
3533 BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3534 prs_struct *ps, int depth)
3539 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3545 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3548 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3554 /*******************************************************************
3555 inits a SAMR_R_QUERY_ALIASINFO structure.
3556 ********************************************************************/
3558 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3559 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3561 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3563 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3565 r_u->status = status;
3568 /*******************************************************************
3569 reads or writes a structure.
3570 ********************************************************************/
3572 BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3573 prs_struct *ps, int depth)
3578 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3584 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3587 if (r_u->ptr != 0) {
3588 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3594 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3600 /*******************************************************************
3601 inits a SAMR_Q_SET_ALIASINFO structure.
3602 ********************************************************************/
3604 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3605 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3607 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3609 q_u->alias_pol = *hnd;
3613 /*******************************************************************
3614 reads or writes a structure.
3615 ********************************************************************/
3617 BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3618 prs_struct *ps, int depth)
3623 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3629 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3631 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3637 /*******************************************************************
3638 reads or writes a structure.
3639 ********************************************************************/
3641 BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
3642 prs_struct *ps, int depth)
3647 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3652 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3658 /*******************************************************************
3659 inits a SAMR_Q_QUERY_USERALIASES structure.
3660 ********************************************************************/
3662 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3665 uint32 *ptr_sid, DOM_SID2 * sid)
3667 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3671 q_u->num_sids1 = num_sids;
3673 q_u->num_sids2 = num_sids;
3675 q_u->ptr_sid = ptr_sid;
3679 /*******************************************************************
3680 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3681 ********************************************************************/
3683 BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3684 prs_struct *ps, int depth)
3692 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3698 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3701 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3703 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3709 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3712 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3713 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3714 if (q_u->ptr_sid == NULL)
3717 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3718 if (q_u->sid == NULL)
3722 for (i = 0; i < q_u->num_sids2; i++) {
3723 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3724 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3728 for (i = 0; i < q_u->num_sids2; i++) {
3729 if (q_u->ptr_sid[i] != 0) {
3730 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3731 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3739 /*******************************************************************
3740 inits a SAMR_R_QUERY_USERALIASES structure.
3741 ********************************************************************/
3743 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3744 uint32 num_rids, uint32 *rid,
3747 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3749 if (NT_STATUS_IS_OK(status)) {
3750 r_u->num_entries = num_rids;
3752 r_u->num_entries2 = num_rids;
3756 r_u->num_entries = 0;
3758 r_u->num_entries2 = 0;
3761 r_u->status = status;
3764 /*******************************************************************
3765 reads or writes a structure.
3766 ********************************************************************/
3768 BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
3769 prs_struct *ps, int depth)
3776 prs_debug(ps, depth, desc, "samr_io_rids");
3782 if(!prs_uint32("num_rids", ps, depth, num_rids))
3785 if ((*num_rids) != 0) {
3786 if (UNMARSHALLING(ps)) {
3788 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3793 for (i = 0; i < (*num_rids); i++) {
3794 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3795 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3803 /*******************************************************************
3804 reads or writes a structure.
3805 ********************************************************************/
3807 BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3808 prs_struct *ps, int depth)
3813 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3819 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3821 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3824 if (r_u->ptr != 0) {
3825 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3831 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3837 /*******************************************************************
3838 inits a SAMR_Q_OPEN_ALIAS structure.
3839 ********************************************************************/
3841 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3842 uint32 access_mask, uint32 rid)
3844 DEBUG(5, ("init_samr_q_open_alias\n"));
3846 q_u->dom_pol = *pol;
3847 q_u->access_mask = access_mask;
3848 q_u->rid_alias = rid;
3851 /*******************************************************************
3852 reads or writes a structure.
3853 ********************************************************************/
3855 BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3856 prs_struct *ps, int depth)
3861 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3867 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3870 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3872 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3878 /*******************************************************************
3879 reads or writes a structure.
3880 ********************************************************************/
3882 BOOL samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS * r_u,
3883 prs_struct *ps, int depth)
3888 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3894 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3897 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3903 /*******************************************************************
3904 inits a SAMR_Q_LOOKUP_RIDS structure.
3905 ********************************************************************/
3907 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3908 POLICY_HND *pol, uint32 flags,
3909 uint32 num_rids, uint32 *rid)
3911 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3915 q_u->num_rids1 = num_rids;
3918 q_u->num_rids2 = num_rids;
3919 q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0]));
3920 if (q_u->rid == NULL) {
3924 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
3928 /*******************************************************************
3929 reads or writes a structure.
3930 ********************************************************************/
3932 BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
3933 prs_struct *ps, int depth)
3941 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
3944 if (UNMARSHALLING(ps))
3950 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3953 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
3955 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
3957 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3959 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
3962 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
3963 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
3964 if (q_u->rid == NULL)
3968 for (i = 0; i < q_u->num_rids2; i++) {
3969 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
3970 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
3977 /*******************************************************************
3978 inits a SAMR_R_LOOKUP_RIDS structure.
3979 ********************************************************************/
3981 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
3982 uint32 num_names, UNIHDR * hdr_name,
3983 UNISTR2 *uni_name, uint32 *type)
3985 DEBUG(5, ("init_samr_r_lookup_rids\n"));
3987 r_u->hdr_name = NULL;
3988 r_u->uni_name = NULL;
3991 if (num_names != 0) {
3992 r_u->num_names1 = num_names;
3994 r_u->num_names2 = num_names;
3996 r_u->num_types1 = num_names;
3998 r_u->num_types2 = num_names;
4000 r_u->hdr_name = hdr_name;
4001 r_u->uni_name = uni_name;
4004 r_u->num_names1 = num_names;
4006 r_u->num_names2 = num_names;
4008 r_u->num_types1 = num_names;
4010 r_u->num_types2 = num_names;
4014 /*******************************************************************
4015 reads or writes a structure.
4016 ********************************************************************/
4018 BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4019 prs_struct *ps, int depth)
4026 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4032 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4034 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4037 if (r_u->ptr_names != 0) {
4039 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4043 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4044 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
4045 if (r_u->hdr_name == NULL)
4048 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
4049 if (r_u->uni_name == NULL)
4053 for (i = 0; i < r_u->num_names2; i++) {
4054 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4055 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4058 for (i = 0; i < r_u->num_names2; i++) {
4059 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4060 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4068 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4070 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4073 if (r_u->ptr_types != 0) {
4075 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4078 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4079 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
4080 if (r_u->type == NULL)
4084 for (i = 0; i < r_u->num_types2; i++) {
4085 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4086 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4091 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4097 /*******************************************************************
4098 inits a SAMR_Q_OPEN_ALIAS structure.
4099 ********************************************************************/
4101 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4103 DEBUG(5, ("init_samr_q_delete_alias\n"));
4105 q_u->alias_pol = *hnd;
4108 /*******************************************************************
4109 reads or writes a structure.
4110 ********************************************************************/
4112 BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4113 prs_struct *ps, int depth)
4118 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4124 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4130 /*******************************************************************
4131 reads or writes a structure.
4132 ********************************************************************/
4134 BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4135 prs_struct *ps, int depth)
4140 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4146 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4148 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4154 /*******************************************************************
4155 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4156 ********************************************************************/
4158 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4159 POLICY_HND *hnd, char *acct_desc)
4161 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
4163 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4165 q_u->dom_pol = *hnd;
4167 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
4168 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
4170 q_u->access_mask = 0x001f000f;
4173 /*******************************************************************
4174 reads or writes a structure.
4175 ********************************************************************/
4177 BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4178 prs_struct *ps, int depth)
4183 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4189 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4192 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4194 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4195 q_u->hdr_acct_desc.buffer, ps, depth))
4200 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4206 /*******************************************************************
4207 reads or writes a structure.
4208 ********************************************************************/
4210 BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4211 prs_struct *ps, int depth)
4216 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4222 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4225 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4228 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4234 /*******************************************************************
4235 inits a SAMR_Q_ADD_ALIASMEM structure.
4236 ********************************************************************/
4238 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4241 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4243 q_u->alias_pol = *hnd;
4244 init_dom_sid2(&q_u->sid, sid);
4247 /*******************************************************************
4248 reads or writes a structure.
4249 ********************************************************************/
4251 BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4252 prs_struct *ps, int depth)
4257 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4263 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4265 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4271 /*******************************************************************
4272 reads or writes a structure.
4273 ********************************************************************/
4275 BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4276 prs_struct *ps, int depth)
4281 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4287 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4293 /*******************************************************************
4294 inits a SAMR_Q_DEL_ALIASMEM structure.
4295 ********************************************************************/
4297 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4300 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4302 q_u->alias_pol = *hnd;
4303 init_dom_sid2(&q_u->sid, sid);
4306 /*******************************************************************
4307 reads or writes a structure.
4308 ********************************************************************/
4310 BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4311 prs_struct *ps, int depth)
4316 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4322 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4324 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4330 /*******************************************************************
4331 reads or writes a structure.
4332 ********************************************************************/
4334 BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4335 prs_struct *ps, int depth)
4340 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4346 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4352 /*******************************************************************
4353 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4354 ********************************************************************/
4356 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4359 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4361 q_c->alias_pol = *hnd;
4364 /*******************************************************************
4365 reads or writes a structure.
4366 ********************************************************************/
4368 BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4369 prs_struct *ps, int depth)
4374 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4380 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4386 /*******************************************************************
4387 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4388 ********************************************************************/
4390 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4393 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4395 r_u->status = status;
4398 /*******************************************************************
4399 reads or writes a structure.
4400 ********************************************************************/
4402 BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4403 prs_struct *ps, int depth)
4408 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4414 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4420 /*******************************************************************
4421 inits a SAMR_Q_QUERY_ALIASMEM structure.
4422 ********************************************************************/
4424 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4427 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4429 q_c->alias_pol = *hnd;
4432 /*******************************************************************
4433 reads or writes a structure.
4434 ********************************************************************/
4436 BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4437 prs_struct *ps, int depth)
4442 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4448 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4454 /*******************************************************************
4455 inits a SAMR_R_QUERY_ALIASMEM structure.
4456 ********************************************************************/
4458 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4459 uint32 num_sids, DOM_SID2 * sid,
4462 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4464 if (NT_STATUS_IS_OK(status)) {
4465 r_u->num_sids = num_sids;
4466 r_u->ptr = (num_sids != 0) ? 1 : 0;
4467 r_u->num_sids1 = num_sids;
4475 r_u->status = status;
4478 /*******************************************************************
4479 reads or writes a structure.
4480 ********************************************************************/
4482 BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4483 prs_struct *ps, int depth)
4486 uint32 ptr_sid[MAX_LOOKUP_SIDS];
4491 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4497 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4499 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4502 if (r_u->ptr != 0) {
4503 SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids);
4505 if (r_u->num_sids != 0) {
4506 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4509 for (i = 0; i < r_u->num_sids1; i++) {
4511 if(!prs_uint32("", ps, depth, &ptr_sid[i]))
4515 for (i = 0; i < r_u->num_sids1; i++) {
4516 if (ptr_sid[i] != 0) {
4517 if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth))
4526 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4532 /*******************************************************************
4533 inits a SAMR_Q_LOOKUP_NAMES structure.
4534 ********************************************************************/
4536 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4537 POLICY_HND *pol, uint32 flags,
4538 uint32 num_names, char **name)
4542 DEBUG(5, ("init_samr_q_lookup_names\n"));
4546 q_u->num_names1 = num_names;
4549 q_u->num_names2 = num_names;
4551 if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR))))
4552 return NT_STATUS_NO_MEMORY;
4554 if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2))))
4555 return NT_STATUS_NO_MEMORY;
4557 for (i = 0; i < num_names; i++) {
4558 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4559 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4560 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4563 return NT_STATUS_OK;
4566 /*******************************************************************
4567 reads or writes a structure.
4568 ********************************************************************/
4570 BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4571 prs_struct *ps, int depth)
4578 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4581 if (UNMARSHALLING(ps))
4587 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4590 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4592 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4594 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4596 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4599 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4600 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4602 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4604 if (!q_u->hdr_name || !q_u->uni_name)
4608 for (i = 0; i < q_u->num_names2; i++) {
4609 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4613 for (i = 0; i < q_u->num_names2; i++) {
4614 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4621 /*******************************************************************
4622 inits a SAMR_R_LOOKUP_NAMES structure.
4623 ********************************************************************/
4625 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4627 uint32 *rid, uint32 *type,
4630 DEBUG(5, ("init_samr_r_lookup_names\n"));
4632 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4635 r_u->num_types1 = num_rids;
4637 r_u->num_types2 = num_rids;
4639 r_u->num_rids1 = num_rids;
4641 r_u->num_rids2 = num_rids;
4643 if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4644 return NT_STATUS_NO_MEMORY;
4645 if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4646 return NT_STATUS_NO_MEMORY;
4648 if (!r_u->rids || !r_u->types)
4651 for (i = 0; i < num_rids; i++) {
4652 r_u->rids[i] = rid[i];
4653 r_u->types[i] = type[i];
4658 r_u->num_types1 = 0;
4660 r_u->num_types2 = 0;
4670 r_u->status = status;
4672 return NT_STATUS_OK;
4675 /*******************************************************************
4676 reads or writes a structure.
4677 ********************************************************************/
4679 BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4680 prs_struct *ps, int depth)
4688 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4691 if (UNMARSHALLING(ps))
4697 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4699 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4702 if (r_u->ptr_rids != 0) {
4703 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4706 if (r_u->num_rids2 != r_u->num_rids1) {
4711 if (UNMARSHALLING(ps))
4712 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4715 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4719 for (i = 0; i < r_u->num_rids2; i++) {
4720 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4721 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4726 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4728 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4731 if (r_u->ptr_types != 0) {
4732 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4735 if (r_u->num_types2 != r_u->num_types1) {
4740 if (UNMARSHALLING(ps))
4741 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4744 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4748 for (i = 0; i < r_u->num_types2; i++) {
4749 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4750 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4755 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4761 /*******************************************************************
4762 inits a SAMR_Q_DELETE_DOM_USER structure.
4763 ********************************************************************/
4765 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4768 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4770 q_c->user_pol = *hnd;
4773 /*******************************************************************
4774 reads or writes a structure.
4775 ********************************************************************/
4777 BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4778 prs_struct *ps, int depth)
4783 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4789 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4795 /*******************************************************************
4796 reads or writes a structure.
4797 ********************************************************************/
4799 BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4800 prs_struct *ps, int depth)
4805 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4811 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4813 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4819 /*******************************************************************
4820 reads or writes a structure.
4821 ********************************************************************/
4823 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4825 uint32 access_mask, uint32 rid)
4827 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4829 q_u->domain_pol = *pol;
4830 q_u->access_mask = access_mask;
4831 q_u->user_rid = rid;
4834 /*******************************************************************
4835 reads or writes a structure.
4836 ********************************************************************/
4838 BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
4839 prs_struct *ps, int depth)
4844 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4850 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4853 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4855 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4861 /*******************************************************************
4862 reads or writes a structure.
4863 ********************************************************************/
4865 BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
4866 prs_struct *ps, int depth)
4871 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4877 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4880 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4887 /*******************************************************************
4888 reads or writes a structure.
4889 ********************************************************************/
4891 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4894 uint32 acb_info, uint32 access_mask)
4897 len_name = strlen(name);
4899 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4901 q_u->domain_pol = *pol;
4903 init_uni_hdr(&q_u->hdr_name, len_name);
4904 init_unistr2(&q_u->uni_name, name, len_name);
4906 q_u->acb_info = acb_info;
4907 q_u->access_mask = access_mask;
4910 /*******************************************************************
4911 reads or writes a structure.
4912 ********************************************************************/
4914 BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
4915 prs_struct *ps, int depth)
4920 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4926 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4929 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
4931 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
4936 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
4938 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4944 /*******************************************************************
4945 reads or writes a structure.
4946 ********************************************************************/
4948 BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
4949 prs_struct *ps, int depth)
4954 prs_debug(ps, depth, desc, "samr_io_r_create_user");
4960 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4963 if(!prs_uint32("unknown_0", ps, depth, &r_u->unknown_0))
4965 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
4967 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4973 /*******************************************************************
4974 inits a SAMR_Q_QUERY_USERINFO structure.
4975 ********************************************************************/
4977 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
4978 POLICY_HND *hnd, uint16 switch_value)
4980 DEBUG(5, ("init_samr_q_query_userinfo\n"));
4983 q_u->switch_value = switch_value;
4986 /*******************************************************************
4987 reads or writes a structure.
4988 ********************************************************************/
4990 BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
4991 prs_struct *ps, int depth)
4996 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5002 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5005 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5011 /*******************************************************************
5012 reads or writes a LOGON_HRS structure.
5013 ********************************************************************/
5015 static BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs,
5016 prs_struct *ps, int depth)
5021 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5027 if(!prs_uint32("len ", ps, depth, &hrs->len))
5030 if (hrs->len > sizeof(hrs->hours)) {
5031 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5032 hrs->len = sizeof(hrs->hours);
5035 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5041 /*******************************************************************
5042 inits a SAM_USER_INFO_12 structure.
5043 ********************************************************************/
5045 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5046 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5048 DEBUG(5, ("init_sam_user_info12\n"));
5050 usr->lm_pwd_active =
5051 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5052 usr->nt_pwd_active =
5053 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5056 /*******************************************************************
5057 reads or writes a structure.
5058 ********************************************************************/
5060 static BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
5061 prs_struct *ps, int depth)
5066 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5072 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5074 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5077 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5079 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5085 /*******************************************************************
5086 inits a SAM_USER_INFO_10 structure.
5087 ********************************************************************/
5089 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5091 DEBUG(5, ("init_sam_user_info10\n"));
5093 usr->acb_info = acb_info;
5096 /*******************************************************************
5097 reads or writes a structure.
5098 ********************************************************************/
5100 static BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
5101 prs_struct *ps, int depth)
5106 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5112 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5118 /*******************************************************************
5119 inits a SAM_USER_INFO_11 structure.
5120 ********************************************************************/
5122 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5125 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5129 DEBUG(5, ("init_sam_user_info11\n"));
5131 len_mach_acct = strlen(mach_acct);
5133 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
5134 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5136 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
5137 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5139 usr->ptr_1 = 1; /* pointer */
5140 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5141 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5143 usr->ptr_2 = 1; /* pointer */
5144 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5146 usr->ptr_3 = 1; /* pointer */
5147 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5149 usr->rid_user = rid_user;
5150 usr->rid_group = rid_group;
5152 usr->acct_ctrl = acct_ctrl;
5153 usr->unknown_3 = 0x0000;
5155 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5156 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5158 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5159 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5161 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
5164 /*******************************************************************
5165 reads or writes a structure.
5166 ********************************************************************/
5168 static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
5169 prs_struct *ps, int depth)
5174 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5180 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5183 if(!smb_io_time("time", &usr->expiry, ps, depth))
5186 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5189 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5192 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5195 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5197 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5200 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5203 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5205 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5208 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5210 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5213 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5215 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5217 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5219 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5221 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5223 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5226 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5229 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5232 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5238 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5244 /*************************************************************************
5247 unknown_3 = 0x09f8 27fa
5248 unknown_5 = 0x0001 0000
5249 unknown_6 = 0x0000 04ec
5251 *************************************************************************/
5253 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5255 DEBUG(10, ("init_sam_user_info24:\n"));
5256 memcpy(usr->pass, newpass, sizeof(usr->pass));
5257 usr->pw_len = pw_len;
5260 /*******************************************************************
5261 reads or writes a structure.
5262 ********************************************************************/
5264 static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
5265 prs_struct *ps, int depth)
5270 prs_debug(ps, depth, desc, "sam_io_user_info24");
5276 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5280 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5281 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5290 /*************************************************************************
5291 init_sam_user_info23
5293 unknown_3 = 0x09f8 27fa
5294 unknown_5 = 0x0001 0000
5295 unknown_6 = 0x0000 04ec
5297 *************************************************************************/
5299 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5300 NTTIME * logoff_time, /* all zeros */
5301 NTTIME * kickoff_time, /* all zeros */
5302 NTTIME * pass_last_set_time, /* all zeros */
5303 NTTIME * pass_can_change_time, /* all zeros */
5304 NTTIME * pass_must_change_time, /* all zeros */
5315 uint32 user_rid, /* 0x0000 0000 */
5322 char newpass[516], uint32 unknown_6)
5324 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5325 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5326 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5327 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5328 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5329 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5330 int len_description = desc != NULL ? desc->uni_str_len : 0;
5331 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5332 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5333 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5335 usr->logon_time = *logon_time; /* all zeros */
5336 usr->logoff_time = *logoff_time; /* all zeros */
5337 usr->kickoff_time = *kickoff_time; /* all zeros */
5338 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5339 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5340 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5342 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5343 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5344 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5345 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5346 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5347 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5348 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5349 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5350 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5351 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5353 ZERO_STRUCT(usr->nt_pwd);
5354 ZERO_STRUCT(usr->lm_pwd);
5356 usr->user_rid = user_rid; /* 0x0000 0000 */
5357 usr->group_rid = group_rid;
5358 usr->acb_info = acb_info;
5359 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5361 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5362 usr->ptr_logon_hrs = hrs ? 1 : 0;
5364 ZERO_STRUCT(usr->padding1);
5366 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5368 memcpy(usr->pass, newpass, sizeof(usr->pass));
5370 copy_unistr2(&usr->uni_user_name, user_name);
5371 copy_unistr2(&usr->uni_full_name, full_name);
5372 copy_unistr2(&usr->uni_home_dir, home_dir);
5373 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5374 copy_unistr2(&usr->uni_logon_script, log_scr);
5375 copy_unistr2(&usr->uni_profile_path, prof_path);
5376 copy_unistr2(&usr->uni_acct_desc, desc);
5377 copy_unistr2(&usr->uni_workstations, wkstas);
5378 copy_unistr2(&usr->uni_unknown_str, unk_str);
5379 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5381 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5384 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5387 /*************************************************************************
5388 init_sam_user_info23
5390 unknown_3 = 0x09f8 27fa
5391 unknown_5 = 0x0001 0000
5392 unknown_6 = 0x0000 04ec
5394 *************************************************************************/
5396 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5397 NTTIME * logoff_time, /* all zeros */
5398 NTTIME * kickoff_time, /* all zeros */
5399 NTTIME * pass_last_set_time, /* all zeros */
5400 NTTIME * pass_can_change_time, /* all zeros */
5401 NTTIME * pass_must_change_time, /* all zeros */
5402 char *user_name, /* NULL */
5404 char *home_dir, char *dir_drive, char *log_scr,
5405 char *prof_path, char *desc, char *wkstas,
5406 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5407 uint32 group_rid, uint32 acb_info,
5408 uint32 unknown_3, uint16 logon_divs,
5409 LOGON_HRS * hrs, uint32 unknown_5,
5410 char newpass[516], uint32 unknown_6)
5412 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5413 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5414 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5415 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5416 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5417 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5418 int len_description = desc != NULL ? strlen(desc) : 0;
5419 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5420 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5421 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5423 usr->logon_time = *logon_time; /* all zeros */
5424 usr->logoff_time = *logoff_time; /* all zeros */
5425 usr->kickoff_time = *kickoff_time; /* all zeros */
5426 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5427 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5428 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5430 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5431 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5432 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5433 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5434 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5435 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5436 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5437 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5438 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5439 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5441 ZERO_STRUCT(usr->nt_pwd);
5442 ZERO_STRUCT(usr->lm_pwd);
5444 usr->user_rid = user_rid; /* 0x0000 0000 */
5445 usr->group_rid = group_rid;
5446 usr->acb_info = acb_info;
5447 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5449 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5450 usr->ptr_logon_hrs = hrs ? 1 : 0;
5452 ZERO_STRUCT(usr->padding1);
5454 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5456 memcpy(usr->pass, newpass, sizeof(usr->pass));
5458 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5459 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5460 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5461 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5462 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5463 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5464 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5465 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5466 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5467 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5469 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5472 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5475 /*******************************************************************
5476 reads or writes a structure.
5477 ********************************************************************/
5479 static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
5480 prs_struct *ps, int depth)
5485 prs_debug(ps, depth, desc, "sam_io_user_info23");
5491 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5493 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5495 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5497 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5499 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5501 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5504 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5506 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5508 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5510 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5512 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5514 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5516 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5518 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5520 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5522 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5525 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5527 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5530 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5532 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5534 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5537 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5539 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5543 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5545 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5547 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5550 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5553 /* here begins pointed-to data */
5555 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5558 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5561 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5564 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5567 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5570 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5573 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5576 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5579 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5582 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5585 /* ok, this is only guess-work (as usual) */
5586 if (usr->ptr_logon_hrs) {
5587 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5589 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5591 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5593 } else if (UNMARSHALLING(ps)) {
5601 /*******************************************************************
5602 reads or writes a structure.
5603 NB. This structure is *definately* incorrect. It's my best guess
5604 currently for W2K SP2. The password field is encrypted in a different
5605 way than normal... And there are definately other problems. JRA.
5606 ********************************************************************/
5608 static BOOL sam_io_user_info25(char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5613 prs_debug(ps, depth, desc, "sam_io_user_info25");
5619 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5621 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5623 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5625 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5627 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5629 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5632 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5634 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5636 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5638 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5640 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5642 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5644 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5646 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5648 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5650 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5653 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5655 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5658 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5660 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5662 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5665 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5668 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5671 /* here begins pointed-to data */
5673 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5676 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5679 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5682 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5685 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5688 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5691 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5694 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5697 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5700 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5703 #if 0 /* JRA - unknown... */
5704 /* ok, this is only guess-work (as usual) */
5705 if (usr->ptr_logon_hrs) {
5706 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5708 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5710 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5712 } else if (UNMARSHALLING(ps)) {
5722 /*************************************************************************
5723 init_sam_user_info21W
5725 unknown_3 = 0x00ff ffff
5726 unknown_5 = 0x0002 0000
5727 unknown_6 = 0x0000 04ec
5729 *************************************************************************/
5731 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5732 NTTIME * logon_time,
5733 NTTIME * logoff_time,
5734 NTTIME * kickoff_time,
5735 NTTIME * pass_last_set_time,
5736 NTTIME * pass_can_change_time,
5737 NTTIME * pass_must_change_time,
5756 uint32 unknown_5, uint32 unknown_6)
5758 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5759 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5760 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5761 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5762 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5763 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5764 int len_description = desc != NULL ? desc->uni_str_len : 0;
5765 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5766 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5767 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5769 usr->logon_time = *logon_time;
5770 usr->logoff_time = *logoff_time;
5771 usr->kickoff_time = *kickoff_time;
5772 usr->pass_last_set_time = *pass_last_set_time;
5773 usr->pass_can_change_time = *pass_can_change_time;
5774 usr->pass_must_change_time = *pass_must_change_time;
5776 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5777 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5778 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5779 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5780 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5781 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5782 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5783 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5784 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5785 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5787 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5788 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5790 usr->user_rid = user_rid;
5791 usr->group_rid = group_rid;
5792 usr->acb_info = acb_info;
5793 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5795 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5796 usr->ptr_logon_hrs = hrs ? 1 : 0;
5797 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5799 ZERO_STRUCT(usr->padding1);
5801 copy_unistr2(&usr->uni_user_name, user_name);
5802 copy_unistr2(&usr->uni_full_name, full_name);
5803 copy_unistr2(&usr->uni_home_dir, home_dir);
5804 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5805 copy_unistr2(&usr->uni_logon_script, log_scr);
5806 copy_unistr2(&usr->uni_profile_path, prof_path);
5807 copy_unistr2(&usr->uni_acct_desc, desc);
5808 copy_unistr2(&usr->uni_workstations, wkstas);
5809 copy_unistr2(&usr->uni_unknown_str, unk_str);
5810 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5812 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5815 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5818 /*************************************************************************
5819 init_sam_user_info21
5821 unknown_3 = 0x00ff ffff
5822 unknown_5 = 0x0002 0000
5823 unknown_6 = 0x0000 04ec
5825 *************************************************************************/
5827 void init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw)
5829 NTTIME logon_time, logoff_time, kickoff_time,
5830 pass_last_set_time, pass_can_change_time,
5831 pass_must_change_time;
5833 int len_user_name, len_full_name, len_home_dir,
5834 len_dir_drive, len_logon_script, len_profile_path,
5835 len_description, len_workstations, len_unknown_str,
5838 const char* user_name = pdb_get_username(pw);
5839 const char* full_name = pdb_get_fullname(pw);
5840 const char* home_dir = pdb_get_homedir(pw);
5841 const char* dir_drive = pdb_get_dirdrive(pw);
5842 const char* logon_script = pdb_get_logon_script(pw);
5843 const char* profile_path = pdb_get_profile_path(pw);
5844 const char* description = pdb_get_acct_desc(pw);
5845 const char* workstations = pdb_get_workstations(pw);
5846 const char* munged_dial = pdb_get_munged_dial(pw);
5848 len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
5849 len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
5850 len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
5851 len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
5852 len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
5853 len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
5854 len_description = description != NULL ? strlen(description )+1 : 0;
5855 len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
5856 len_unknown_str = 0;
5857 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
5860 /* Create NTTIME structs */
5861 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5862 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5863 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5864 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5865 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
5866 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
5868 /* structure assignment */
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 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5877 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5878 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5879 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5880 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5881 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5882 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5883 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5884 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5885 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5887 ZERO_STRUCT(usr->nt_pwd);
5888 ZERO_STRUCT(usr->lm_pwd);
5890 usr->user_rid = pdb_get_user_rid(pw);
5891 usr->group_rid = pdb_get_group_rid(pw);
5892 usr->acb_info = pdb_get_acct_ctrl(pw);
5893 usr->unknown_3 = pdb_get_unknown3(pw);
5895 usr->logon_divs = pdb_get_logon_divs(pw);
5896 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
5897 usr->unknown_5 = pdb_get_unknown5(pw); /* 0x0002 0000 */
5899 ZERO_STRUCT(usr->padding1);
5901 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
5902 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5903 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5904 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5905 init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
5906 init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
5907 init_unistr2(&usr->uni_acct_desc, description, len_description);
5908 init_unistr2(&usr->uni_workstations, workstations, len_workstations);
5909 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
5910 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
5912 usr->unknown_6 = pdb_get_unknown6(pw);
5915 if (pdb_get_hours(pw)) {
5916 usr->logon_hrs.len = pdb_get_hours_len(pw);
5917 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
5919 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
5922 /*******************************************************************
5923 reads or writes a structure.
5924 ********************************************************************/
5926 static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
5927 prs_struct *ps, int depth)
5932 prs_debug(ps, depth, desc, "sam_io_user_info21");
5938 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5940 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5942 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
5944 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5946 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
5948 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5951 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5953 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5955 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5957 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5959 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5961 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5963 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5965 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5967 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5969 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5972 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5974 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5977 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5979 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5981 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5984 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5986 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5990 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5992 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5995 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5998 /* here begins pointed-to data */
6000 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6002 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6004 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6006 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6008 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6010 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6012 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6014 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6016 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6018 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6021 /* ok, this is only guess-work (as usual) */
6022 if (usr->ptr_logon_hrs) {
6025 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6027 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6029 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6031 } else if (UNMARSHALLING(ps)) {
6039 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6041 int len_munged_dial;
6042 const char* munged_dial = pdb_get_munged_dial(pw);
6044 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6045 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6046 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6050 /*******************************************************************
6051 reads or writes a structure.
6052 ********************************************************************/
6054 static BOOL sam_io_user_info20(char *desc, SAM_USER_INFO_20 *usr,
6055 prs_struct *ps, int depth)
6060 prs_debug(ps, depth, desc, "sam_io_user_info20");
6066 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6069 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6075 /*******************************************************************
6076 inits a SAM_USERINFO_CTR structure.
6077 ********************************************************************/
6079 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6080 uint16 switch_value,
6081 SAM_USER_INFO_21 * usr)
6083 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6085 ctr->switch_value = switch_value;
6086 ctr->info.id = NULL;
6088 switch (switch_value) {
6090 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
6091 if (ctr->info.id10 == NULL)
6092 return NT_STATUS_NO_MEMORY;
6094 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6097 /* whoops - got this wrong. i think. or don't understand what's happening. */
6101 info = (void *)&id11;
6103 expire.low = 0xffffffff;
6104 expire.high = 0x7fffffff;
6106 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
6107 init_sam_user_info11(ctr->info.id11, &expire,
6108 "BROOKFIELDS$", /* name */
6109 0x03ef, /* user rid */
6110 0x201, /* group rid */
6111 0x0080); /* acb info */
6117 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
6118 if (ctr->info.id12 == NULL)
6119 return NT_STATUS_NO_MEMORY;
6121 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6125 SAM_USER_INFO_21 *cusr;
6126 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
6127 ctr->info.id21 = cusr;
6128 if (ctr->info.id21 == NULL)
6129 return NT_STATUS_NO_MEMORY;
6130 memcpy(cusr, usr, sizeof(*usr));
6131 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6132 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6136 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6137 return NT_STATUS_INVALID_INFO_CLASS;
6140 return NT_STATUS_OK;
6143 /*******************************************************************
6144 inits a SAM_USERINFO_CTR structure.
6145 ********************************************************************/
6147 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
6148 uint16 switch_value, void *info)
6150 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6152 ctr->switch_value = switch_value;
6153 ctr->info.id = info;
6155 switch (switch_value) {
6157 SamOEMhash(ctr->info.id24->pass, sess_key, 516);
6158 dump_data(100, (char *)sess_key, 16);
6159 dump_data(100, (char *)ctr->info.id24->pass, 516);
6162 SamOEMhash(ctr->info.id23->pass, sess_key, 516);
6163 dump_data(100, (char *)sess_key, 16);
6164 dump_data(100, (char *)ctr->info.id23->pass, 516);
6167 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6171 /*******************************************************************
6172 reads or writes a structure.
6173 ********************************************************************/
6175 static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR **ppctr,
6176 prs_struct *ps, int depth)
6179 SAM_USERINFO_CTR *ctr;
6181 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6184 if (UNMARSHALLING(ps)) {
6185 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
6193 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6195 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6202 switch (ctr->switch_value) {
6204 if (UNMARSHALLING(ps))
6205 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
6206 if (ctr->info.id10 == NULL) {
6207 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6210 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6213 if (UNMARSHALLING(ps))
6214 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
6216 if (ctr->info.id11 == NULL) {
6217 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6220 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6223 if (UNMARSHALLING(ps))
6224 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
6226 if (ctr->info.id12 == NULL) {
6227 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6230 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6233 if (UNMARSHALLING(ps))
6234 ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20));
6236 if (ctr->info.id20 == NULL) {
6237 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6240 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6243 if (UNMARSHALLING(ps))
6244 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
6246 if (ctr->info.id21 == NULL) {
6247 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6250 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6253 if (UNMARSHALLING(ps))
6254 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
6256 if (ctr->info.id23 == NULL) {
6257 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6260 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6263 if (UNMARSHALLING(ps))
6264 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
6266 if (ctr->info.id24 == NULL) {
6267 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6270 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6273 if (UNMARSHALLING(ps))
6274 ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25));
6276 if (ctr->info.id25 == NULL) {
6277 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6280 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6283 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6291 /*******************************************************************
6292 inits a SAMR_R_QUERY_USERINFO structure.
6293 ********************************************************************/
6295 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6296 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6298 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6303 if (NT_STATUS_IS_OK(status)) {
6308 r_u->status = status; /* return status */
6311 /*******************************************************************
6312 reads or writes a structure.
6313 ********************************************************************/
6315 BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
6316 prs_struct *ps, int depth)
6321 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6327 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6330 if (r_u->ptr != 0) {
6331 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6337 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6343 /*******************************************************************
6344 inits a SAMR_Q_SET_USERINFO structure.
6345 ********************************************************************/
6347 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6348 POLICY_HND *hnd, unsigned char sess_key[16],
6349 uint16 switch_value, void *info)
6351 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6354 q_u->switch_value = switch_value;
6355 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6358 /*******************************************************************
6359 reads or writes a structure.
6360 ********************************************************************/
6362 BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
6363 prs_struct *ps, int depth)
6368 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6374 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6376 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6378 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6384 /*******************************************************************
6385 inits a SAMR_R_SET_USERINFO structure.
6386 ********************************************************************/
6388 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6390 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6392 r_u->status = status; /* return status */
6395 /*******************************************************************
6396 reads or writes a structure.
6397 ********************************************************************/
6399 BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
6400 prs_struct *ps, int depth)
6405 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6411 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6417 /*******************************************************************
6418 inits a SAMR_Q_SET_USERINFO2 structure.
6419 ********************************************************************/
6421 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6422 POLICY_HND *hnd, unsigned char sess_key[16],
6423 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6425 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6428 q_u->switch_value = switch_value;
6431 if (q_u->ctr != NULL)
6432 q_u->ctr->switch_value = switch_value;
6434 switch (switch_value) {
6436 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16);
6437 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16);
6438 dump_data(100, (char *)sess_key, 16);
6439 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6440 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6445 /*******************************************************************
6446 reads or writes a structure.
6447 ********************************************************************/
6449 BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6450 prs_struct *ps, int depth)
6455 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6461 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6464 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6466 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6472 /*******************************************************************
6473 inits a SAMR_R_SET_USERINFO2 structure.
6474 ********************************************************************/
6476 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6478 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6480 r_u->status = status; /* return status */
6483 /*******************************************************************
6484 reads or writes a structure.
6485 ********************************************************************/
6487 BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
6488 prs_struct *ps, int depth)
6493 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6499 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6505 /*******************************************************************
6506 inits a SAMR_Q_CONNECT structure.
6507 ********************************************************************/
6509 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6510 char *srv_name, uint32 access_mask)
6512 int len_srv_name = strlen(srv_name);
6514 DEBUG(5, ("init_samr_q_connect\n"));
6516 /* make PDC server name \\server */
6517 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6518 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6520 /* example values: 0x0000 0002 */
6521 q_u->access_mask = access_mask;
6524 /*******************************************************************
6525 reads or writes a structure.
6526 ********************************************************************/
6528 BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
6529 prs_struct *ps, int depth)
6534 prs_debug(ps, depth, desc, "samr_io_q_connect");
6540 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6542 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6547 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6553 /*******************************************************************
6554 reads or writes a structure.
6555 ********************************************************************/
6557 BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
6558 prs_struct *ps, int depth)
6563 prs_debug(ps, depth, desc, "samr_io_r_connect");
6569 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6572 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6578 /*******************************************************************
6579 inits a SAMR_Q_CONNECT_ANON structure.
6580 ********************************************************************/
6582 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6584 DEBUG(5, ("init_samr_q_connect_anon\n"));
6587 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6588 q_u->unknown_1 = 0x01;
6589 q_u->access_mask = 0x20;
6592 /*******************************************************************
6593 reads or writes a structure.
6594 ********************************************************************/
6596 BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
6597 prs_struct *ps, int depth)
6602 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6608 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6610 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6612 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6614 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6620 /*******************************************************************
6621 reads or writes a structure.
6622 ********************************************************************/
6624 BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
6625 prs_struct *ps, int depth)
6630 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6636 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6639 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6645 /*******************************************************************
6646 inits a SAMR_Q_GET_DOM_PWINFO structure.
6647 ********************************************************************/
6649 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6652 int len_srv_name = strlen(srv_name);
6654 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6657 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6658 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6661 /*******************************************************************
6662 reads or writes a structure.
6663 ********************************************************************/
6665 BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6666 prs_struct *ps, int depth)
6671 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6677 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6679 if (q_u->ptr != 0) {
6680 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6682 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6689 /*******************************************************************
6690 reads or writes a structure.
6691 ********************************************************************/
6693 BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6694 prs_struct *ps, int depth)
6699 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6705 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
6709 if(!prs_uint16("unk_1", ps, depth, &r_u->unk_1))
6713 if(!prs_uint16("unk_2", ps, depth, &r_u->unk_2))
6718 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6724 /*******************************************************************
6725 make a SAMR_ENC_PASSWD structure.
6726 ********************************************************************/
6728 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
6736 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6740 /*******************************************************************
6741 reads or writes a SAMR_ENC_PASSWD structure.
6742 ********************************************************************/
6744 BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
6745 prs_struct *ps, int depth)
6750 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6756 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
6759 if (pwd->ptr != 0) {
6760 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
6767 /*******************************************************************
6768 inits a SAMR_ENC_HASH structure.
6769 ********************************************************************/
6771 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
6779 memcpy(hsh->hash, hash, sizeof(hsh->hash));
6783 /*******************************************************************
6784 reads or writes a SAMR_ENC_HASH structure.
6785 ********************************************************************/
6787 BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
6788 prs_struct *ps, int depth)
6793 prs_debug(ps, depth, desc, "samr_io_enc_hash");
6799 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
6801 if (hsh->ptr != 0) {
6802 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
6809 /*******************************************************************
6810 inits a SAMR_R_GET_DOM_PWINFO structure.
6811 ********************************************************************/
6813 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
6814 char *dest_host, char *user_name,
6815 char nt_newpass[516],
6816 uchar nt_oldhash[16],
6817 char lm_newpass[516],
6818 uchar lm_oldhash[16])
6820 int len_dest_host = strlen(dest_host);
6821 int len_user_name = strlen(user_name);
6823 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
6826 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
6827 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
6828 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
6829 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
6831 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
6832 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
6834 q_u->unknown = 0x01;
6836 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
6837 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
6840 /*******************************************************************
6841 reads or writes a structure.
6842 ********************************************************************/
6844 BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
6845 prs_struct *ps, int depth)
6850 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
6856 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
6859 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
6861 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
6866 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
6868 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
6871 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
6873 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
6876 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
6879 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
6881 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
6887 /*******************************************************************
6888 inits a SAMR_R_CHGPASSWD_USER structure.
6889 ********************************************************************/
6891 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
6893 DEBUG(5, ("init_r_chgpasswd_user\n"));
6895 r_u->status = status;
6898 /*******************************************************************
6899 reads or writes a structure.
6900 ********************************************************************/
6902 BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
6903 prs_struct *ps, int depth)
6908 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
6914 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6920 /*******************************************************************
6921 reads or writes a structure.
6922 ********************************************************************/
6924 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
6925 POLICY_HND *domain_pol, uint16 switch_value)
6927 DEBUG(5, ("init_samr_q_unknown_2e\n"));
6929 q_u->domain_pol = *domain_pol;
6930 q_u->switch_value = switch_value;
6933 /*******************************************************************
6934 reads or writes a structure.
6935 ********************************************************************/
6937 BOOL samr_io_q_unknown_2e(char *desc, SAMR_Q_UNKNOWN_2E *q_u,
6938 prs_struct *ps, int depth)
6943 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
6949 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
6952 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6958 /*******************************************************************
6959 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
6960 ********************************************************************/
6962 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
6963 uint16 switch_value, SAM_UNK_CTR * ctr,
6966 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
6969 r_u->switch_value = 0;
6970 r_u->status = status; /* return status */
6972 if (NT_STATUS_IS_OK(status)) {
6973 r_u->switch_value = switch_value;
6979 /*******************************************************************
6980 reads or writes a structure.
6981 ********************************************************************/
6983 BOOL samr_io_r_samr_unknown_2e(char *desc, SAMR_R_UNKNOWN_2E * r_u,
6984 prs_struct *ps, int depth)
6989 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
6995 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
6998 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
6999 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7004 switch (r_u->switch_value) {
7006 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7010 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7014 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7018 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7022 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7026 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7030 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7034 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7035 r_u->switch_value));
7036 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7044 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7051 /*******************************************************************
7052 reads or writes a structure.
7053 ********************************************************************/
7055 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7056 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7058 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7060 q_u->domain_pol = *domain_pol;
7061 q_u->switch_value0 = switch_value;
7063 q_u->switch_value = switch_value;
7068 /*******************************************************************
7069 reads or writes a structure.
7070 ********************************************************************/
7072 BOOL samr_io_q_set_domain_info(char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7073 prs_struct *ps, int depth)
7078 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7084 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7087 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7090 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7096 if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL)
7099 switch (q_u->switch_value) {
7102 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7106 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7110 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7114 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7118 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7122 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7126 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7130 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7131 q_u->switch_value));
7138 /*******************************************************************
7139 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7140 ********************************************************************/
7142 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7144 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7146 r_u->status = status; /* return status */
7149 /*******************************************************************
7150 reads or writes a structure.
7151 ********************************************************************/
7153 BOOL samr_io_r_set_domain_info(char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7154 prs_struct *ps, int depth)
7159 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7165 if(!prs_ntstatus("status", ps, depth, &r_u->status))