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"
31 #define DBGC_CLASS DBGC_RPC_PARSE
33 /*******************************************************************
34 inits a SAMR_Q_CLOSE_HND structure.
35 ********************************************************************/
37 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
39 DEBUG(5, ("init_samr_q_close_hnd\n"));
44 /*******************************************************************
45 reads or writes a structure.
46 ********************************************************************/
48 BOOL samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND * q_u,
49 prs_struct *ps, int depth)
54 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
60 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
63 /*******************************************************************
64 reads or writes a structure.
65 ********************************************************************/
67 BOOL samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND * r_u,
68 prs_struct *ps, int depth)
73 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
79 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
82 if(!prs_ntstatus("status", ps, depth, &r_u->status))
88 /*******************************************************************
89 inits a SAMR_Q_LOOKUP_DOMAIN structure.
90 ********************************************************************/
92 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
93 POLICY_HND *pol, char *dom_name)
95 int len_name = strlen(dom_name);
97 DEBUG(5, ("init_samr_q_lookup_domain\n"));
99 q_u->connect_pol = *pol;
101 init_uni_hdr(&q_u->hdr_domain, len_name);
102 init_unistr2(&q_u->uni_domain, dom_name, len_name);
105 /*******************************************************************
106 reads or writes a structure.
107 ********************************************************************/
108 BOOL samr_io_q_lookup_domain(char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
109 prs_struct *ps, int depth)
114 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
120 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
123 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
126 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
132 /*******************************************************************
133 inits a SAMR_R_LOOKUP_DOMAIN structure.
134 ********************************************************************/
136 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
137 DOM_SID *dom_sid, NTSTATUS status)
139 DEBUG(5, ("init_samr_r_lookup_domain\n"));
141 r_u->status = status;
143 if (NT_STATUS_IS_OK(status)) {
145 init_dom_sid2(&r_u->dom_sid, dom_sid);
149 /*******************************************************************
150 reads or writes a structure.
151 ********************************************************************/
153 BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
154 prs_struct *ps, int depth)
159 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
165 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
168 if (r_u->ptr_sid != 0) {
169 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
175 if(!prs_ntstatus("status", ps, depth, &r_u->status))
181 /*******************************************************************
182 reads or writes a structure.
183 ********************************************************************/
185 void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
187 DEBUG(5, ("samr_init_samr_q_unknown_2d\n"));
189 q_u->dom_pol = *dom_pol;
190 init_dom_sid2(&q_u->sid, sid);
193 /*******************************************************************
194 reads or writes a structure.
195 ********************************************************************/
197 BOOL samr_io_q_unknown_2d(char *desc, SAMR_Q_UNKNOWN_2D * q_u,
198 prs_struct *ps, int depth)
203 prs_debug(ps, depth, desc, "samr_io_q_unknown_2d");
209 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
212 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
221 /*******************************************************************
222 reads or writes a structure.
223 ********************************************************************/
225 BOOL samr_io_r_unknown_2d(char *desc, SAMR_R_UNKNOWN_2D * r_u,
226 prs_struct *ps, int depth)
231 prs_debug(ps, depth, desc, "samr_io_r_unknown_2d");
237 if(!prs_ntstatus("status", ps, depth, &r_u->status))
243 /*******************************************************************
244 reads or writes a structure.
245 ********************************************************************/
247 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
248 POLICY_HND *pol, uint32 flags,
251 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
255 init_dom_sid2(&q_u->dom_sid, sid);
258 /*******************************************************************
259 reads or writes a structure.
260 ********************************************************************/
262 BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
263 prs_struct *ps, int depth)
268 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
274 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
277 if(!prs_uint32("flags", ps, depth, &q_u->flags))
280 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
286 /*******************************************************************
287 reads or writes a structure.
288 ********************************************************************/
290 BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN * r_u,
291 prs_struct *ps, int depth)
296 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
302 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
305 if(!prs_ntstatus("status", ps, depth, &r_u->status))
311 /*******************************************************************
312 reads or writes a structure.
313 ********************************************************************/
315 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
316 POLICY_HND *user_pol)
318 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
320 q_u->user_pol = *user_pol;
323 /*******************************************************************
324 reads or writes a structure.
325 ********************************************************************/
327 BOOL samr_io_q_get_usrdom_pwinfo(char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
328 prs_struct *ps, int depth)
333 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
339 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
342 /*******************************************************************
344 ********************************************************************/
346 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
348 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
350 r_u->unknown_0 = 0x0000;
354 * r_u->unknown_1 = 0x0015;
357 r_u->unknown_1 = 0x01D1;
358 r_u->unknown_1 = 0x0015;
360 r_u->unknown_2 = 0x00000000;
362 r_u->status = status;
365 /*******************************************************************
366 reads or writes a structure.
367 ********************************************************************/
369 BOOL samr_io_r_get_usrdom_pwinfo(char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
370 prs_struct *ps, int depth)
375 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
381 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
383 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
385 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
387 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
394 /*******************************************************************
395 reads or writes a structure.
396 ********************************************************************/
398 BOOL samr_io_q_set_sec_obj(char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
399 prs_struct *ps, int depth)
404 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
410 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
413 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
416 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
423 /*******************************************************************
424 reads or writes a structure.
425 ********************************************************************/
427 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
428 POLICY_HND *user_pol, uint32 sec_info)
430 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
432 q_u->user_pol = *user_pol;
433 q_u->sec_info = sec_info;
437 /*******************************************************************
438 reads or writes a structure.
439 ********************************************************************/
441 BOOL samr_io_q_query_sec_obj(char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
442 prs_struct *ps, int depth)
447 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
453 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
456 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
462 /*******************************************************************
463 reads or writes a structure.
464 ********************************************************************/
466 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
467 POLICY_HND *domain_pol, uint16 switch_value)
469 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
471 q_u->domain_pol = *domain_pol;
472 q_u->switch_value = switch_value;
475 /*******************************************************************
476 reads or writes a structure.
477 ********************************************************************/
479 BOOL samr_io_q_query_dom_info(char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
480 prs_struct *ps, int depth)
485 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
491 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
494 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
501 /*******************************************************************
503 ********************************************************************/
505 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
507 u_3->logout.low = nt_logout.low;
508 u_3->logout.high = nt_logout.high;
511 /*******************************************************************
512 reads or writes a structure.
513 ********************************************************************/
515 static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 * u_3,
516 prs_struct *ps, int depth)
521 prs_debug(ps, depth, desc, "sam_io_unk_info3");
524 if(!smb_io_time("logout", &u_3->logout, ps, depth))
530 /*******************************************************************
532 ********************************************************************/
534 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
536 u_6->unknown_0 = 0x00000000;
538 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
541 /*******************************************************************
542 reads or writes a structure.
543 ********************************************************************/
545 static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 * u_6,
546 prs_struct *ps, int depth)
551 prs_debug(ps, depth, desc, "sam_io_unk_info6");
554 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
556 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
558 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
564 /*******************************************************************
566 ********************************************************************/
568 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
570 u_7->unknown_0 = 0x0003;
573 /*******************************************************************
574 reads or writes a structure.
575 ********************************************************************/
577 static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 * u_7,
578 prs_struct *ps, int depth)
583 prs_debug(ps, depth, desc, "sam_io_unk_info7");
586 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
592 /*******************************************************************
594 ********************************************************************/
596 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
598 u_12->duration.low = nt_lock_duration.low;
599 u_12->duration.high = nt_lock_duration.high;
600 u_12->reset_count.low = nt_reset_time.low;
601 u_12->reset_count.high = nt_reset_time.high;
603 u_12->bad_attempt_lockout = lockout;
606 /*******************************************************************
607 reads or writes a structure.
608 ********************************************************************/
610 static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
611 prs_struct *ps, int depth)
616 prs_debug(ps, depth, desc, "sam_io_unk_info12");
619 if(!smb_io_time("duration", &u_12->duration, ps, depth))
621 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
623 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
629 /*******************************************************************
631 ********************************************************************/
632 void init_unk_info5(SAM_UNK_INFO_5 * u_5,char *server)
634 int len_server = strlen(server);
636 init_uni_hdr(&u_5->hdr_server, len_server);
638 init_unistr2(&u_5->uni_server, server, len_server);
641 /*******************************************************************
642 reads or writes a structure.
643 ********************************************************************/
645 static BOOL sam_io_unk_info5(char *desc, SAM_UNK_INFO_5 * u_5,
646 prs_struct *ps, int depth)
651 prs_debug(ps, depth, desc, "sam_io_unk_info5");
654 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
657 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
663 /*******************************************************************
665 ********************************************************************/
666 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
667 char *domain, char *server,
668 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
670 int len_domain = strlen(domain);
671 int len_server = strlen(server);
673 u_2->unknown_0 = 0x00000000;
674 u_2->unknown_1 = 0x80000000;
675 u_2->unknown_2 = 0x00000000;
678 init_uni_hdr(&u_2->hdr_domain, len_domain);
679 init_uni_hdr(&u_2->hdr_server, len_server);
681 u_2->seq_num = seq_num;
682 u_2->unknown_3 = 0x00000000;
684 u_2->unknown_4 = 0x00000001;
685 u_2->unknown_5 = 0x00000003;
686 u_2->unknown_6 = 0x00000001;
687 u_2->num_domain_usrs = num_users;
688 u_2->num_domain_grps = num_groups;
689 u_2->num_local_grps = num_alias;
691 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
693 init_unistr2(&u_2->uni_domain, domain, len_domain);
694 init_unistr2(&u_2->uni_server, server, len_server);
697 /*******************************************************************
698 reads or writes a structure.
699 ********************************************************************/
701 static BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 * u_2,
702 prs_struct *ps, int depth)
707 prs_debug(ps, depth, desc, "sam_io_unk_info2");
710 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
712 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
714 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
717 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
719 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
721 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
724 /* put all the data in here, at the moment, including what the above
725 pointer is referring to
728 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
730 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
733 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
735 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
737 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
739 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
741 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
743 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
746 if(!prs_uint8s(False, "padding", ps, depth, u_2->padding,sizeof(u_2->padding)))
749 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
751 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
757 /*******************************************************************
759 ********************************************************************/
761 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
762 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
764 u_1->min_length_password = min_pass_len;
765 u_1->password_history = pass_hist;
768 /* password never expire */
769 u_1->expire.high = nt_expire.high;
770 u_1->expire.low = nt_expire.low;
772 /* can change the password now */
773 u_1->min_passwordage.high = nt_min_age.high;
774 u_1->min_passwordage.low = nt_min_age.low;
778 /*******************************************************************
779 reads or writes a structure.
780 ********************************************************************/
782 static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 * u_1,
783 prs_struct *ps, int depth)
788 prs_debug(ps, depth, desc, "sam_io_unk_info1");
791 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
793 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
795 if(!prs_uint32("flag", ps, depth, &u_1->flag))
797 if(!smb_io_time("expire", &u_1->expire, ps, depth))
799 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
805 /*******************************************************************
806 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
807 ********************************************************************/
809 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
810 uint16 switch_value, SAM_UNK_CTR * ctr,
813 DEBUG(5, ("init_samr_r_query_dom_info\n"));
816 r_u->switch_value = 0;
817 r_u->status = status; /* return status */
819 if (NT_STATUS_IS_OK(status)) {
820 r_u->switch_value = switch_value;
826 /*******************************************************************
827 reads or writes a structure.
828 ********************************************************************/
830 BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
831 prs_struct *ps, int depth)
836 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
842 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
845 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
846 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
851 switch (r_u->switch_value) {
853 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
857 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
861 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
865 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
869 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
873 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
877 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
881 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
883 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
891 if(!prs_ntstatus("status", ps, depth, &r_u->status))
897 /*******************************************************************
898 reads or writes a SAMR_R_SET_SEC_OBJ structure.
899 ********************************************************************/
901 BOOL samr_io_r_set_sec_obj(char *desc, SAMR_R_SET_SEC_OBJ * r_u,
902 prs_struct *ps, int depth)
907 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
913 if(!prs_ntstatus("status", ps, depth, &r_u->status))
919 /*******************************************************************
920 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
921 ********************************************************************/
923 BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
924 prs_struct *ps, int depth)
929 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
935 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
938 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
942 if(!prs_ntstatus("status", ps, depth, &r_u->status))
948 /*******************************************************************
949 reads or writes a SAM_STR1 structure.
950 ********************************************************************/
952 static BOOL sam_io_sam_str1(char *desc, SAM_STR1 * sam, uint32 acct_buf,
953 uint32 name_buf, uint32 desc_buf,
954 prs_struct *ps, int depth)
959 prs_debug(ps, depth, desc, "sam_io_sam_str1");
964 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
967 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
970 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
976 /*******************************************************************
977 inits a SAM_ENTRY1 structure.
978 ********************************************************************/
980 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
981 uint32 len_sam_name, uint32 len_sam_full,
982 uint32 len_sam_desc, uint32 rid_user,
985 DEBUG(5, ("init_sam_entry1\n"));
989 sam->user_idx = user_idx;
990 sam->rid_user = rid_user;
991 sam->acb_info = acb_info;
993 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
994 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
995 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
998 /*******************************************************************
999 reads or writes a SAM_ENTRY1 structure.
1000 ********************************************************************/
1002 static BOOL sam_io_sam_entry1(char *desc, SAM_ENTRY1 * sam,
1003 prs_struct *ps, int depth)
1008 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1014 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1017 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1019 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1025 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1027 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1029 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1035 /*******************************************************************
1036 reads or writes a SAM_STR2 structure.
1037 ********************************************************************/
1039 static BOOL sam_io_sam_str2(char *desc, SAM_STR2 * sam, uint32 acct_buf,
1040 uint32 desc_buf, prs_struct *ps, int depth)
1045 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1051 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1053 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1059 /*******************************************************************
1060 inits a SAM_ENTRY2 structure.
1061 ********************************************************************/
1062 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1063 uint32 len_sam_name, uint32 len_sam_desc,
1064 uint32 rid_user, uint16 acb_info)
1066 DEBUG(5, ("init_sam_entry2\n"));
1068 sam->user_idx = user_idx;
1069 sam->rid_user = rid_user;
1070 sam->acb_info = acb_info;
1072 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
1073 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
1076 /*******************************************************************
1077 reads or writes a SAM_ENTRY2 structure.
1078 ********************************************************************/
1080 static BOOL sam_io_sam_entry2(char *desc, SAM_ENTRY2 * sam,
1081 prs_struct *ps, int depth)
1086 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1092 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1095 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1097 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1103 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1105 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1111 /*******************************************************************
1112 reads or writes a SAM_STR3 structure.
1113 ********************************************************************/
1115 static BOOL sam_io_sam_str3(char *desc, SAM_STR3 * sam, uint32 acct_buf,
1116 uint32 desc_buf, prs_struct *ps, int depth)
1121 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1127 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1129 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1135 /*******************************************************************
1136 inits a SAM_ENTRY3 structure.
1137 ********************************************************************/
1139 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1140 uint32 len_grp_name, uint32 len_grp_desc,
1143 DEBUG(5, ("init_sam_entry3\n"));
1145 sam->grp_idx = grp_idx;
1146 sam->rid_grp = rid_grp;
1147 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1149 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1150 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1153 /*******************************************************************
1154 reads or writes a SAM_ENTRY3 structure.
1155 ********************************************************************/
1157 static BOOL sam_io_sam_entry3(char *desc, SAM_ENTRY3 * sam,
1158 prs_struct *ps, int depth)
1163 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1169 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1172 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1174 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1177 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1179 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1185 /*******************************************************************
1186 inits a SAM_ENTRY4 structure.
1187 ********************************************************************/
1189 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1190 uint32 len_acct_name)
1192 DEBUG(5, ("init_sam_entry4\n"));
1194 sam->user_idx = user_idx;
1195 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1198 /*******************************************************************
1199 reads or writes a SAM_ENTRY4 structure.
1200 ********************************************************************/
1202 static BOOL sam_io_sam_entry4(char *desc, SAM_ENTRY4 * sam,
1203 prs_struct *ps, int depth)
1208 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1214 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1216 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1222 /*******************************************************************
1223 inits a SAM_ENTRY5 structure.
1224 ********************************************************************/
1226 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1227 uint32 len_grp_name)
1229 DEBUG(5, ("init_sam_entry5\n"));
1231 sam->grp_idx = grp_idx;
1232 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1236 /*******************************************************************
1237 reads or writes a SAM_ENTRY5 structure.
1238 ********************************************************************/
1240 static BOOL sam_io_sam_entry5(char *desc, SAM_ENTRY5 * sam,
1241 prs_struct *ps, int depth)
1246 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1252 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1254 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1260 /*******************************************************************
1261 inits a SAM_ENTRY structure.
1262 ********************************************************************/
1264 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1266 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1269 init_uni_hdr(&sam->hdr_name, len_sam_name);
1272 /*******************************************************************
1273 reads or writes a SAM_ENTRY structure.
1274 ********************************************************************/
1276 static BOOL sam_io_sam_entry(char *desc, SAM_ENTRY * sam,
1277 prs_struct *ps, int depth)
1282 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1287 if(!prs_uint32("rid", ps, depth, &sam->rid))
1289 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1295 /*******************************************************************
1296 inits a SAMR_Q_ENUM_DOM_USERS structure.
1297 ********************************************************************/
1299 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1301 uint16 acb_mask, uint16 unk_1, uint32 size)
1303 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1307 q_e->start_idx = start_idx; /* zero indicates lots */
1308 q_e->acb_mask = acb_mask;
1309 q_e->unknown_1 = unk_1;
1310 q_e->max_size = size;
1313 /*******************************************************************
1314 reads or writes a structure.
1315 ********************************************************************/
1317 BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1318 prs_struct *ps, int depth)
1323 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1329 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1332 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1334 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1336 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1339 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1346 /*******************************************************************
1347 inits a SAMR_R_ENUM_DOM_USERS structure.
1348 ********************************************************************/
1350 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1351 uint32 next_idx, uint32 num_sam_entries)
1353 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1355 r_u->next_idx = next_idx;
1357 if (num_sam_entries != 0) {
1358 r_u->ptr_entries1 = 1;
1359 r_u->ptr_entries2 = 1;
1360 r_u->num_entries2 = num_sam_entries;
1361 r_u->num_entries3 = num_sam_entries;
1363 r_u->num_entries4 = num_sam_entries;
1365 r_u->ptr_entries1 = 0;
1366 r_u->num_entries2 = num_sam_entries;
1367 r_u->ptr_entries2 = 1;
1371 /*******************************************************************
1372 reads or writes a structure.
1373 ********************************************************************/
1375 BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1376 prs_struct *ps, int depth)
1383 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1389 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1391 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1394 if (r_u->ptr_entries1 != 0) {
1395 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1397 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1399 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1402 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1403 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1404 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
1407 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1408 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1409 r_u->num_entries4 = 0;
1410 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1414 for (i = 0; i < r_u->num_entries2; i++) {
1415 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1419 for (i = 0; i < r_u->num_entries2; i++) {
1420 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1429 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1431 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1437 /*******************************************************************
1438 inits a SAMR_Q_QUERY_DISPINFO structure.
1439 ********************************************************************/
1441 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1442 uint16 switch_level, uint32 start_idx,
1445 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1447 q_e->domain_pol = *pol;
1449 q_e->switch_level = switch_level;
1451 q_e->start_idx = start_idx;
1452 q_e->max_entries = max_entries;
1453 q_e->max_size = 0xffff; /* Not especially useful */
1456 /*******************************************************************
1457 reads or writes a structure.
1458 ********************************************************************/
1460 BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1461 prs_struct *ps, int depth)
1466 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1472 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1475 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1480 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1482 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1484 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1490 /*******************************************************************
1491 inits a SAM_DISPINFO_1 structure.
1492 ********************************************************************/
1494 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1495 uint32 start_idx, DISP_USER_INFO *disp_user_info,
1496 DOM_SID *domain_sid)
1498 uint32 len_sam_name, len_sam_full, len_sam_desc;
1501 SAM_ACCOUNT *pwd = NULL;
1504 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1507 return NT_STATUS_OK;
1509 sam->sam=(SAM_ENTRY1 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY1));
1511 return NT_STATUS_NO_MEMORY;
1513 sam->str=(SAM_STR1 *)talloc(ctx, num_entries*sizeof(SAM_STR1));
1515 return NT_STATUS_NO_MEMORY;
1517 ZERO_STRUCTP(sam->sam);
1518 ZERO_STRUCTP(sam->str);
1520 for (i = 0; i < num_entries ; i++) {
1521 const char *username;
1522 const char *fullname;
1523 const char *acct_desc;
1525 const DOM_SID *user_sid;
1526 fstring user_sid_string, domain_sid_string;
1528 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1530 pwd=disp_user_info[i+start_idx].sam;
1532 username = pdb_get_username(pwd);
1533 fullname = pdb_get_fullname(pwd);
1534 acct_desc = pdb_get_acct_desc(pwd);
1545 user_sid = pdb_get_user_sid(pwd);
1547 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1548 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1549 "the domain sid %s. Failing operation.\n",
1551 sid_to_string(user_sid_string, user_sid),
1552 sid_to_string(domain_sid_string, domain_sid)));
1553 return NT_STATUS_UNSUCCESSFUL;
1556 len_sam_name = strlen(username);
1557 len_sam_full = strlen(fullname);
1558 len_sam_desc = strlen(acct_desc);
1560 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1561 len_sam_name, len_sam_full, len_sam_desc,
1562 user_rid, pdb_get_acct_ctrl(pwd));
1564 ZERO_STRUCTP(&sam->str[i].uni_acct_name);
1565 ZERO_STRUCTP(&sam->str[i].uni_full_name);
1566 ZERO_STRUCTP(&sam->str[i].uni_acct_desc);
1568 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), len_sam_name);
1569 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), len_sam_full);
1570 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1573 return NT_STATUS_OK;
1576 /*******************************************************************
1577 reads or writes a structure.
1578 ********************************************************************/
1580 static BOOL sam_io_sam_dispinfo_1(char *desc, SAM_DISPINFO_1 * sam,
1582 prs_struct *ps, int depth)
1586 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1592 if (UNMARSHALLING(ps) && num_entries > 0) {
1594 if ((sam->sam = (SAM_ENTRY1 *)
1595 prs_alloc_mem(ps, sizeof(SAM_ENTRY1) *
1596 num_entries)) == NULL) {
1597 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1601 if ((sam->str = (SAM_STR1 *)
1602 prs_alloc_mem(ps, sizeof(SAM_STR1) *
1603 num_entries)) == NULL) {
1604 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1609 for (i = 0; i < num_entries; i++) {
1610 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1614 for (i = 0; i < num_entries; i++) {
1615 if(!sam_io_sam_str1("", &sam->str[i],
1616 sam->sam[i].hdr_acct_name.buffer,
1617 sam->sam[i].hdr_user_name.buffer,
1618 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1625 /*******************************************************************
1626 inits a SAM_DISPINFO_2 structure.
1627 ********************************************************************/
1629 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1630 uint32 start_idx, DISP_USER_INFO *disp_user_info,
1631 DOM_SID *domain_sid )
1633 uint32 len_sam_name, len_sam_desc;
1636 SAM_ACCOUNT *pwd = NULL;
1639 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1642 return NT_STATUS_OK;
1644 if (!(sam->sam=(SAM_ENTRY2 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY2))))
1645 return NT_STATUS_NO_MEMORY;
1647 if (!(sam->str=(SAM_STR2 *)talloc(ctx, num_entries*sizeof(SAM_STR2))))
1648 return NT_STATUS_NO_MEMORY;
1650 ZERO_STRUCTP(sam->sam);
1651 ZERO_STRUCTP(sam->str);
1653 for (i = 0; i < num_entries; i++) {
1655 const DOM_SID *user_sid;
1656 const char *username;
1657 const char *acct_desc;
1658 fstring user_sid_string, domain_sid_string;
1660 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1661 pwd=disp_user_info[i+start_idx].sam;
1663 username = pdb_get_username(pwd);
1664 acct_desc = pdb_get_acct_desc(pwd);
1665 user_sid = pdb_get_user_sid(pwd);
1667 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1668 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1669 "the domain sid %s. Failing operation.\n",
1671 sid_to_string(user_sid_string, user_sid),
1672 sid_to_string(domain_sid_string, domain_sid)));
1673 return NT_STATUS_UNSUCCESSFUL;
1676 len_sam_name = strlen(username);
1677 len_sam_desc = strlen(acct_desc);
1679 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1680 len_sam_name, len_sam_desc,
1681 user_rid, pdb_get_acct_ctrl(pwd));
1683 ZERO_STRUCTP(&sam->str[i].uni_srv_name);
1684 ZERO_STRUCTP(&sam->str[i].uni_srv_desc);
1686 init_unistr2(&sam->str[i].uni_srv_name, username, len_sam_name);
1687 init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1690 return NT_STATUS_OK;
1693 /*******************************************************************
1694 reads or writes a structure.
1695 ********************************************************************/
1697 static BOOL sam_io_sam_dispinfo_2(char *desc, SAM_DISPINFO_2 * sam,
1699 prs_struct *ps, int depth)
1706 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1712 if (UNMARSHALLING(ps) && num_entries > 0) {
1714 if ((sam->sam = (SAM_ENTRY2 *)
1715 prs_alloc_mem(ps, sizeof(SAM_ENTRY2) *
1716 num_entries)) == NULL) {
1717 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1721 if ((sam->str = (SAM_STR2 *)
1722 prs_alloc_mem(ps, sizeof(SAM_STR2) *
1723 num_entries)) == NULL) {
1724 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1729 for (i = 0; i < num_entries; i++) {
1730 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1734 for (i = 0; i < num_entries; i++) {
1735 if(!sam_io_sam_str2("", &sam->str[i],
1736 sam->sam[i].hdr_srv_name.buffer,
1737 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1744 /*******************************************************************
1745 inits a SAM_DISPINFO_3 structure.
1746 ********************************************************************/
1748 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1749 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1751 uint32 len_sam_name, len_sam_desc;
1756 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1759 return NT_STATUS_OK;
1761 if (!(sam->sam=(SAM_ENTRY3 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY3))))
1762 return NT_STATUS_NO_MEMORY;
1764 if (!(sam->str=(SAM_STR3 *)talloc(ctx, num_entries*sizeof(SAM_STR3))))
1765 return NT_STATUS_NO_MEMORY;
1767 ZERO_STRUCTP(sam->sam);
1768 ZERO_STRUCTP(sam->str);
1770 for (i = 0; i < num_entries; i++) {
1771 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1773 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1775 len_sam_name = strlen(grp->name);
1776 len_sam_desc = strlen(grp->comment);
1778 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp->rid);
1780 init_unistr2(&sam->str[i].uni_grp_name, grp->name, len_sam_name);
1781 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, len_sam_desc);
1784 return NT_STATUS_OK;
1787 /*******************************************************************
1788 reads or writes a structure.
1789 ********************************************************************/
1791 static BOOL sam_io_sam_dispinfo_3(char *desc, SAM_DISPINFO_3 * sam,
1793 prs_struct *ps, int depth)
1800 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1806 if (UNMARSHALLING(ps) && num_entries > 0) {
1808 if ((sam->sam = (SAM_ENTRY3 *)
1809 prs_alloc_mem(ps, sizeof(SAM_ENTRY3) *
1810 num_entries)) == NULL) {
1811 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1815 if ((sam->str = (SAM_STR3 *)
1816 prs_alloc_mem(ps, sizeof(SAM_STR3) *
1817 num_entries)) == NULL) {
1818 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1823 for (i = 0; i < num_entries; i++) {
1824 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1828 for (i = 0; i < num_entries; i++) {
1829 if(!sam_io_sam_str3("", &sam->str[i],
1830 sam->sam[i].hdr_grp_name.buffer,
1831 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1838 /*******************************************************************
1839 inits a SAM_DISPINFO_4 structure.
1840 ********************************************************************/
1842 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1843 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1845 uint32 len_sam_name;
1848 SAM_ACCOUNT *pwd = NULL;
1851 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1854 return NT_STATUS_OK;
1856 if (!(sam->sam=(SAM_ENTRY4 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY4))))
1857 return NT_STATUS_NO_MEMORY;
1859 if (!(sam->str=(SAM_STR4 *)talloc(ctx, num_entries*sizeof(SAM_STR4))))
1860 return NT_STATUS_NO_MEMORY;
1862 ZERO_STRUCTP(sam->sam);
1863 ZERO_STRUCTP(sam->str);
1865 for (i = 0; i < num_entries; i++) {
1866 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1867 pwd=disp_user_info[i+start_idx].sam;
1869 len_sam_name = strlen(pdb_get_username(pwd));
1871 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1873 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1876 return NT_STATUS_OK;
1879 /*******************************************************************
1880 reads or writes a structure.
1881 ********************************************************************/
1883 static BOOL sam_io_sam_dispinfo_4(char *desc, SAM_DISPINFO_4 * sam,
1885 prs_struct *ps, int depth)
1892 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1898 if (UNMARSHALLING(ps) && num_entries > 0) {
1900 if ((sam->sam = (SAM_ENTRY4 *)
1901 prs_alloc_mem(ps, sizeof(SAM_ENTRY4) *
1902 num_entries)) == NULL) {
1903 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1907 if ((sam->str = (SAM_STR4 *)
1908 prs_alloc_mem(ps, sizeof(SAM_STR4) *
1909 num_entries)) == NULL) {
1910 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1915 for (i = 0; i < num_entries; i++) {
1916 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1920 for (i = 0; i < num_entries; i++) {
1921 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1922 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1929 /*******************************************************************
1930 inits a SAM_DISPINFO_5 structure.
1931 ********************************************************************/
1933 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1934 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1936 uint32 len_sam_name;
1941 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1944 return NT_STATUS_OK;
1946 if (!(sam->sam=(SAM_ENTRY5 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY5))))
1947 return NT_STATUS_NO_MEMORY;
1949 if (!(sam->str=(SAM_STR5 *)talloc(ctx, num_entries*sizeof(SAM_STR5))))
1950 return NT_STATUS_NO_MEMORY;
1952 ZERO_STRUCTP(sam->sam);
1953 ZERO_STRUCTP(sam->str);
1955 for (i = 0; i < num_entries; i++) {
1956 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1958 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1960 len_sam_name = strlen(grp->name);
1962 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1963 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1966 return NT_STATUS_OK;
1969 /*******************************************************************
1970 reads or writes a structure.
1971 ********************************************************************/
1973 static BOOL sam_io_sam_dispinfo_5(char *desc, SAM_DISPINFO_5 * sam,
1975 prs_struct *ps, int depth)
1982 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1988 if (UNMARSHALLING(ps) && num_entries > 0) {
1990 if ((sam->sam = (SAM_ENTRY5 *)
1991 prs_alloc_mem(ps, sizeof(SAM_ENTRY5) *
1992 num_entries)) == NULL) {
1993 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1997 if ((sam->str = (SAM_STR5 *)
1998 prs_alloc_mem(ps, sizeof(SAM_STR5) *
1999 num_entries)) == NULL) {
2000 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2005 for (i = 0; i < num_entries; i++) {
2006 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2010 for (i = 0; i < num_entries; i++) {
2011 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
2012 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2019 /*******************************************************************
2020 inits a SAMR_R_QUERY_DISPINFO structure.
2021 ********************************************************************/
2023 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2024 uint32 num_entries, uint32 total_size, uint32 data_size,
2025 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2028 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2030 r_u->total_size = total_size;
2032 r_u->data_size = data_size;
2034 r_u->switch_level = switch_level;
2035 r_u->num_entries = num_entries;
2038 r_u->ptr_entries = 0;
2040 r_u->ptr_entries = 1;
2042 r_u->num_entries2 = num_entries;
2045 r_u->status = status;
2048 /*******************************************************************
2049 reads or writes a structure.
2050 ********************************************************************/
2052 BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2053 prs_struct *ps, int depth)
2058 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2064 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2066 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2068 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2073 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2075 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2078 if (r_u->ptr_entries==0) {
2081 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2087 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2090 switch (r_u->switch_level) {
2092 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2093 r_u->num_entries, ps, depth))
2097 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2098 r_u->num_entries, ps, depth))
2102 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2103 r_u->num_entries, ps, depth))
2107 if(!sam_io_sam_dispinfo_4("user list",
2108 r_u->ctr->sam.info4,
2109 r_u->num_entries, ps, depth))
2113 if(!sam_io_sam_dispinfo_5("group list",
2114 r_u->ctr->sam.info5,
2115 r_u->num_entries, ps, depth))
2119 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2125 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2131 /*******************************************************************
2132 inits a SAMR_Q_OPEN_GROUP structure.
2133 ********************************************************************/
2135 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2137 uint32 access_mask, uint32 rid)
2139 DEBUG(5, ("init_samr_q_open_group\n"));
2141 q_c->domain_pol = *hnd;
2142 q_c->access_mask = access_mask;
2143 q_c->rid_group = rid;
2146 /*******************************************************************
2147 reads or writes a structure.
2148 ********************************************************************/
2150 BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
2151 prs_struct *ps, int depth)
2156 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2162 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2165 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2167 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2173 /*******************************************************************
2174 reads or writes a structure.
2175 ********************************************************************/
2177 BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
2178 prs_struct *ps, int depth)
2183 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2189 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2192 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2198 /*******************************************************************
2199 inits a GROUP_INFO1 structure.
2200 ********************************************************************/
2202 void init_samr_group_info1(GROUP_INFO1 * gr1,
2203 char *acct_name, char *acct_desc,
2206 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2207 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
2209 DEBUG(5, ("init_samr_group_info1\n"));
2211 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
2213 gr1->unknown_1 = 0x3;
2214 gr1->num_members = num_members;
2216 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
2218 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
2219 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
2222 /*******************************************************************
2223 reads or writes a structure.
2224 ********************************************************************/
2226 BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
2227 prs_struct *ps, int depth)
2232 prs_debug(ps, depth, desc, "samr_io_group_info1");
2238 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2241 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2243 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2246 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2249 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2250 gr1->hdr_acct_name.buffer, ps, depth))
2253 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2254 gr1->hdr_acct_desc.buffer, ps, depth))
2260 /*******************************************************************
2261 inits a GROUP_INFO3 structure.
2262 ********************************************************************/
2264 void init_samr_group_info3(GROUP_INFO3 *gr3)
2266 DEBUG(5, ("init_samr_group_info3\n"));
2268 gr3->unknown_1 = 0x3;
2271 /*******************************************************************
2272 reads or writes a structure.
2273 ********************************************************************/
2275 BOOL samr_io_group_info3(char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2280 prs_debug(ps, depth, desc, "samr_io_group_info3");
2286 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2292 /*******************************************************************
2293 inits a GROUP_INFO4 structure.
2294 ********************************************************************/
2296 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2298 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2300 DEBUG(5, ("init_samr_group_info4\n"));
2302 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2303 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2306 /*******************************************************************
2307 reads or writes a structure.
2308 ********************************************************************/
2310 BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
2311 prs_struct *ps, int depth)
2316 prs_debug(ps, depth, desc, "samr_io_group_info4");
2322 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2324 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2325 gr4->hdr_acct_desc.buffer, ps, depth))
2331 /*******************************************************************
2332 reads or writes a structure.
2333 ********************************************************************/
2335 static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR **ctr,
2336 prs_struct *ps, int depth)
2338 if (UNMARSHALLING(ps))
2339 *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
2344 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2347 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2350 switch ((*ctr)->switch_value1) {
2352 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2356 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2360 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2364 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2371 /*******************************************************************
2372 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2373 ********************************************************************/
2375 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2376 POLICY_HND *pol, char *acct_desc,
2379 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2381 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2385 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2386 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2388 q_e->access_mask = access_mask;
2391 /*******************************************************************
2392 reads or writes a structure.
2393 ********************************************************************/
2395 BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2396 prs_struct *ps, int depth)
2401 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2407 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2410 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2412 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2413 q_e->hdr_acct_desc.buffer, ps, depth))
2418 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2424 /*******************************************************************
2425 reads or writes a structure.
2426 ********************************************************************/
2428 BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2429 prs_struct *ps, int depth)
2434 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2440 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2443 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2445 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2451 /*******************************************************************
2452 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2453 ********************************************************************/
2455 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2458 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2460 q_c->group_pol = *hnd;
2463 /*******************************************************************
2464 reads or writes a structure.
2465 ********************************************************************/
2467 BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2468 prs_struct *ps, int depth)
2473 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2479 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2485 /*******************************************************************
2486 reads or writes a structure.
2487 ********************************************************************/
2489 BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2490 prs_struct *ps, int depth)
2495 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2501 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2504 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2510 /*******************************************************************
2511 inits a SAMR_Q_DEL_GROUPMEM structure.
2512 ********************************************************************/
2514 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2515 POLICY_HND *pol, uint32 rid)
2517 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2523 /*******************************************************************
2524 reads or writes a structure.
2525 ********************************************************************/
2527 BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2528 prs_struct *ps, int depth)
2533 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2539 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2542 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2548 /*******************************************************************
2549 inits a SAMR_R_DEL_GROUPMEM structure.
2550 ********************************************************************/
2552 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2555 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2557 r_u->status = status;
2560 /*******************************************************************
2561 reads or writes a structure.
2562 ********************************************************************/
2564 BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2565 prs_struct *ps, int depth)
2570 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2576 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2582 /*******************************************************************
2583 inits a SAMR_Q_ADD_GROUPMEM structure.
2584 ********************************************************************/
2586 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2587 POLICY_HND *pol, uint32 rid)
2589 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2593 q_e->unknown = 0x0005;
2596 /*******************************************************************
2597 reads or writes a structure.
2598 ********************************************************************/
2600 BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2601 prs_struct *ps, int depth)
2606 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2612 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2615 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2617 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2623 /*******************************************************************
2624 inits a SAMR_R_ADD_GROUPMEM structure.
2625 ********************************************************************/
2627 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2630 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2632 r_u->status = status;
2635 /*******************************************************************
2636 reads or writes a structure.
2637 ********************************************************************/
2639 BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2640 prs_struct *ps, int depth)
2645 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2651 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2657 /*******************************************************************
2658 inits a SAMR_Q_SET_GROUPINFO structure.
2659 ********************************************************************/
2661 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2662 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2664 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2670 /*******************************************************************
2671 reads or writes a structure.
2672 ********************************************************************/
2674 BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2675 prs_struct *ps, int depth)
2680 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2686 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2689 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2695 /*******************************************************************
2696 inits a SAMR_R_SET_GROUPINFO structure.
2697 ********************************************************************/
2699 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2701 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2703 r_u->status = status;
2706 /*******************************************************************
2707 reads or writes a structure.
2708 ********************************************************************/
2710 BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
2711 prs_struct *ps, int depth)
2716 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2722 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2728 /*******************************************************************
2729 inits a SAMR_Q_QUERY_GROUPINFO structure.
2730 ********************************************************************/
2732 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2733 POLICY_HND *pol, uint16 switch_level)
2735 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2739 q_e->switch_level = switch_level;
2742 /*******************************************************************
2743 reads or writes a structure.
2744 ********************************************************************/
2746 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2747 prs_struct *ps, int depth)
2752 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2758 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2761 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2767 /*******************************************************************
2768 inits a SAMR_R_QUERY_GROUPINFO structure.
2769 ********************************************************************/
2771 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2772 GROUP_INFO_CTR * ctr, NTSTATUS status)
2774 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2776 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2778 r_u->status = status;
2781 /*******************************************************************
2782 reads or writes a structure.
2783 ********************************************************************/
2785 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2786 prs_struct *ps, int depth)
2791 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2797 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2800 if (r_u->ptr != 0) {
2801 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2807 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2813 /*******************************************************************
2814 inits a SAMR_Q_QUERY_GROUPMEM structure.
2815 ********************************************************************/
2817 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2819 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2821 q_c->group_pol = *hnd;
2824 /*******************************************************************
2825 reads or writes a structure.
2826 ********************************************************************/
2828 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2829 prs_struct *ps, int depth)
2834 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2840 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2846 /*******************************************************************
2847 inits a SAMR_R_QUERY_GROUPMEM structure.
2848 ********************************************************************/
2850 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2851 uint32 num_entries, uint32 *rid,
2852 uint32 *attr, NTSTATUS status)
2854 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2856 if (NT_STATUS_IS_OK(status)) {
2858 r_u->num_entries = num_entries;
2860 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2861 r_u->ptr_rids = rid != NULL ? 1 : 0;
2863 r_u->num_rids = num_entries;
2866 r_u->num_attrs = num_entries;
2870 r_u->num_entries = 0;
2873 r_u->status = status;
2876 /*******************************************************************
2877 reads or writes a structure.
2878 ********************************************************************/
2880 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2881 prs_struct *ps, int depth)
2888 if (UNMARSHALLING(ps))
2891 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2897 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2899 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2902 if (r_u->ptr != 0) {
2903 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2905 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2908 if (r_u->ptr_rids != 0) {
2909 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2911 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2912 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2913 if (r_u->rid == NULL)
2917 for (i = 0; i < r_u->num_rids; i++) {
2918 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2923 if (r_u->ptr_attrs != 0) {
2924 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2927 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2928 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2929 if (r_u->attr == NULL)
2933 for (i = 0; i < r_u->num_attrs; i++) {
2934 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2940 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2946 /*******************************************************************
2947 inits a SAMR_Q_QUERY_USERGROUPS structure.
2948 ********************************************************************/
2950 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2953 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2958 /*******************************************************************
2959 reads or writes a structure.
2960 ********************************************************************/
2962 BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2963 prs_struct *ps, int depth)
2968 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2974 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2980 /*******************************************************************
2981 inits a SAMR_R_QUERY_USERGROUPS structure.
2982 ********************************************************************/
2984 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2985 uint32 num_gids, DOM_GID * gid,
2988 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2990 if (NT_STATUS_IS_OK(status)) {
2992 r_u->num_entries = num_gids;
2993 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2994 r_u->num_entries2 = num_gids;
2999 r_u->num_entries = 0;
3004 r_u->status = status;
3007 /*******************************************************************
3008 reads or writes a structure.
3009 ********************************************************************/
3011 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
3012 prs_struct *ps, int depth)
3018 prs_debug(ps, depth, desc, "samr_io_gids");
3024 if(!prs_uint32("num_gids", ps, depth, num_gids))
3027 if ((*num_gids) != 0) {
3028 if (UNMARSHALLING(ps)) {
3029 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
3032 if ((*gid) == NULL) {
3036 for (i = 0; i < (*num_gids); i++) {
3037 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3045 /*******************************************************************
3046 reads or writes a structure.
3047 ********************************************************************/
3049 BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3050 prs_struct *ps, int depth)
3055 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3061 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3064 if (r_u->ptr_0 != 0) {
3065 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3067 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3070 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3071 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3078 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3084 /*******************************************************************
3085 inits a SAMR_Q_ENUM_DOMAINS structure.
3086 ********************************************************************/
3088 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3090 uint32 start_idx, uint32 size)
3092 DEBUG(5, ("init_samr_q_enum_domains\n"));
3096 q_e->start_idx = start_idx;
3097 q_e->max_size = size;
3100 /*******************************************************************
3101 reads or writes a structure.
3102 ********************************************************************/
3104 BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3105 prs_struct *ps, int depth)
3110 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3116 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3119 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3121 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3127 /*******************************************************************
3128 inits a SAMR_R_ENUM_DOMAINS structure.
3129 ********************************************************************/
3131 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3132 uint32 next_idx, uint32 num_sam_entries)
3134 DEBUG(5, ("init_samr_r_enum_domains\n"));
3136 r_u->next_idx = next_idx;
3138 if (num_sam_entries != 0) {
3139 r_u->ptr_entries1 = 1;
3140 r_u->ptr_entries2 = 1;
3141 r_u->num_entries2 = num_sam_entries;
3142 r_u->num_entries3 = num_sam_entries;
3144 r_u->num_entries4 = num_sam_entries;
3146 r_u->ptr_entries1 = 0;
3147 r_u->num_entries2 = num_sam_entries;
3148 r_u->ptr_entries2 = 1;
3152 /*******************************************************************
3153 reads or writes a structure.
3154 ********************************************************************/
3156 BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3157 prs_struct *ps, int depth)
3164 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3170 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3172 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3175 if (r_u->ptr_entries1 != 0) {
3176 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3178 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3180 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3183 if (UNMARSHALLING(ps)) {
3184 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3185 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3188 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3189 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3190 r_u->num_entries4 = 0;
3191 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3195 for (i = 0; i < r_u->num_entries2; i++) {
3197 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3198 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3202 for (i = 0; i < r_u->num_entries2; i++) {
3204 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3205 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3206 r_u->sam[i].hdr_name.buffer, ps,
3215 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3217 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3223 /*******************************************************************
3224 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3225 ********************************************************************/
3227 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3229 uint32 start_idx, uint32 size)
3231 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3235 q_e->start_idx = start_idx;
3236 q_e->max_size = size;
3239 /*******************************************************************
3240 reads or writes a structure.
3241 ********************************************************************/
3243 BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3244 prs_struct *ps, int depth)
3249 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3255 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3258 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3260 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3266 /*******************************************************************
3267 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3268 ********************************************************************/
3270 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3271 uint32 next_idx, uint32 num_sam_entries)
3273 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3275 r_u->next_idx = next_idx;
3277 if (num_sam_entries != 0) {
3278 r_u->ptr_entries1 = 1;
3279 r_u->ptr_entries2 = 1;
3280 r_u->num_entries2 = num_sam_entries;
3281 r_u->num_entries3 = num_sam_entries;
3283 r_u->num_entries4 = num_sam_entries;
3285 r_u->ptr_entries1 = 0;
3286 r_u->num_entries2 = num_sam_entries;
3287 r_u->ptr_entries2 = 1;
3291 /*******************************************************************
3292 reads or writes a structure.
3293 ********************************************************************/
3295 BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3296 prs_struct *ps, int depth)
3303 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3309 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3311 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3314 if (r_u->ptr_entries1 != 0) {
3315 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3317 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3319 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3322 if (UNMARSHALLING(ps)) {
3323 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3324 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3327 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3329 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3330 r_u->num_entries4 = 0;
3331 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3335 for (i = 0; i < r_u->num_entries2; i++) {
3336 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3340 for (i = 0; i < r_u->num_entries2; i++) {
3341 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3342 r_u->sam[i].hdr_name.buffer, ps, depth))
3349 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3351 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3357 /*******************************************************************
3358 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3359 ********************************************************************/
3361 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3362 POLICY_HND *pol, uint32 start_idx,
3365 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3369 q_e->start_idx = start_idx;
3370 q_e->max_size = size;
3374 /*******************************************************************
3375 reads or writes a structure.
3376 ********************************************************************/
3378 BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3379 prs_struct *ps, int depth)
3384 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3390 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3393 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3395 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3401 /*******************************************************************
3402 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3403 ********************************************************************/
3405 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3407 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3409 r_u->next_idx = next_idx;
3411 if (num_sam_entries != 0) {
3412 r_u->ptr_entries1 = 1;
3413 r_u->ptr_entries2 = 1;
3414 r_u->num_entries2 = num_sam_entries;
3415 r_u->num_entries3 = num_sam_entries;
3417 r_u->num_entries4 = num_sam_entries;
3419 r_u->ptr_entries1 = 0;
3420 r_u->num_entries2 = num_sam_entries;
3421 r_u->ptr_entries2 = 1;
3425 /*******************************************************************
3426 reads or writes a structure.
3427 ********************************************************************/
3429 BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3430 prs_struct *ps, int depth)
3437 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3443 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3445 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3448 if (r_u->ptr_entries1 != 0) {
3449 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3451 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3453 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3456 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3457 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3458 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3461 if (r_u->num_entries2 != 0 &&
3462 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3463 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3464 r_u->num_entries4 = 0;
3465 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3469 for (i = 0; i < r_u->num_entries2; i++) {
3470 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3474 for (i = 0; i < r_u->num_entries2; i++) {
3475 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3476 r_u->sam[i].hdr_name.buffer, ps,
3484 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3486 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3492 /*******************************************************************
3493 inits a ALIAS_INFO1 structure.
3494 ********************************************************************/
3496 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3498 int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0;
3499 int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0;
3501 DEBUG(5, ("init_samr_alias_info1\n"));
3503 init_uni_hdr(&al1->hdr_acct_name, acct_len_name);
3504 init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name);
3506 al1->num_member=num_member;
3508 init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc);
3509 init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc);
3512 /*******************************************************************
3513 reads or writes a structure.
3514 ********************************************************************/
3516 BOOL samr_io_alias_info1(char *desc, ALIAS_INFO1 * al1,
3517 prs_struct *ps, int depth)
3522 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3528 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3530 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3532 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3535 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3536 al1->hdr_acct_name.buffer, ps, depth))
3542 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3543 al1->hdr_acct_desc.buffer, ps, depth))
3549 /*******************************************************************
3550 inits a ALIAS_INFO3 structure.
3551 ********************************************************************/
3553 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3555 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3557 DEBUG(5, ("init_samr_alias_info3\n"));
3559 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3560 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3563 /*******************************************************************
3564 reads or writes a structure.
3565 ********************************************************************/
3567 BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
3568 prs_struct *ps, int depth)
3573 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3579 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3581 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3582 al3->hdr_acct_desc.buffer, ps, depth))
3588 /*******************************************************************
3589 reads or writes a structure.
3590 ********************************************************************/
3592 BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
3593 prs_struct *ps, int depth)
3598 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3601 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3603 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3606 switch (ctr->switch_value1) {
3608 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3612 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3616 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3623 /*******************************************************************
3624 inits a SAMR_Q_QUERY_ALIASINFO structure.
3625 ********************************************************************/
3627 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3628 POLICY_HND *pol, uint16 switch_level)
3630 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3633 q_e->switch_level = switch_level;
3636 /*******************************************************************
3637 reads or writes a structure.
3638 ********************************************************************/
3640 BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3641 prs_struct *ps, int depth)
3646 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3652 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3655 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3661 /*******************************************************************
3662 inits a SAMR_R_QUERY_ALIASINFO structure.
3663 ********************************************************************/
3665 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3666 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3668 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3670 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3672 r_u->status = status;
3675 /*******************************************************************
3676 reads or writes a structure.
3677 ********************************************************************/
3679 BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3680 prs_struct *ps, int depth)
3685 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3691 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3694 if (r_u->ptr != 0) {
3695 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3701 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3707 /*******************************************************************
3708 inits a SAMR_Q_SET_ALIASINFO structure.
3709 ********************************************************************/
3711 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3712 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3714 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3716 q_u->alias_pol = *hnd;
3720 /*******************************************************************
3721 reads or writes a structure.
3722 ********************************************************************/
3724 BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3725 prs_struct *ps, int depth)
3730 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3736 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3738 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3744 /*******************************************************************
3745 reads or writes a structure.
3746 ********************************************************************/
3748 BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
3749 prs_struct *ps, int depth)
3754 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3759 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3765 /*******************************************************************
3766 inits a SAMR_Q_QUERY_USERALIASES structure.
3767 ********************************************************************/
3769 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3772 uint32 *ptr_sid, DOM_SID2 * sid)
3774 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3778 q_u->num_sids1 = num_sids;
3780 q_u->num_sids2 = num_sids;
3782 q_u->ptr_sid = ptr_sid;
3786 /*******************************************************************
3787 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3788 ********************************************************************/
3790 BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3791 prs_struct *ps, int depth)
3799 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3805 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3808 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3810 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3816 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3819 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3820 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3821 if (q_u->ptr_sid == NULL)
3824 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3825 if (q_u->sid == NULL)
3829 for (i = 0; i < q_u->num_sids2; i++) {
3830 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3831 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3835 for (i = 0; i < q_u->num_sids2; i++) {
3836 if (q_u->ptr_sid[i] != 0) {
3837 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3838 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3846 /*******************************************************************
3847 inits a SAMR_R_QUERY_USERALIASES structure.
3848 ********************************************************************/
3850 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3851 uint32 num_rids, uint32 *rid,
3854 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3856 if (NT_STATUS_IS_OK(status)) {
3857 r_u->num_entries = num_rids;
3859 r_u->num_entries2 = num_rids;
3863 r_u->num_entries = 0;
3865 r_u->num_entries2 = 0;
3868 r_u->status = status;
3871 /*******************************************************************
3872 reads or writes a structure.
3873 ********************************************************************/
3875 BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
3876 prs_struct *ps, int depth)
3883 prs_debug(ps, depth, desc, "samr_io_rids");
3889 if(!prs_uint32("num_rids", ps, depth, num_rids))
3892 if ((*num_rids) != 0) {
3893 if (UNMARSHALLING(ps)) {
3895 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3900 for (i = 0; i < (*num_rids); i++) {
3901 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3902 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3910 /*******************************************************************
3911 reads or writes a structure.
3912 ********************************************************************/
3914 BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3915 prs_struct *ps, int depth)
3920 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3926 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3928 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3931 if (r_u->ptr != 0) {
3932 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3938 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3944 /*******************************************************************
3945 inits a SAMR_Q_OPEN_ALIAS structure.
3946 ********************************************************************/
3948 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3949 uint32 access_mask, uint32 rid)
3951 DEBUG(5, ("init_samr_q_open_alias\n"));
3953 q_u->dom_pol = *pol;
3954 q_u->access_mask = access_mask;
3955 q_u->rid_alias = rid;
3958 /*******************************************************************
3959 reads or writes a structure.
3960 ********************************************************************/
3962 BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3963 prs_struct *ps, int depth)
3968 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3974 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3977 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3979 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3985 /*******************************************************************
3986 reads or writes a structure.
3987 ********************************************************************/
3989 BOOL samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS * r_u,
3990 prs_struct *ps, int depth)
3995 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4001 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4004 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4010 /*******************************************************************
4011 inits a SAMR_Q_LOOKUP_RIDS structure.
4012 ********************************************************************/
4014 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4015 POLICY_HND *pol, uint32 flags,
4016 uint32 num_rids, uint32 *rid)
4018 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4022 q_u->num_rids1 = num_rids;
4025 q_u->num_rids2 = num_rids;
4026 q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0]));
4027 if (q_u->rid == NULL) {
4031 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4035 /*******************************************************************
4036 reads or writes a structure.
4037 ********************************************************************/
4039 BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4040 prs_struct *ps, int depth)
4048 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4051 if (UNMARSHALLING(ps))
4057 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4060 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4062 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4064 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4066 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4069 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4070 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
4071 if (q_u->rid == NULL)
4075 for (i = 0; i < q_u->num_rids2; i++) {
4076 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4077 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4084 /*******************************************************************
4085 inits a SAMR_R_LOOKUP_RIDS structure.
4086 ********************************************************************/
4088 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4089 uint32 num_names, UNIHDR * hdr_name,
4090 UNISTR2 *uni_name, uint32 *type)
4092 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4094 r_u->hdr_name = NULL;
4095 r_u->uni_name = NULL;
4098 if (num_names != 0) {
4099 r_u->num_names1 = num_names;
4101 r_u->num_names2 = num_names;
4103 r_u->num_types1 = num_names;
4105 r_u->num_types2 = num_names;
4107 r_u->hdr_name = hdr_name;
4108 r_u->uni_name = uni_name;
4111 r_u->num_names1 = num_names;
4113 r_u->num_names2 = num_names;
4115 r_u->num_types1 = num_names;
4117 r_u->num_types2 = num_names;
4121 /*******************************************************************
4122 reads or writes a structure.
4123 ********************************************************************/
4125 BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4126 prs_struct *ps, int depth)
4133 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4139 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4141 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4144 if (r_u->ptr_names != 0) {
4146 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4150 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4151 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
4152 if (r_u->hdr_name == NULL)
4155 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
4156 if (r_u->uni_name == NULL)
4160 for (i = 0; i < r_u->num_names2; i++) {
4161 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4162 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4165 for (i = 0; i < r_u->num_names2; i++) {
4166 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4167 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4175 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4177 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4180 if (r_u->ptr_types != 0) {
4182 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4185 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4186 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
4187 if (r_u->type == NULL)
4191 for (i = 0; i < r_u->num_types2; i++) {
4192 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4193 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4198 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4204 /*******************************************************************
4205 inits a SAMR_Q_OPEN_ALIAS structure.
4206 ********************************************************************/
4208 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4210 DEBUG(5, ("init_samr_q_delete_alias\n"));
4212 q_u->alias_pol = *hnd;
4215 /*******************************************************************
4216 reads or writes a structure.
4217 ********************************************************************/
4219 BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4220 prs_struct *ps, int depth)
4225 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4231 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4237 /*******************************************************************
4238 reads or writes a structure.
4239 ********************************************************************/
4241 BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4242 prs_struct *ps, int depth)
4247 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4253 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4255 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4261 /*******************************************************************
4262 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4263 ********************************************************************/
4265 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4266 POLICY_HND *hnd, char *acct_desc)
4268 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
4270 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4272 q_u->dom_pol = *hnd;
4274 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
4275 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
4277 q_u->access_mask = 0x001f000f;
4280 /*******************************************************************
4281 reads or writes a structure.
4282 ********************************************************************/
4284 BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4285 prs_struct *ps, int depth)
4290 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4296 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4299 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4301 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4302 q_u->hdr_acct_desc.buffer, ps, depth))
4307 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4313 /*******************************************************************
4314 reads or writes a structure.
4315 ********************************************************************/
4317 BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4318 prs_struct *ps, int depth)
4323 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4329 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4332 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4335 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4341 /*******************************************************************
4342 inits a SAMR_Q_ADD_ALIASMEM structure.
4343 ********************************************************************/
4345 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4348 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4350 q_u->alias_pol = *hnd;
4351 init_dom_sid2(&q_u->sid, sid);
4354 /*******************************************************************
4355 reads or writes a structure.
4356 ********************************************************************/
4358 BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4359 prs_struct *ps, int depth)
4364 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4370 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4372 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4378 /*******************************************************************
4379 reads or writes a structure.
4380 ********************************************************************/
4382 BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4383 prs_struct *ps, int depth)
4388 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4394 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4400 /*******************************************************************
4401 inits a SAMR_Q_DEL_ALIASMEM structure.
4402 ********************************************************************/
4404 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4407 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4409 q_u->alias_pol = *hnd;
4410 init_dom_sid2(&q_u->sid, sid);
4413 /*******************************************************************
4414 reads or writes a structure.
4415 ********************************************************************/
4417 BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4418 prs_struct *ps, int depth)
4423 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4429 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4431 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4437 /*******************************************************************
4438 reads or writes a structure.
4439 ********************************************************************/
4441 BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4442 prs_struct *ps, int depth)
4447 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4453 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4459 /*******************************************************************
4460 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4461 ********************************************************************/
4463 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4466 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4468 q_c->alias_pol = *hnd;
4471 /*******************************************************************
4472 reads or writes a structure.
4473 ********************************************************************/
4475 BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4476 prs_struct *ps, int depth)
4481 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4487 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4493 /*******************************************************************
4494 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4495 ********************************************************************/
4497 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4500 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4502 r_u->status = status;
4505 /*******************************************************************
4506 reads or writes a structure.
4507 ********************************************************************/
4509 BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4510 prs_struct *ps, int depth)
4515 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4521 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4527 /*******************************************************************
4528 inits a SAMR_Q_QUERY_ALIASMEM structure.
4529 ********************************************************************/
4531 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4534 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4536 q_c->alias_pol = *hnd;
4539 /*******************************************************************
4540 reads or writes a structure.
4541 ********************************************************************/
4543 BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4544 prs_struct *ps, int depth)
4549 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4555 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4561 /*******************************************************************
4562 inits a SAMR_R_QUERY_ALIASMEM structure.
4563 ********************************************************************/
4565 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4566 uint32 num_sids, DOM_SID2 * sid,
4569 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4571 if (NT_STATUS_IS_OK(status)) {
4572 r_u->num_sids = num_sids;
4573 r_u->ptr = (num_sids != 0) ? 1 : 0;
4574 r_u->num_sids1 = num_sids;
4582 r_u->status = status;
4585 /*******************************************************************
4586 reads or writes a structure.
4587 ********************************************************************/
4589 BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4590 prs_struct *ps, int depth)
4593 uint32 ptr_sid[MAX_LOOKUP_SIDS];
4598 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4604 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4606 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4609 if (r_u->ptr != 0) {
4610 SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids);
4612 if (r_u->num_sids != 0) {
4613 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4616 for (i = 0; i < r_u->num_sids1; i++) {
4618 if(!prs_uint32("", ps, depth, &ptr_sid[i]))
4622 for (i = 0; i < r_u->num_sids1; i++) {
4623 if (ptr_sid[i] != 0) {
4624 if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth))
4633 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4639 /*******************************************************************
4640 inits a SAMR_Q_LOOKUP_NAMES structure.
4641 ********************************************************************/
4643 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4644 POLICY_HND *pol, uint32 flags,
4645 uint32 num_names, const char **name)
4649 DEBUG(5, ("init_samr_q_lookup_names\n"));
4653 q_u->num_names1 = num_names;
4656 q_u->num_names2 = num_names;
4658 if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR))))
4659 return NT_STATUS_NO_MEMORY;
4661 if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2))))
4662 return NT_STATUS_NO_MEMORY;
4664 for (i = 0; i < num_names; i++) {
4665 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4666 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4667 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4670 return NT_STATUS_OK;
4673 /*******************************************************************
4674 reads or writes a structure.
4675 ********************************************************************/
4677 BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4678 prs_struct *ps, int depth)
4685 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4688 if (UNMARSHALLING(ps))
4694 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4697 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4699 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4701 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4703 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4706 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4707 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4709 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4711 if (!q_u->hdr_name || !q_u->uni_name)
4715 for (i = 0; i < q_u->num_names2; i++) {
4716 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4720 for (i = 0; i < q_u->num_names2; i++) {
4721 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4728 /*******************************************************************
4729 inits a SAMR_R_LOOKUP_NAMES structure.
4730 ********************************************************************/
4732 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4734 uint32 *rid, uint32 *type,
4737 DEBUG(5, ("init_samr_r_lookup_names\n"));
4739 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4742 r_u->num_types1 = num_rids;
4744 r_u->num_types2 = num_rids;
4746 r_u->num_rids1 = num_rids;
4748 r_u->num_rids2 = num_rids;
4750 if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4751 return NT_STATUS_NO_MEMORY;
4752 if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4753 return NT_STATUS_NO_MEMORY;
4755 if (!r_u->rids || !r_u->types)
4758 for (i = 0; i < num_rids; i++) {
4759 r_u->rids[i] = rid[i];
4760 r_u->types[i] = type[i];
4765 r_u->num_types1 = 0;
4767 r_u->num_types2 = 0;
4777 r_u->status = status;
4779 return NT_STATUS_OK;
4782 /*******************************************************************
4783 reads or writes a structure.
4784 ********************************************************************/
4786 BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4787 prs_struct *ps, int depth)
4795 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4798 if (UNMARSHALLING(ps))
4804 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4806 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4809 if (r_u->ptr_rids != 0) {
4810 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4813 if (r_u->num_rids2 != r_u->num_rids1) {
4818 if (UNMARSHALLING(ps))
4819 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4822 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4826 for (i = 0; i < r_u->num_rids2; i++) {
4827 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4828 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4833 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4835 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4838 if (r_u->ptr_types != 0) {
4839 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4842 if (r_u->num_types2 != r_u->num_types1) {
4847 if (UNMARSHALLING(ps))
4848 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4851 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4855 for (i = 0; i < r_u->num_types2; i++) {
4856 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4857 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4862 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4868 /*******************************************************************
4869 inits a SAMR_Q_DELETE_DOM_USER structure.
4870 ********************************************************************/
4872 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4875 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4877 q_c->user_pol = *hnd;
4880 /*******************************************************************
4881 reads or writes a structure.
4882 ********************************************************************/
4884 BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4885 prs_struct *ps, int depth)
4890 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4896 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4902 /*******************************************************************
4903 reads or writes a structure.
4904 ********************************************************************/
4906 BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4907 prs_struct *ps, int depth)
4912 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4918 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4920 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4926 /*******************************************************************
4927 reads or writes a structure.
4928 ********************************************************************/
4930 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4932 uint32 access_mask, uint32 rid)
4934 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4936 q_u->domain_pol = *pol;
4937 q_u->access_mask = access_mask;
4938 q_u->user_rid = rid;
4941 /*******************************************************************
4942 reads or writes a structure.
4943 ********************************************************************/
4945 BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
4946 prs_struct *ps, int depth)
4951 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4957 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4960 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4962 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4968 /*******************************************************************
4969 reads or writes a structure.
4970 ********************************************************************/
4972 BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
4973 prs_struct *ps, int depth)
4978 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4984 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4987 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4994 /*******************************************************************
4995 reads or writes a structure.
4996 ********************************************************************/
4998 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5001 uint32 acb_info, uint32 access_mask)
5004 len_name = strlen(name);
5006 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5008 q_u->domain_pol = *pol;
5010 init_uni_hdr(&q_u->hdr_name, len_name);
5011 init_unistr2(&q_u->uni_name, name, len_name);
5013 q_u->acb_info = acb_info;
5014 q_u->access_mask = access_mask;
5017 /*******************************************************************
5018 reads or writes a structure.
5019 ********************************************************************/
5021 BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
5022 prs_struct *ps, int depth)
5027 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5033 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5036 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5038 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5043 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5045 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5051 /*******************************************************************
5052 reads or writes a structure.
5053 ********************************************************************/
5055 BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
5056 prs_struct *ps, int depth)
5061 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5067 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5070 if(!prs_uint32("unknown_0", ps, depth, &r_u->unknown_0))
5072 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5074 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5080 /*******************************************************************
5081 inits a SAMR_Q_QUERY_USERINFO structure.
5082 ********************************************************************/
5084 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5085 POLICY_HND *hnd, uint16 switch_value)
5087 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5090 q_u->switch_value = switch_value;
5093 /*******************************************************************
5094 reads or writes a structure.
5095 ********************************************************************/
5097 BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5098 prs_struct *ps, int depth)
5103 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5109 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5112 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5118 /*******************************************************************
5119 reads or writes a LOGON_HRS structure.
5120 ********************************************************************/
5122 static BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs,
5123 prs_struct *ps, int depth)
5128 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5134 if(!prs_uint32("len ", ps, depth, &hrs->len))
5137 if (hrs->len > sizeof(hrs->hours)) {
5138 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5139 hrs->len = sizeof(hrs->hours);
5142 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5148 /*******************************************************************
5149 inits a SAM_USER_INFO_12 structure.
5150 ********************************************************************/
5152 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5153 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5155 DEBUG(5, ("init_sam_user_info12\n"));
5157 usr->lm_pwd_active =
5158 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5159 usr->nt_pwd_active =
5160 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5163 /*******************************************************************
5164 reads or writes a structure.
5165 ********************************************************************/
5167 static BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
5168 prs_struct *ps, int depth)
5173 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5179 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5181 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5184 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5186 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5192 /*******************************************************************
5193 inits a SAM_USER_INFO_10 structure.
5194 ********************************************************************/
5196 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5198 DEBUG(5, ("init_sam_user_info10\n"));
5200 usr->acb_info = acb_info;
5203 /*******************************************************************
5204 reads or writes a structure.
5205 ********************************************************************/
5207 static BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
5208 prs_struct *ps, int depth)
5213 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5219 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5225 /*******************************************************************
5226 inits a SAM_USER_INFO_11 structure.
5227 ********************************************************************/
5229 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5232 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5236 DEBUG(5, ("init_sam_user_info11\n"));
5238 len_mach_acct = strlen(mach_acct);
5240 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
5241 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5243 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
5244 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5246 usr->ptr_1 = 1; /* pointer */
5247 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5248 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5250 usr->ptr_2 = 1; /* pointer */
5251 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5253 usr->ptr_3 = 1; /* pointer */
5254 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5256 usr->rid_user = rid_user;
5257 usr->rid_group = rid_group;
5259 usr->acct_ctrl = acct_ctrl;
5260 usr->unknown_3 = 0x0000;
5262 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5263 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5265 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5266 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5268 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
5271 /*******************************************************************
5272 reads or writes a structure.
5273 ********************************************************************/
5275 static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
5276 prs_struct *ps, int depth)
5281 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5287 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5290 if(!smb_io_time("time", &usr->expiry, ps, depth))
5293 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5296 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5299 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5302 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5304 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5307 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5310 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5312 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5315 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5317 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5320 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5322 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5324 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5326 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5328 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5330 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5333 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5336 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5339 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5345 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5351 /*************************************************************************
5354 unknown_3 = 0x09f8 27fa
5355 unknown_5 = 0x0001 0000
5356 unknown_6 = 0x0000 04ec
5358 *************************************************************************/
5360 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5362 DEBUG(10, ("init_sam_user_info24:\n"));
5363 memcpy(usr->pass, newpass, sizeof(usr->pass));
5364 usr->pw_len = pw_len;
5367 /*******************************************************************
5368 reads or writes a structure.
5369 ********************************************************************/
5371 static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
5372 prs_struct *ps, int depth)
5377 prs_debug(ps, depth, desc, "sam_io_user_info24");
5383 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5387 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5388 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5397 /*************************************************************************
5398 init_sam_user_info23
5400 unknown_3 = 0x09f8 27fa
5401 unknown_5 = 0x0001 0000
5402 unknown_6 = 0x0000 04ec
5404 *************************************************************************/
5406 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5407 NTTIME * logoff_time, /* all zeros */
5408 NTTIME * kickoff_time, /* all zeros */
5409 NTTIME * pass_last_set_time, /* all zeros */
5410 NTTIME * pass_can_change_time, /* all zeros */
5411 NTTIME * pass_must_change_time, /* all zeros */
5422 uint32 user_rid, /* 0x0000 0000 */
5429 char newpass[516], uint32 unknown_6)
5431 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5432 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5433 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5434 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5435 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5436 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5437 int len_description = desc != NULL ? desc->uni_str_len : 0;
5438 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5439 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5440 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5442 usr->logon_time = *logon_time; /* all zeros */
5443 usr->logoff_time = *logoff_time; /* all zeros */
5444 usr->kickoff_time = *kickoff_time; /* all zeros */
5445 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5446 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5447 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5449 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5450 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5451 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5452 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5453 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5454 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5455 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5456 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5457 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5458 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5460 ZERO_STRUCT(usr->nt_pwd);
5461 ZERO_STRUCT(usr->lm_pwd);
5463 usr->user_rid = user_rid; /* 0x0000 0000 */
5464 usr->group_rid = group_rid;
5465 usr->acb_info = acb_info;
5466 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5468 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5469 usr->ptr_logon_hrs = hrs ? 1 : 0;
5471 ZERO_STRUCT(usr->padding1);
5473 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5475 memcpy(usr->pass, newpass, sizeof(usr->pass));
5477 copy_unistr2(&usr->uni_user_name, user_name);
5478 copy_unistr2(&usr->uni_full_name, full_name);
5479 copy_unistr2(&usr->uni_home_dir, home_dir);
5480 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5481 copy_unistr2(&usr->uni_logon_script, log_scr);
5482 copy_unistr2(&usr->uni_profile_path, prof_path);
5483 copy_unistr2(&usr->uni_acct_desc, desc);
5484 copy_unistr2(&usr->uni_workstations, wkstas);
5485 copy_unistr2(&usr->uni_unknown_str, unk_str);
5486 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5488 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5491 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5494 /*************************************************************************
5495 init_sam_user_info23
5497 unknown_3 = 0x09f8 27fa
5498 unknown_5 = 0x0001 0000
5499 unknown_6 = 0x0000 04ec
5501 *************************************************************************/
5503 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5504 NTTIME * logoff_time, /* all zeros */
5505 NTTIME * kickoff_time, /* all zeros */
5506 NTTIME * pass_last_set_time, /* all zeros */
5507 NTTIME * pass_can_change_time, /* all zeros */
5508 NTTIME * pass_must_change_time, /* all zeros */
5509 char *user_name, /* NULL */
5511 char *home_dir, char *dir_drive, char *log_scr,
5512 char *prof_path, char *desc, char *wkstas,
5513 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5514 uint32 group_rid, uint32 acb_info,
5515 uint32 unknown_3, uint16 logon_divs,
5516 LOGON_HRS * hrs, uint32 unknown_5,
5517 char newpass[516], uint32 unknown_6)
5519 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5520 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5521 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5522 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5523 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5524 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5525 int len_description = desc != NULL ? strlen(desc) : 0;
5526 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5527 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5528 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5530 usr->logon_time = *logon_time; /* all zeros */
5531 usr->logoff_time = *logoff_time; /* all zeros */
5532 usr->kickoff_time = *kickoff_time; /* all zeros */
5533 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5534 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5535 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5537 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5538 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5539 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5540 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5541 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5542 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5543 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5544 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5545 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5546 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5548 ZERO_STRUCT(usr->nt_pwd);
5549 ZERO_STRUCT(usr->lm_pwd);
5551 usr->user_rid = user_rid; /* 0x0000 0000 */
5552 usr->group_rid = group_rid;
5553 usr->acb_info = acb_info;
5554 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5556 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5557 usr->ptr_logon_hrs = hrs ? 1 : 0;
5559 ZERO_STRUCT(usr->padding1);
5561 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5563 memcpy(usr->pass, newpass, sizeof(usr->pass));
5565 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5566 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5567 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5568 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5569 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5570 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5571 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5572 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5573 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5574 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5576 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5579 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5582 /*******************************************************************
5583 reads or writes a structure.
5584 ********************************************************************/
5586 static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
5587 prs_struct *ps, int depth)
5592 prs_debug(ps, depth, desc, "sam_io_user_info23");
5598 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5600 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5602 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5604 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5606 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5608 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5611 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5613 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5615 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5617 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5619 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5621 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5623 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5625 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5627 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5629 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5632 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5634 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5637 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5639 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5641 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5644 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5646 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5650 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5652 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5654 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5657 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5660 /* here begins pointed-to data */
5662 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5665 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5668 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5671 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5674 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5677 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5680 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5683 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5686 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5689 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5692 /* ok, this is only guess-work (as usual) */
5693 if (usr->ptr_logon_hrs) {
5694 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5696 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5698 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5700 } else if (UNMARSHALLING(ps)) {
5708 /*******************************************************************
5709 reads or writes a structure.
5710 NB. This structure is *definately* incorrect. It's my best guess
5711 currently for W2K SP2. The password field is encrypted in a different
5712 way than normal... And there are definately other problems. JRA.
5713 ********************************************************************/
5715 static BOOL sam_io_user_info25(char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5720 prs_debug(ps, depth, desc, "sam_io_user_info25");
5726 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5728 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5730 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5732 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5734 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5736 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5739 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5741 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5743 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5745 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5747 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5749 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5751 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5753 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5755 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5757 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5760 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5762 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5765 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5767 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5769 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5772 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5775 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5778 /* here begins pointed-to data */
5780 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5783 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5786 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5789 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5792 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5795 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5798 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5801 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5804 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5807 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5810 #if 0 /* JRA - unknown... */
5811 /* ok, this is only guess-work (as usual) */
5812 if (usr->ptr_logon_hrs) {
5813 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5815 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5817 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5819 } else if (UNMARSHALLING(ps)) {
5829 /*************************************************************************
5830 init_sam_user_info21W
5832 unknown_3 = 0x00ff ffff
5833 unknown_5 = 0x0002 0000
5834 unknown_6 = 0x0000 04ec
5836 *************************************************************************/
5838 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5839 NTTIME * logon_time,
5840 NTTIME * logoff_time,
5841 NTTIME * kickoff_time,
5842 NTTIME * pass_last_set_time,
5843 NTTIME * pass_can_change_time,
5844 NTTIME * pass_must_change_time,
5863 uint32 unknown_5, uint32 unknown_6)
5865 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5866 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5867 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5868 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5869 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5870 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5871 int len_description = desc != NULL ? desc->uni_str_len : 0;
5872 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5873 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5874 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5876 usr->logon_time = *logon_time;
5877 usr->logoff_time = *logoff_time;
5878 usr->kickoff_time = *kickoff_time;
5879 usr->pass_last_set_time = *pass_last_set_time;
5880 usr->pass_can_change_time = *pass_can_change_time;
5881 usr->pass_must_change_time = *pass_must_change_time;
5883 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5884 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5885 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5886 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5887 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5888 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5889 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5890 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5891 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5892 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5894 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5895 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5897 usr->user_rid = user_rid;
5898 usr->group_rid = group_rid;
5899 usr->acb_info = acb_info;
5900 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5902 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5903 usr->ptr_logon_hrs = hrs ? 1 : 0;
5904 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5906 ZERO_STRUCT(usr->padding1);
5908 copy_unistr2(&usr->uni_user_name, user_name);
5909 copy_unistr2(&usr->uni_full_name, full_name);
5910 copy_unistr2(&usr->uni_home_dir, home_dir);
5911 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5912 copy_unistr2(&usr->uni_logon_script, log_scr);
5913 copy_unistr2(&usr->uni_profile_path, prof_path);
5914 copy_unistr2(&usr->uni_acct_desc, desc);
5915 copy_unistr2(&usr->uni_workstations, wkstas);
5916 copy_unistr2(&usr->uni_unknown_str, unk_str);
5917 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5919 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5922 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5925 /*************************************************************************
5926 init_sam_user_info21
5928 unknown_3 = 0x00ff ffff
5929 unknown_5 = 0x0002 0000
5930 unknown_6 = 0x0000 04ec
5932 *************************************************************************/
5934 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5936 NTTIME logon_time, logoff_time, kickoff_time,
5937 pass_last_set_time, pass_can_change_time,
5938 pass_must_change_time;
5940 int len_user_name, len_full_name, len_home_dir,
5941 len_dir_drive, len_logon_script, len_profile_path,
5942 len_description, len_workstations, len_unknown_str,
5945 const char* user_name = pdb_get_username(pw);
5946 const char* full_name = pdb_get_fullname(pw);
5947 const char* home_dir = pdb_get_homedir(pw);
5948 const char* dir_drive = pdb_get_dir_drive(pw);
5949 const char* logon_script = pdb_get_logon_script(pw);
5950 const char* profile_path = pdb_get_profile_path(pw);
5951 const char* description = pdb_get_acct_desc(pw);
5952 const char* workstations = pdb_get_workstations(pw);
5953 const char* munged_dial = pdb_get_munged_dial(pw);
5956 const DOM_SID *user_sid;
5959 const DOM_SID *group_sid;
5961 len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
5962 len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
5963 len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
5964 len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
5965 len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
5966 len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
5967 len_description = description != NULL ? strlen(description )+1 : 0;
5968 len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
5969 len_unknown_str = 0;
5970 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
5973 /* Create NTTIME structs */
5974 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5975 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5976 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5977 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5978 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
5979 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
5981 /* structure assignment */
5982 usr->logon_time = logon_time;
5983 usr->logoff_time = logoff_time;
5984 usr->kickoff_time = kickoff_time;
5985 usr->pass_last_set_time = pass_last_set_time;
5986 usr->pass_can_change_time = pass_can_change_time;
5987 usr->pass_must_change_time = pass_must_change_time;
5989 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5990 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5991 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5992 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5993 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5994 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5995 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5996 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5997 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5998 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6000 ZERO_STRUCT(usr->nt_pwd);
6001 ZERO_STRUCT(usr->lm_pwd);
6003 user_sid = pdb_get_user_sid(pw);
6005 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6006 fstring user_sid_string;
6007 fstring domain_sid_string;
6008 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6009 "the domain sid %s. Failing operation.\n",
6011 sid_to_string(user_sid_string, user_sid),
6012 sid_to_string(domain_sid_string, domain_sid)));
6013 return NT_STATUS_UNSUCCESSFUL;
6016 group_sid = pdb_get_group_sid(pw);
6018 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6019 fstring group_sid_string;
6020 fstring domain_sid_string;
6021 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6022 "which conflicts with the domain sid %s. Failing operation.\n",
6024 sid_to_string(group_sid_string, group_sid),
6025 sid_to_string(domain_sid_string, domain_sid)));
6026 return NT_STATUS_UNSUCCESSFUL;
6029 usr->user_rid = user_rid;
6030 usr->group_rid = group_rid;
6031 usr->acb_info = pdb_get_acct_ctrl(pw);
6032 usr->unknown_3 = pdb_get_unknown3(pw);
6034 usr->logon_divs = pdb_get_logon_divs(pw);
6035 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6036 usr->unknown_5 = pdb_get_unknown5(pw); /* 0x0002 0000 */
6038 ZERO_STRUCT(usr->padding1);
6040 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
6041 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
6042 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
6043 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
6044 init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
6045 init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
6046 init_unistr2(&usr->uni_acct_desc, description, len_description);
6047 init_unistr2(&usr->uni_workstations, workstations, len_workstations);
6048 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
6049 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6051 usr->unknown_6 = pdb_get_unknown6(pw);
6054 if (pdb_get_hours(pw)) {
6055 usr->logon_hrs.len = pdb_get_hours_len(pw);
6056 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6058 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6060 return NT_STATUS_OK;
6063 /*******************************************************************
6064 reads or writes a structure.
6065 ********************************************************************/
6067 static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
6068 prs_struct *ps, int depth)
6073 prs_debug(ps, depth, desc, "sam_io_user_info21");
6079 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6081 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6083 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6085 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6087 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6089 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6092 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6094 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6096 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6098 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6100 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6102 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6104 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6106 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6108 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6110 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6113 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6115 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6118 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6120 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6122 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6125 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
6127 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6131 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6133 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
6136 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6139 /* here begins pointed-to data */
6141 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6143 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6145 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6147 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6149 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6151 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6153 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6155 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6157 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6159 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6162 /* ok, this is only guess-work (as usual) */
6163 if (usr->ptr_logon_hrs) {
6166 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6168 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6170 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6172 } else if (UNMARSHALLING(ps)) {
6180 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6182 int len_munged_dial;
6183 const char* munged_dial = pdb_get_munged_dial(pw);
6185 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6186 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6187 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6191 /*******************************************************************
6192 reads or writes a structure.
6193 ********************************************************************/
6195 static BOOL sam_io_user_info20(char *desc, SAM_USER_INFO_20 *usr,
6196 prs_struct *ps, int depth)
6201 prs_debug(ps, depth, desc, "sam_io_user_info20");
6207 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6210 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6216 /*******************************************************************
6217 inits a SAM_USERINFO_CTR structure.
6218 ********************************************************************/
6220 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6221 uint16 switch_value,
6222 SAM_USER_INFO_21 * usr)
6224 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6226 ctr->switch_value = switch_value;
6227 ctr->info.id = NULL;
6229 switch (switch_value) {
6231 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
6232 if (ctr->info.id10 == NULL)
6233 return NT_STATUS_NO_MEMORY;
6235 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6238 /* whoops - got this wrong. i think. or don't understand what's happening. */
6242 info = (void *)&id11;
6244 expire.low = 0xffffffff;
6245 expire.high = 0x7fffffff;
6247 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
6248 init_sam_user_info11(ctr->info.id11, &expire,
6249 "BROOKFIELDS$", /* name */
6250 0x03ef, /* user rid */
6251 0x201, /* group rid */
6252 0x0080); /* acb info */
6258 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
6259 if (ctr->info.id12 == NULL)
6260 return NT_STATUS_NO_MEMORY;
6262 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6266 SAM_USER_INFO_21 *cusr;
6267 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
6268 ctr->info.id21 = cusr;
6269 if (ctr->info.id21 == NULL)
6270 return NT_STATUS_NO_MEMORY;
6271 memcpy(cusr, usr, sizeof(*usr));
6272 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6273 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6277 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6278 return NT_STATUS_INVALID_INFO_CLASS;
6281 return NT_STATUS_OK;
6284 /*******************************************************************
6285 inits a SAM_USERINFO_CTR structure.
6286 ********************************************************************/
6288 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
6289 uint16 switch_value, void *info)
6291 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6293 ctr->switch_value = switch_value;
6294 ctr->info.id = info;
6296 switch (switch_value) {
6298 SamOEMhash(ctr->info.id24->pass, sess_key, 516);
6299 dump_data(100, (char *)sess_key, 16);
6300 dump_data(100, (char *)ctr->info.id24->pass, 516);
6303 SamOEMhash(ctr->info.id23->pass, sess_key, 516);
6304 dump_data(100, (char *)sess_key, 16);
6305 dump_data(100, (char *)ctr->info.id23->pass, 516);
6308 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6312 /*******************************************************************
6313 reads or writes a structure.
6314 ********************************************************************/
6316 static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR **ppctr,
6317 prs_struct *ps, int depth)
6320 SAM_USERINFO_CTR *ctr;
6322 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6325 if (UNMARSHALLING(ps)) {
6326 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
6334 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6336 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6343 switch (ctr->switch_value) {
6345 if (UNMARSHALLING(ps))
6346 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
6347 if (ctr->info.id10 == NULL) {
6348 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6351 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6354 if (UNMARSHALLING(ps))
6355 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
6357 if (ctr->info.id11 == NULL) {
6358 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6361 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6364 if (UNMARSHALLING(ps))
6365 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
6367 if (ctr->info.id12 == NULL) {
6368 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6371 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6374 if (UNMARSHALLING(ps))
6375 ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20));
6377 if (ctr->info.id20 == NULL) {
6378 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6381 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6384 if (UNMARSHALLING(ps))
6385 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
6387 if (ctr->info.id21 == NULL) {
6388 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6391 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6394 if (UNMARSHALLING(ps))
6395 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
6397 if (ctr->info.id23 == NULL) {
6398 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6401 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6404 if (UNMARSHALLING(ps))
6405 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
6407 if (ctr->info.id24 == NULL) {
6408 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6411 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6414 if (UNMARSHALLING(ps))
6415 ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25));
6417 if (ctr->info.id25 == NULL) {
6418 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6421 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6424 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6432 /*******************************************************************
6433 inits a SAMR_R_QUERY_USERINFO structure.
6434 ********************************************************************/
6436 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6437 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6439 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6444 if (NT_STATUS_IS_OK(status)) {
6449 r_u->status = status; /* return status */
6452 /*******************************************************************
6453 reads or writes a structure.
6454 ********************************************************************/
6456 BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
6457 prs_struct *ps, int depth)
6462 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6468 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6471 if (r_u->ptr != 0) {
6472 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6478 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6484 /*******************************************************************
6485 inits a SAMR_Q_SET_USERINFO structure.
6486 ********************************************************************/
6488 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6489 POLICY_HND *hnd, unsigned char sess_key[16],
6490 uint16 switch_value, void *info)
6492 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6495 q_u->switch_value = switch_value;
6496 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6499 /*******************************************************************
6500 reads or writes a structure.
6501 ********************************************************************/
6503 BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
6504 prs_struct *ps, int depth)
6509 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6515 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6517 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6519 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6525 /*******************************************************************
6526 inits a SAMR_R_SET_USERINFO structure.
6527 ********************************************************************/
6529 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6531 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6533 r_u->status = status; /* return status */
6536 /*******************************************************************
6537 reads or writes a structure.
6538 ********************************************************************/
6540 BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
6541 prs_struct *ps, int depth)
6546 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6552 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6558 /*******************************************************************
6559 inits a SAMR_Q_SET_USERINFO2 structure.
6560 ********************************************************************/
6562 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6563 POLICY_HND *hnd, unsigned char sess_key[16],
6564 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6566 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6569 q_u->switch_value = switch_value;
6572 if (q_u->ctr != NULL)
6573 q_u->ctr->switch_value = switch_value;
6575 switch (switch_value) {
6577 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16);
6578 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16);
6579 dump_data(100, (char *)sess_key, 16);
6580 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6581 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6586 /*******************************************************************
6587 reads or writes a structure.
6588 ********************************************************************/
6590 BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6591 prs_struct *ps, int depth)
6596 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6602 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6605 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6607 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6613 /*******************************************************************
6614 inits a SAMR_R_SET_USERINFO2 structure.
6615 ********************************************************************/
6617 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6619 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6621 r_u->status = status; /* return status */
6624 /*******************************************************************
6625 reads or writes a structure.
6626 ********************************************************************/
6628 BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
6629 prs_struct *ps, int depth)
6634 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6640 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6646 /*******************************************************************
6647 inits a SAMR_Q_CONNECT structure.
6648 ********************************************************************/
6650 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6651 char *srv_name, uint32 access_mask)
6653 int len_srv_name = strlen(srv_name);
6655 DEBUG(5, ("init_samr_q_connect\n"));
6657 /* make PDC server name \\server */
6658 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6659 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6661 /* example values: 0x0000 0002 */
6662 q_u->access_mask = access_mask;
6665 /*******************************************************************
6666 reads or writes a structure.
6667 ********************************************************************/
6669 BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
6670 prs_struct *ps, int depth)
6675 prs_debug(ps, depth, desc, "samr_io_q_connect");
6681 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6683 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6688 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6694 /*******************************************************************
6695 reads or writes a structure.
6696 ********************************************************************/
6698 BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
6699 prs_struct *ps, int depth)
6704 prs_debug(ps, depth, desc, "samr_io_r_connect");
6710 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6713 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6719 /*******************************************************************
6720 inits a SAMR_Q_CONNECT_ANON structure.
6721 ********************************************************************/
6723 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6725 DEBUG(5, ("init_samr_q_connect_anon\n"));
6728 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6729 q_u->unknown_1 = 0x01;
6730 q_u->access_mask = 0x20;
6733 /*******************************************************************
6734 reads or writes a structure.
6735 ********************************************************************/
6737 BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
6738 prs_struct *ps, int depth)
6743 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6749 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6751 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6753 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6755 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6761 /*******************************************************************
6762 reads or writes a structure.
6763 ********************************************************************/
6765 BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
6766 prs_struct *ps, int depth)
6771 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6777 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6780 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6786 /*******************************************************************
6787 inits a SAMR_Q_GET_DOM_PWINFO structure.
6788 ********************************************************************/
6790 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6793 int len_srv_name = strlen(srv_name);
6795 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6798 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6799 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6802 /*******************************************************************
6803 reads or writes a structure.
6804 ********************************************************************/
6806 BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6807 prs_struct *ps, int depth)
6812 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6818 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6820 if (q_u->ptr != 0) {
6821 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6823 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6830 /*******************************************************************
6831 reads or writes a structure.
6832 ********************************************************************/
6834 BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6835 prs_struct *ps, int depth)
6840 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6847 * We need 16 bytes here according to tests. Don't know
6848 * what they are, but the length is important for the singing
6851 if(!prs_uint32("unk_0", ps, depth, &r_u->unk_0))
6853 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
6855 if(!prs_uint32("unk_2", ps, depth, &r_u->unk_2))
6858 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6864 /*******************************************************************
6865 make a SAMR_ENC_PASSWD structure.
6866 ********************************************************************/
6868 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
6876 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6880 /*******************************************************************
6881 reads or writes a SAMR_ENC_PASSWD structure.
6882 ********************************************************************/
6884 BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
6885 prs_struct *ps, int depth)
6890 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6896 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
6899 if (pwd->ptr != 0) {
6900 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
6907 /*******************************************************************
6908 inits a SAMR_ENC_HASH structure.
6909 ********************************************************************/
6911 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
6919 memcpy(hsh->hash, hash, sizeof(hsh->hash));
6923 /*******************************************************************
6924 reads or writes a SAMR_ENC_HASH structure.
6925 ********************************************************************/
6927 BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
6928 prs_struct *ps, int depth)
6933 prs_debug(ps, depth, desc, "samr_io_enc_hash");
6939 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
6941 if (hsh->ptr != 0) {
6942 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
6949 /*******************************************************************
6950 inits a SAMR_R_GET_DOM_PWINFO structure.
6951 ********************************************************************/
6953 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
6954 char *dest_host, char *user_name,
6955 char nt_newpass[516],
6956 uchar nt_oldhash[16],
6957 char lm_newpass[516],
6958 uchar lm_oldhash[16])
6960 int len_dest_host = strlen(dest_host);
6961 int len_user_name = strlen(user_name);
6963 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
6966 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
6967 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
6968 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
6969 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
6971 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
6972 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
6974 q_u->unknown = 0x01;
6976 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
6977 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
6980 /*******************************************************************
6981 reads or writes a structure.
6982 ********************************************************************/
6984 BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
6985 prs_struct *ps, int depth)
6990 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
6996 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
6999 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7001 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7006 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7008 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7011 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7013 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7016 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7019 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7021 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7027 /*******************************************************************
7028 inits a SAMR_R_CHGPASSWD_USER structure.
7029 ********************************************************************/
7031 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7033 DEBUG(5, ("init_r_chgpasswd_user\n"));
7035 r_u->status = status;
7038 /*******************************************************************
7039 reads or writes a structure.
7040 ********************************************************************/
7042 BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7043 prs_struct *ps, int depth)
7048 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7054 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7060 /*******************************************************************
7061 reads or writes a structure.
7062 ********************************************************************/
7064 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7065 POLICY_HND *domain_pol, uint16 switch_value)
7067 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7069 q_u->domain_pol = *domain_pol;
7070 q_u->switch_value = switch_value;
7073 /*******************************************************************
7074 reads or writes a structure.
7075 ********************************************************************/
7077 BOOL samr_io_q_unknown_2e(char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7078 prs_struct *ps, int depth)
7083 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7089 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7092 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7098 /*******************************************************************
7099 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7100 ********************************************************************/
7102 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7103 uint16 switch_value, SAM_UNK_CTR * ctr,
7106 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7109 r_u->switch_value = 0;
7110 r_u->status = status; /* return status */
7112 if (NT_STATUS_IS_OK(status)) {
7113 r_u->switch_value = switch_value;
7119 /*******************************************************************
7120 reads or writes a structure.
7121 ********************************************************************/
7123 BOOL samr_io_r_samr_unknown_2e(char *desc, SAMR_R_UNKNOWN_2E * r_u,
7124 prs_struct *ps, int depth)
7129 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7135 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7138 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7139 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7144 switch (r_u->switch_value) {
7146 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7150 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7154 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7158 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7162 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7166 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7170 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7174 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7175 r_u->switch_value));
7176 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7184 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7191 /*******************************************************************
7192 reads or writes a structure.
7193 ********************************************************************/
7195 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7196 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7198 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7200 q_u->domain_pol = *domain_pol;
7201 q_u->switch_value0 = switch_value;
7203 q_u->switch_value = switch_value;
7208 /*******************************************************************
7209 reads or writes a structure.
7210 ********************************************************************/
7212 BOOL samr_io_q_set_domain_info(char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7213 prs_struct *ps, int depth)
7218 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7224 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7227 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7230 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7236 if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL)
7239 switch (q_u->switch_value) {
7242 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7246 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7250 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7254 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7258 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7262 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7266 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7270 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7271 q_u->switch_value));
7278 /*******************************************************************
7279 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7280 ********************************************************************/
7282 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7284 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7286 r_u->status = status; /* return status */
7289 /*******************************************************************
7290 reads or writes a structure.
7291 ********************************************************************/
7293 BOOL samr_io_r_set_domain_info(char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7294 prs_struct *ps, int depth)
7299 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7305 if(!prs_ntstatus("status", ps, depth, &r_u->status))