2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Paul Ashton 1997-2000,
7 * Copyright (C) Elrond 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Jean François Micouleau 1998-2001,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include "rpc_parse.h"
32 #define DBGC_CLASS DBGC_RPC_PARSE
34 /*******************************************************************
35 inits a SAMR_Q_CLOSE_HND structure.
36 ********************************************************************/
38 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
40 DEBUG(5, ("init_samr_q_close_hnd\n"));
45 /*******************************************************************
46 reads or writes a structure.
47 ********************************************************************/
49 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
50 prs_struct *ps, int depth)
55 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
61 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
64 /*******************************************************************
65 reads or writes a structure.
66 ********************************************************************/
68 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
69 prs_struct *ps, int depth)
74 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
80 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
83 if(!prs_ntstatus("status", ps, depth, &r_u->status))
89 /*******************************************************************
90 inits a SAMR_Q_LOOKUP_DOMAIN structure.
91 ********************************************************************/
93 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
94 POLICY_HND *pol, char *dom_name)
96 DEBUG(5, ("init_samr_q_lookup_domain\n"));
98 q_u->connect_pol = *pol;
100 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
101 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
104 /*******************************************************************
105 reads or writes a structure.
106 ********************************************************************/
107 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
108 prs_struct *ps, int depth)
113 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
119 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
122 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
125 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
131 /*******************************************************************
132 inits a SAMR_R_LOOKUP_DOMAIN structure.
133 ********************************************************************/
135 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
136 DOM_SID *dom_sid, NTSTATUS status)
138 DEBUG(5, ("init_samr_r_lookup_domain\n"));
140 r_u->status = status;
142 if (NT_STATUS_IS_OK(status)) {
144 init_dom_sid2(&r_u->dom_sid, dom_sid);
148 /*******************************************************************
149 reads or writes a structure.
150 ********************************************************************/
152 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
153 prs_struct *ps, int depth)
158 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
164 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
167 if (r_u->ptr_sid != 0) {
168 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
174 if(!prs_ntstatus("status", ps, depth, &r_u->status))
180 /*******************************************************************
181 reads or writes a structure.
182 ********************************************************************/
184 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
186 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
188 q_u->dom_pol = *dom_pol;
189 init_dom_sid2(&q_u->sid, sid);
192 /*******************************************************************
193 reads or writes a structure.
194 ********************************************************************/
196 BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
197 prs_struct *ps, int depth)
202 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
208 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
211 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
220 /*******************************************************************
221 reads or writes a structure.
222 ********************************************************************/
224 BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
225 prs_struct *ps, int depth)
230 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
236 if(!prs_ntstatus("status", ps, depth, &r_u->status))
242 /*******************************************************************
243 reads or writes a structure.
244 ********************************************************************/
246 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
247 POLICY_HND *pol, uint32 flags,
250 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
254 init_dom_sid2(&q_u->dom_sid, sid);
257 /*******************************************************************
258 reads or writes a structure.
259 ********************************************************************/
261 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
262 prs_struct *ps, int depth)
267 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
273 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
276 if(!prs_uint32("flags", ps, depth, &q_u->flags))
279 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
285 /*******************************************************************
286 reads or writes a structure.
287 ********************************************************************/
289 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
290 prs_struct *ps, int depth)
295 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
301 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
304 if(!prs_ntstatus("status", ps, depth, &r_u->status))
310 /*******************************************************************
311 reads or writes a structure.
312 ********************************************************************/
314 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
315 POLICY_HND *user_pol)
317 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
319 q_u->user_pol = *user_pol;
322 /*******************************************************************
323 reads or writes a structure.
324 ********************************************************************/
326 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
327 prs_struct *ps, int depth)
332 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
338 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
341 /*******************************************************************
343 ********************************************************************/
345 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
347 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
349 r_u->unknown_0 = 0x0000;
353 * r_u->unknown_1 = 0x0015;
356 r_u->unknown_1 = 0x01D1;
357 r_u->unknown_1 = 0x0015;
359 r_u->unknown_2 = 0x00000000;
361 r_u->status = status;
364 /*******************************************************************
365 reads or writes a structure.
366 ********************************************************************/
368 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
369 prs_struct *ps, int depth)
374 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
380 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
382 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
384 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
386 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
393 /*******************************************************************
394 reads or writes a structure.
395 ********************************************************************/
397 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
398 prs_struct *ps, int depth)
403 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
409 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
412 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
415 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
422 /*******************************************************************
423 reads or writes a structure.
424 ********************************************************************/
426 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
427 POLICY_HND *user_pol, uint32 sec_info)
429 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
431 q_u->user_pol = *user_pol;
432 q_u->sec_info = sec_info;
436 /*******************************************************************
437 reads or writes a structure.
438 ********************************************************************/
440 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
441 prs_struct *ps, int depth)
446 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
452 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
455 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
461 /*******************************************************************
462 reads or writes a structure.
463 ********************************************************************/
465 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
466 POLICY_HND *domain_pol, uint16 switch_value)
468 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
470 q_u->domain_pol = *domain_pol;
471 q_u->switch_value = switch_value;
474 /*******************************************************************
475 reads or writes a structure.
476 ********************************************************************/
478 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
479 prs_struct *ps, int depth)
484 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
490 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
493 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
500 /*******************************************************************
502 ********************************************************************/
504 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
506 u_3->logout.low = nt_logout.low;
507 u_3->logout.high = nt_logout.high;
510 /*******************************************************************
511 reads or writes a structure.
512 ********************************************************************/
514 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
515 prs_struct *ps, int depth)
520 prs_debug(ps, depth, desc, "sam_io_unk_info3");
523 if(!smb_io_time("logout", &u_3->logout, ps, depth))
529 /*******************************************************************
531 ********************************************************************/
533 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
535 u_6->unknown_0 = 0x00000000;
537 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
540 /*******************************************************************
541 reads or writes a structure.
542 ********************************************************************/
544 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
545 prs_struct *ps, int depth)
550 prs_debug(ps, depth, desc, "sam_io_unk_info6");
553 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
555 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
557 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
563 /*******************************************************************
565 ********************************************************************/
567 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
569 u_7->server_role = server_role;
572 /*******************************************************************
573 reads or writes a structure.
574 ********************************************************************/
576 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
577 prs_struct *ps, int depth)
582 prs_debug(ps, depth, desc, "sam_io_unk_info7");
585 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
591 /*******************************************************************
593 ********************************************************************/
595 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
597 unix_to_nt_time(&u_8->domain_create_time, 0);
598 u_8->seq_num.low = seq_num;
599 u_8->seq_num.high = 0x0000;
602 /*******************************************************************
603 reads or writes a structure.
604 ********************************************************************/
606 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
607 prs_struct *ps, int depth)
612 prs_debug(ps, depth, desc, "sam_io_unk_info8");
615 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
618 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
625 /*******************************************************************
627 ********************************************************************/
629 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
631 u_12->duration.low = nt_lock_duration.low;
632 u_12->duration.high = nt_lock_duration.high;
633 u_12->reset_count.low = nt_reset_time.low;
634 u_12->reset_count.high = nt_reset_time.high;
636 u_12->bad_attempt_lockout = lockout;
639 /*******************************************************************
640 reads or writes a structure.
641 ********************************************************************/
643 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
644 prs_struct *ps, int depth)
649 prs_debug(ps, depth, desc, "sam_io_unk_info12");
652 if(!smb_io_time("duration", &u_12->duration, ps, depth))
654 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
656 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
662 /*******************************************************************
664 ********************************************************************/
666 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
668 init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE);
669 init_uni_hdr(&u_5->hdr_server, &u_5->uni_server);
672 /*******************************************************************
673 reads or writes a structure.
674 ********************************************************************/
676 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
677 prs_struct *ps, int depth)
682 prs_debug(ps, depth, desc, "sam_io_unk_info5");
685 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
688 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
694 /*******************************************************************
696 ********************************************************************/
698 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
699 const char *comment, const char *domain, const char *server,
700 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
702 u_2->logout.low = nt_logout.low;
703 u_2->logout.high = nt_logout.high;
705 u_2->seq_num.low = seq_num;
706 u_2->seq_num.high = 0x00000000;
709 u_2->unknown_4 = 0x00000001;
710 u_2->server_role = server_role;
711 u_2->unknown_6 = 0x00000001;
712 u_2->num_domain_usrs = num_users;
713 u_2->num_domain_grps = num_groups;
714 u_2->num_local_grps = num_alias;
716 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
718 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
719 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
720 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
721 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
722 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
723 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
726 /*******************************************************************
727 reads or writes a structure.
728 ********************************************************************/
730 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
731 prs_struct *ps, int depth)
736 prs_debug(ps, depth, desc, "sam_io_unk_info2");
739 if(!smb_io_time("logout", &u_2->logout, ps, depth))
741 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
743 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
745 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
748 /* put all the data in here, at the moment, including what the above
749 pointer is referring to
752 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
755 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
757 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
759 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
761 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
763 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
765 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
768 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
770 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
772 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
778 /*******************************************************************
780 ********************************************************************/
782 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
783 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
785 u_1->min_length_password = min_pass_len;
786 u_1->password_history = pass_hist;
789 /* password never expire */
790 u_1->expire.high = nt_expire.high;
791 u_1->expire.low = nt_expire.low;
793 /* can change the password now */
794 u_1->min_passwordage.high = nt_min_age.high;
795 u_1->min_passwordage.low = nt_min_age.low;
799 /*******************************************************************
800 reads or writes a structure.
801 ********************************************************************/
803 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
804 prs_struct *ps, int depth)
809 prs_debug(ps, depth, desc, "sam_io_unk_info1");
812 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
814 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
816 if(!prs_uint32("flag", ps, depth, &u_1->flag))
818 if(!smb_io_time("expire", &u_1->expire, ps, depth))
820 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
826 /*******************************************************************
827 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
828 ********************************************************************/
830 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
831 uint16 switch_value, SAM_UNK_CTR * ctr,
834 DEBUG(5, ("init_samr_r_query_dom_info\n"));
837 r_u->switch_value = 0;
838 r_u->status = status; /* return status */
840 if (NT_STATUS_IS_OK(status)) {
841 r_u->switch_value = switch_value;
847 /*******************************************************************
848 reads or writes a structure.
849 ********************************************************************/
851 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
852 prs_struct *ps, int depth)
857 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
863 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
866 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
867 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
872 switch (r_u->switch_value) {
874 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
878 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
882 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
886 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
890 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
894 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
898 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
902 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
906 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
908 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
916 if(!prs_ntstatus("status", ps, depth, &r_u->status))
922 /*******************************************************************
923 reads or writes a SAMR_R_SET_SEC_OBJ structure.
924 ********************************************************************/
926 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
927 prs_struct *ps, int depth)
932 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
938 if(!prs_ntstatus("status", ps, depth, &r_u->status))
944 /*******************************************************************
945 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
946 ********************************************************************/
948 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
949 prs_struct *ps, int depth)
954 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
960 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
963 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
967 if(!prs_ntstatus("status", ps, depth, &r_u->status))
973 /*******************************************************************
974 reads or writes a SAM_STR1 structure.
975 ********************************************************************/
977 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
978 uint32 name_buf, uint32 desc_buf,
979 prs_struct *ps, int depth)
984 prs_debug(ps, depth, desc, "sam_io_sam_str1");
989 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
992 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
995 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1001 /*******************************************************************
1002 inits a SAM_ENTRY1 structure.
1003 ********************************************************************/
1005 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1006 UNISTR2 *sam_name, UNISTR2 *sam_full,
1007 UNISTR2 *sam_desc, uint32 rid_user,
1010 DEBUG(5, ("init_sam_entry1\n"));
1014 sam->user_idx = user_idx;
1015 sam->rid_user = rid_user;
1016 sam->acb_info = acb_info;
1018 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1019 init_uni_hdr(&sam->hdr_user_name, sam_full);
1020 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1023 /*******************************************************************
1024 reads or writes a SAM_ENTRY1 structure.
1025 ********************************************************************/
1027 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1028 prs_struct *ps, int depth)
1033 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1039 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1042 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1044 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1050 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1052 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1054 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1060 /*******************************************************************
1061 reads or writes a SAM_STR2 structure.
1062 ********************************************************************/
1064 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1065 uint32 desc_buf, prs_struct *ps, int depth)
1070 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1076 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1078 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1084 /*******************************************************************
1085 inits a SAM_ENTRY2 structure.
1086 ********************************************************************/
1087 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1088 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1089 uint32 rid_user, uint16 acb_info)
1091 DEBUG(5, ("init_sam_entry2\n"));
1093 sam->user_idx = user_idx;
1094 sam->rid_user = rid_user;
1095 sam->acb_info = acb_info;
1097 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1098 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1101 /*******************************************************************
1102 reads or writes a SAM_ENTRY2 structure.
1103 ********************************************************************/
1105 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1106 prs_struct *ps, int depth)
1111 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1117 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1120 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1122 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1128 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1130 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1136 /*******************************************************************
1137 reads or writes a SAM_STR3 structure.
1138 ********************************************************************/
1140 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1141 uint32 desc_buf, prs_struct *ps, int depth)
1146 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1152 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1154 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1160 /*******************************************************************
1161 inits a SAM_ENTRY3 structure.
1162 ********************************************************************/
1164 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1165 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1168 DEBUG(5, ("init_sam_entry3\n"));
1170 sam->grp_idx = grp_idx;
1171 sam->rid_grp = rid_grp;
1172 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1174 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1175 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1178 /*******************************************************************
1179 reads or writes a SAM_ENTRY3 structure.
1180 ********************************************************************/
1182 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1183 prs_struct *ps, int depth)
1188 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1194 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1197 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1199 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1202 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1204 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1210 /*******************************************************************
1211 inits a SAM_ENTRY4 structure.
1212 ********************************************************************/
1214 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1215 uint32 len_acct_name)
1217 DEBUG(5, ("init_sam_entry4\n"));
1219 sam->user_idx = user_idx;
1220 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1223 /*******************************************************************
1224 reads or writes a SAM_ENTRY4 structure.
1225 ********************************************************************/
1227 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1228 prs_struct *ps, int depth)
1233 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1239 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1241 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1247 /*******************************************************************
1248 inits a SAM_ENTRY5 structure.
1249 ********************************************************************/
1251 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1252 uint32 len_grp_name)
1254 DEBUG(5, ("init_sam_entry5\n"));
1256 sam->grp_idx = grp_idx;
1257 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1261 /*******************************************************************
1262 reads or writes a SAM_ENTRY5 structure.
1263 ********************************************************************/
1265 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1266 prs_struct *ps, int depth)
1271 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1277 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1279 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1285 /*******************************************************************
1286 inits a SAM_ENTRY structure.
1287 ********************************************************************/
1289 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1291 DEBUG(10, ("init_sam_entry: %d\n", rid));
1294 init_uni_hdr(&sam->hdr_name, uni2);
1297 /*******************************************************************
1298 reads or writes a SAM_ENTRY structure.
1299 ********************************************************************/
1301 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1302 prs_struct *ps, int depth)
1307 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1312 if(!prs_uint32("rid", ps, depth, &sam->rid))
1314 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1320 /*******************************************************************
1321 inits a SAMR_Q_ENUM_DOM_USERS structure.
1322 ********************************************************************/
1324 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1326 uint16 acb_mask, uint16 unk_1, uint32 size)
1328 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1332 q_e->start_idx = start_idx; /* zero indicates lots */
1333 q_e->acb_mask = acb_mask;
1334 q_e->unknown_1 = unk_1;
1335 q_e->max_size = size;
1338 /*******************************************************************
1339 reads or writes a structure.
1340 ********************************************************************/
1342 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1343 prs_struct *ps, int depth)
1348 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1354 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1357 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1359 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1361 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1364 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1371 /*******************************************************************
1372 inits a SAMR_R_ENUM_DOM_USERS structure.
1373 ********************************************************************/
1375 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1376 uint32 next_idx, uint32 num_sam_entries)
1378 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1380 r_u->next_idx = next_idx;
1382 if (num_sam_entries != 0) {
1383 r_u->ptr_entries1 = 1;
1384 r_u->ptr_entries2 = 1;
1385 r_u->num_entries2 = num_sam_entries;
1386 r_u->num_entries3 = num_sam_entries;
1388 r_u->num_entries4 = num_sam_entries;
1390 r_u->ptr_entries1 = 0;
1391 r_u->num_entries2 = num_sam_entries;
1392 r_u->ptr_entries2 = 1;
1396 /*******************************************************************
1397 reads or writes a structure.
1398 ********************************************************************/
1400 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1401 prs_struct *ps, int depth)
1408 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1414 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1416 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1419 if (r_u->ptr_entries1 != 0) {
1420 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1422 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1424 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1427 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1428 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1429 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1432 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1433 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1434 r_u->num_entries4 = 0;
1435 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1439 for (i = 0; i < r_u->num_entries2; i++) {
1440 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1444 for (i = 0; i < r_u->num_entries2; i++) {
1445 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1454 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1456 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1462 /*******************************************************************
1463 inits a SAMR_Q_QUERY_DISPINFO structure.
1464 ********************************************************************/
1466 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1467 uint16 switch_level, uint32 start_idx,
1468 uint32 max_entries, uint32 max_size)
1470 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1472 q_e->domain_pol = *pol;
1474 q_e->switch_level = switch_level;
1476 q_e->start_idx = start_idx;
1477 q_e->max_entries = max_entries;
1478 q_e->max_size = max_size;
1481 /*******************************************************************
1482 reads or writes a structure.
1483 ********************************************************************/
1485 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1486 prs_struct *ps, int depth)
1491 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1497 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1500 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1505 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1507 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1509 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1515 /*******************************************************************
1516 inits a SAM_DISPINFO_1 structure.
1517 ********************************************************************/
1519 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1520 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1521 DOM_SID *domain_sid)
1525 SAM_ACCOUNT *pwd = NULL;
1528 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1531 return NT_STATUS_OK;
1533 sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1535 return NT_STATUS_NO_MEMORY;
1537 sam->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1539 return NT_STATUS_NO_MEMORY;
1541 ZERO_STRUCTP(sam->sam);
1542 ZERO_STRUCTP(sam->str);
1544 for (i = 0; i < num_entries ; i++) {
1545 const char *username;
1546 const char *fullname;
1547 const char *acct_desc;
1549 const DOM_SID *user_sid;
1550 fstring user_sid_string, domain_sid_string;
1552 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1554 pwd=&disp_user_info[i+start_idx];
1556 username = pdb_get_username(pwd);
1557 fullname = pdb_get_fullname(pwd);
1558 acct_desc = pdb_get_acct_desc(pwd);
1569 user_sid = pdb_get_user_sid(pwd);
1571 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1572 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1573 "the domain sid %s. Failing operation.\n",
1575 sid_to_string(user_sid_string, user_sid),
1576 sid_to_string(domain_sid_string, domain_sid)));
1577 return NT_STATUS_UNSUCCESSFUL;
1580 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), UNI_FLAGS_NONE);
1581 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), UNI_FLAGS_NONE);
1582 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), UNI_FLAGS_NONE);
1584 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1585 &sam->str[i].uni_acct_name, &sam->str[i].uni_full_name, &sam->str[i].uni_acct_desc,
1586 user_rid, pdb_get_acct_ctrl(pwd));
1590 return NT_STATUS_OK;
1593 /*******************************************************************
1594 reads or writes a structure.
1595 ********************************************************************/
1597 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1599 prs_struct *ps, int depth)
1603 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1609 if (UNMARSHALLING(ps) && num_entries > 0) {
1611 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1612 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1616 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1617 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1622 for (i = 0; i < num_entries; i++) {
1623 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1627 for (i = 0; i < num_entries; i++) {
1628 if(!sam_io_sam_str1("", &sam->str[i],
1629 sam->sam[i].hdr_acct_name.buffer,
1630 sam->sam[i].hdr_user_name.buffer,
1631 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1638 /*******************************************************************
1639 inits a SAM_DISPINFO_2 structure.
1640 ********************************************************************/
1642 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1643 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1644 DOM_SID *domain_sid )
1648 SAM_ACCOUNT *pwd = NULL;
1651 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1654 return NT_STATUS_OK;
1656 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries)))
1657 return NT_STATUS_NO_MEMORY;
1659 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries)))
1660 return NT_STATUS_NO_MEMORY;
1662 ZERO_STRUCTP(sam->sam);
1663 ZERO_STRUCTP(sam->str);
1665 for (i = 0; i < num_entries; i++) {
1667 const DOM_SID *user_sid;
1668 const char *username;
1669 const char *acct_desc;
1670 fstring user_sid_string, domain_sid_string;
1672 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1673 pwd=&disp_user_info[i+start_idx];
1675 username = pdb_get_username(pwd);
1676 acct_desc = pdb_get_acct_desc(pwd);
1677 user_sid = pdb_get_user_sid(pwd);
1679 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1680 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1681 "the domain sid %s. Failing operation.\n",
1683 sid_to_string(user_sid_string, user_sid),
1684 sid_to_string(domain_sid_string, domain_sid)));
1685 return NT_STATUS_UNSUCCESSFUL;
1688 init_unistr2(&sam->str[i].uni_srv_name, username, UNI_FLAGS_NONE);
1689 init_unistr2(&sam->str[i].uni_srv_desc, acct_desc, UNI_FLAGS_NONE);
1691 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1692 &sam->str[i].uni_srv_name, &sam->str[i].uni_srv_desc,
1693 user_rid, pdb_get_acct_ctrl(pwd));
1696 return NT_STATUS_OK;
1699 /*******************************************************************
1700 reads or writes a structure.
1701 ********************************************************************/
1703 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1705 prs_struct *ps, int depth)
1712 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1718 if (UNMARSHALLING(ps) && num_entries > 0) {
1720 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1721 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1725 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1726 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1731 for (i = 0; i < num_entries; i++) {
1732 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1736 for (i = 0; i < num_entries; i++) {
1737 if(!sam_io_sam_str2("", &sam->str[i],
1738 sam->sam[i].hdr_srv_name.buffer,
1739 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1746 /*******************************************************************
1747 inits a SAM_DISPINFO_3 structure.
1748 ********************************************************************/
1750 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1751 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1757 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1760 return NT_STATUS_OK;
1762 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1763 return NT_STATUS_NO_MEMORY;
1765 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1766 return NT_STATUS_NO_MEMORY;
1768 ZERO_STRUCTP(sam->sam);
1769 ZERO_STRUCTP(sam->str);
1771 for (i = 0; i < num_entries; i++) {
1772 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1774 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1776 init_unistr2(&sam->str[i].uni_grp_name, grp->name, UNI_FLAGS_NONE);
1777 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, UNI_FLAGS_NONE);
1779 init_sam_entry3(&sam->sam[i], start_idx + i + 1, &sam->str[i].uni_grp_name,
1780 &sam->str[i].uni_grp_desc, grp->rid);
1783 return NT_STATUS_OK;
1786 /*******************************************************************
1787 reads or writes a structure.
1788 ********************************************************************/
1790 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1792 prs_struct *ps, int depth)
1799 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1805 if (UNMARSHALLING(ps) && num_entries > 0) {
1807 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1808 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1812 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1813 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1818 for (i = 0; i < num_entries; i++) {
1819 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1823 for (i = 0; i < num_entries; i++) {
1824 if(!sam_io_sam_str3("", &sam->str[i],
1825 sam->sam[i].hdr_grp_name.buffer,
1826 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1833 /*******************************************************************
1834 inits a SAM_DISPINFO_4 structure.
1835 ********************************************************************/
1837 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1838 uint32 start_idx, SAM_ACCOUNT *disp_user_info)
1840 uint32 len_sam_name;
1843 SAM_ACCOUNT *pwd = NULL;
1846 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1849 return NT_STATUS_OK;
1851 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries)))
1852 return NT_STATUS_NO_MEMORY;
1854 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries)))
1855 return NT_STATUS_NO_MEMORY;
1857 ZERO_STRUCTP(sam->sam);
1858 ZERO_STRUCTP(sam->str);
1860 for (i = 0; i < num_entries; i++) {
1861 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1862 pwd=&disp_user_info[i+start_idx];
1864 len_sam_name = strlen(pdb_get_username(pwd));
1866 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1868 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1871 return NT_STATUS_OK;
1874 /*******************************************************************
1875 reads or writes a structure.
1876 ********************************************************************/
1878 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1880 prs_struct *ps, int depth)
1887 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1893 if (UNMARSHALLING(ps) && num_entries > 0) {
1895 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1896 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1900 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1901 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1906 for (i = 0; i < num_entries; i++) {
1907 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1911 for (i = 0; i < num_entries; i++) {
1912 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1913 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1920 /*******************************************************************
1921 inits a SAM_DISPINFO_5 structure.
1922 ********************************************************************/
1924 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1925 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1927 uint32 len_sam_name;
1932 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1935 return NT_STATUS_OK;
1937 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1938 return NT_STATUS_NO_MEMORY;
1940 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1941 return NT_STATUS_NO_MEMORY;
1943 ZERO_STRUCTP(sam->sam);
1944 ZERO_STRUCTP(sam->str);
1946 for (i = 0; i < num_entries; i++) {
1947 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1949 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1951 len_sam_name = strlen(grp->name);
1953 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1954 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1957 return NT_STATUS_OK;
1960 /*******************************************************************
1961 reads or writes a structure.
1962 ********************************************************************/
1964 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1966 prs_struct *ps, int depth)
1973 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1979 if (UNMARSHALLING(ps) && num_entries > 0) {
1981 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1982 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1986 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1987 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1992 for (i = 0; i < num_entries; i++) {
1993 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1997 for (i = 0; i < num_entries; i++) {
1998 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1999 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2006 /*******************************************************************
2007 inits a SAMR_R_QUERY_DISPINFO structure.
2008 ********************************************************************/
2010 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2011 uint32 num_entries, uint32 total_size, uint32 data_size,
2012 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2015 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2017 r_u->total_size = total_size;
2019 r_u->data_size = data_size;
2021 r_u->switch_level = switch_level;
2022 r_u->num_entries = num_entries;
2025 r_u->ptr_entries = 0;
2027 r_u->ptr_entries = 1;
2029 r_u->num_entries2 = num_entries;
2032 r_u->status = status;
2035 /*******************************************************************
2036 reads or writes a structure.
2037 ********************************************************************/
2039 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2040 prs_struct *ps, int depth)
2045 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2051 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2053 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2055 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2060 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2062 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2065 if (r_u->ptr_entries==0) {
2068 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2074 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2077 switch (r_u->switch_level) {
2079 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2080 r_u->num_entries, ps, depth))
2084 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2085 r_u->num_entries, ps, depth))
2089 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2090 r_u->num_entries, ps, depth))
2094 if(!sam_io_sam_dispinfo_4("user list",
2095 r_u->ctr->sam.info4,
2096 r_u->num_entries, ps, depth))
2100 if(!sam_io_sam_dispinfo_5("group list",
2101 r_u->ctr->sam.info5,
2102 r_u->num_entries, ps, depth))
2106 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2112 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2118 /*******************************************************************
2119 inits a SAMR_Q_OPEN_GROUP structure.
2120 ********************************************************************/
2122 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2124 uint32 access_mask, uint32 rid)
2126 DEBUG(5, ("init_samr_q_open_group\n"));
2128 q_c->domain_pol = *hnd;
2129 q_c->access_mask = access_mask;
2130 q_c->rid_group = rid;
2133 /*******************************************************************
2134 reads or writes a structure.
2135 ********************************************************************/
2137 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2138 prs_struct *ps, int depth)
2143 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2149 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2152 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2154 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2160 /*******************************************************************
2161 reads or writes a structure.
2162 ********************************************************************/
2164 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2165 prs_struct *ps, int depth)
2170 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2176 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2179 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2185 /*******************************************************************
2186 inits a GROUP_INFO1 structure.
2187 ********************************************************************/
2189 void init_samr_group_info1(GROUP_INFO1 * gr1,
2190 char *acct_name, char *acct_desc,
2193 DEBUG(5, ("init_samr_group_info1\n"));
2195 gr1->unknown_1 = 0x3;
2196 gr1->num_members = num_members;
2198 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2199 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2200 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2201 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2204 /*******************************************************************
2205 reads or writes a structure.
2206 ********************************************************************/
2208 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2209 prs_struct *ps, int depth)
2216 prs_debug(ps, depth, desc, "samr_io_group_info1");
2219 if(!prs_uint16("level", ps, depth, &dummy))
2225 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2228 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2230 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2233 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2236 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2237 gr1->hdr_acct_name.buffer, ps, depth))
2240 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2241 gr1->hdr_acct_desc.buffer, ps, depth))
2247 /*******************************************************************
2248 inits a GROUP_INFO2 structure.
2249 ********************************************************************/
2251 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2253 DEBUG(5, ("init_samr_group_info2\n"));
2256 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2257 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2260 /*******************************************************************
2261 reads or writes a structure.
2262 ********************************************************************/
2264 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2269 prs_debug(ps, depth, desc, "samr_io_group_info2");
2272 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2275 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2277 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2278 gr2->hdr_acct_name.buffer, ps, depth))
2284 /*******************************************************************
2285 inits a GROUP_INFO3 structure.
2286 ********************************************************************/
2288 void init_samr_group_info3(GROUP_INFO3 *gr3)
2290 DEBUG(5, ("init_samr_group_info3\n"));
2292 gr3->unknown_1 = 0x3;
2295 /*******************************************************************
2296 reads or writes a structure.
2297 ********************************************************************/
2299 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2304 prs_debug(ps, depth, desc, "samr_io_group_info3");
2310 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2316 /*******************************************************************
2317 inits a GROUP_INFO4 structure.
2318 ********************************************************************/
2320 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2322 DEBUG(5, ("init_samr_group_info4\n"));
2325 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2326 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2329 /*******************************************************************
2330 reads or writes a structure.
2331 ********************************************************************/
2333 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2334 prs_struct *ps, int depth)
2339 prs_debug(ps, depth, desc, "samr_io_group_info4");
2342 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2344 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2346 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2347 gr4->hdr_acct_desc.buffer, ps, depth))
2353 /*******************************************************************
2354 reads or writes a structure.
2355 ********************************************************************/
2357 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2358 prs_struct *ps, int depth)
2360 if (UNMARSHALLING(ps))
2361 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2366 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2369 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2372 switch ((*ctr)->switch_value1) {
2374 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2378 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2382 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2386 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2390 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2397 /*******************************************************************
2398 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2399 ********************************************************************/
2401 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2402 POLICY_HND *pol, const char *acct_desc,
2405 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2409 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2410 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2412 q_e->access_mask = access_mask;
2415 /*******************************************************************
2416 reads or writes a structure.
2417 ********************************************************************/
2419 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2420 prs_struct *ps, int depth)
2425 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2431 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2434 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2436 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2437 q_e->hdr_acct_desc.buffer, ps, depth))
2442 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2448 /*******************************************************************
2449 reads or writes a structure.
2450 ********************************************************************/
2452 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2453 prs_struct *ps, int depth)
2458 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2464 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2467 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2469 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2475 /*******************************************************************
2476 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2477 ********************************************************************/
2479 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2482 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2484 q_c->group_pol = *hnd;
2487 /*******************************************************************
2488 reads or writes a structure.
2489 ********************************************************************/
2491 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2492 prs_struct *ps, int depth)
2497 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2503 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2509 /*******************************************************************
2510 reads or writes a structure.
2511 ********************************************************************/
2513 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2514 prs_struct *ps, int depth)
2519 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2525 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2528 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2534 /*******************************************************************
2535 inits a SAMR_Q_DEL_GROUPMEM structure.
2536 ********************************************************************/
2538 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2539 POLICY_HND *pol, uint32 rid)
2541 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2547 /*******************************************************************
2548 reads or writes a structure.
2549 ********************************************************************/
2551 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2552 prs_struct *ps, int depth)
2557 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2563 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2566 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2572 /*******************************************************************
2573 inits a SAMR_R_DEL_GROUPMEM structure.
2574 ********************************************************************/
2576 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2579 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2581 r_u->status = status;
2584 /*******************************************************************
2585 reads or writes a structure.
2586 ********************************************************************/
2588 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2589 prs_struct *ps, int depth)
2594 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2600 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2606 /*******************************************************************
2607 inits a SAMR_Q_ADD_GROUPMEM structure.
2608 ********************************************************************/
2610 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2611 POLICY_HND *pol, uint32 rid)
2613 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2617 q_e->unknown = 0x0005;
2620 /*******************************************************************
2621 reads or writes a structure.
2622 ********************************************************************/
2624 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2625 prs_struct *ps, int depth)
2630 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2636 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2639 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2641 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2647 /*******************************************************************
2648 inits a SAMR_R_ADD_GROUPMEM structure.
2649 ********************************************************************/
2651 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2654 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2656 r_u->status = status;
2659 /*******************************************************************
2660 reads or writes a structure.
2661 ********************************************************************/
2663 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2664 prs_struct *ps, int depth)
2669 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2675 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2681 /*******************************************************************
2682 inits a SAMR_Q_SET_GROUPINFO structure.
2683 ********************************************************************/
2685 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2686 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2688 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2694 /*******************************************************************
2695 reads or writes a structure.
2696 ********************************************************************/
2698 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2699 prs_struct *ps, int depth)
2704 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2710 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2713 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2719 /*******************************************************************
2720 inits a SAMR_R_SET_GROUPINFO structure.
2721 ********************************************************************/
2723 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2725 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2727 r_u->status = status;
2730 /*******************************************************************
2731 reads or writes a structure.
2732 ********************************************************************/
2734 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2735 prs_struct *ps, int depth)
2740 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2746 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2752 /*******************************************************************
2753 inits a SAMR_Q_QUERY_GROUPINFO structure.
2754 ********************************************************************/
2756 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2757 POLICY_HND *pol, uint16 switch_level)
2759 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2763 q_e->switch_level = switch_level;
2766 /*******************************************************************
2767 reads or writes a structure.
2768 ********************************************************************/
2770 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2771 prs_struct *ps, int depth)
2776 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2782 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2785 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2791 /*******************************************************************
2792 inits a SAMR_R_QUERY_GROUPINFO structure.
2793 ********************************************************************/
2795 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2796 GROUP_INFO_CTR * ctr, NTSTATUS status)
2798 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2800 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2802 r_u->status = status;
2805 /*******************************************************************
2806 reads or writes a structure.
2807 ********************************************************************/
2809 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2810 prs_struct *ps, int depth)
2815 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2821 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2824 if (r_u->ptr != 0) {
2825 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2831 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2837 /*******************************************************************
2838 inits a SAMR_Q_QUERY_GROUPMEM structure.
2839 ********************************************************************/
2841 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2843 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2845 q_c->group_pol = *hnd;
2848 /*******************************************************************
2849 reads or writes a structure.
2850 ********************************************************************/
2852 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2853 prs_struct *ps, int depth)
2858 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2864 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2870 /*******************************************************************
2871 inits a SAMR_R_QUERY_GROUPMEM structure.
2872 ********************************************************************/
2874 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2875 uint32 num_entries, uint32 *rid,
2876 uint32 *attr, NTSTATUS status)
2878 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2880 if (NT_STATUS_IS_OK(status)) {
2882 r_u->num_entries = num_entries;
2884 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2885 r_u->ptr_rids = rid != NULL ? 1 : 0;
2887 r_u->num_rids = num_entries;
2890 r_u->num_attrs = num_entries;
2894 r_u->num_entries = 0;
2897 r_u->status = status;
2900 /*******************************************************************
2901 reads or writes a structure.
2902 ********************************************************************/
2904 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2905 prs_struct *ps, int depth)
2912 if (UNMARSHALLING(ps))
2915 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2921 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2923 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2926 if (r_u->ptr != 0) {
2927 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2929 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2932 if (r_u->ptr_rids != 0) {
2933 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2935 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2936 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2937 if (r_u->rid == NULL)
2941 for (i = 0; i < r_u->num_rids; i++) {
2942 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2947 if (r_u->ptr_attrs != 0) {
2948 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2951 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2952 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2953 if (r_u->attr == NULL)
2957 for (i = 0; i < r_u->num_attrs; i++) {
2958 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2964 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2970 /*******************************************************************
2971 inits a SAMR_Q_QUERY_USERGROUPS structure.
2972 ********************************************************************/
2974 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2977 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2982 /*******************************************************************
2983 reads or writes a structure.
2984 ********************************************************************/
2986 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2987 prs_struct *ps, int depth)
2992 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2998 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3004 /*******************************************************************
3005 inits a SAMR_R_QUERY_USERGROUPS structure.
3006 ********************************************************************/
3008 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3009 uint32 num_gids, DOM_GID * gid,
3012 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3014 if (NT_STATUS_IS_OK(status)) {
3016 r_u->num_entries = num_gids;
3017 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3018 r_u->num_entries2 = num_gids;
3023 r_u->num_entries = 0;
3028 r_u->status = status;
3031 /*******************************************************************
3032 reads or writes a structure.
3033 ********************************************************************/
3035 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3036 prs_struct *ps, int depth)
3042 prs_debug(ps, depth, desc, "samr_io_gids");
3048 if(!prs_uint32("num_gids", ps, depth, num_gids))
3051 if ((*num_gids) != 0) {
3052 if (UNMARSHALLING(ps)) {
3053 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3056 if ((*gid) == NULL) {
3060 for (i = 0; i < (*num_gids); i++) {
3061 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3069 /*******************************************************************
3070 reads or writes a structure.
3071 ********************************************************************/
3073 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3074 prs_struct *ps, int depth)
3079 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3085 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3088 if (r_u->ptr_0 != 0) {
3089 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3091 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3094 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3095 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3102 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3108 /*******************************************************************
3109 inits a SAMR_Q_ENUM_DOMAINS structure.
3110 ********************************************************************/
3112 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3114 uint32 start_idx, uint32 size)
3116 DEBUG(5, ("init_samr_q_enum_domains\n"));
3120 q_e->start_idx = start_idx;
3121 q_e->max_size = size;
3124 /*******************************************************************
3125 reads or writes a structure.
3126 ********************************************************************/
3128 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3129 prs_struct *ps, int depth)
3134 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3140 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3143 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3145 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3151 /*******************************************************************
3152 inits a SAMR_R_ENUM_DOMAINS structure.
3153 ********************************************************************/
3155 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3156 uint32 next_idx, uint32 num_sam_entries)
3158 DEBUG(5, ("init_samr_r_enum_domains\n"));
3160 r_u->next_idx = next_idx;
3162 if (num_sam_entries != 0) {
3163 r_u->ptr_entries1 = 1;
3164 r_u->ptr_entries2 = 1;
3165 r_u->num_entries2 = num_sam_entries;
3166 r_u->num_entries3 = num_sam_entries;
3168 r_u->num_entries4 = num_sam_entries;
3170 r_u->ptr_entries1 = 0;
3171 r_u->num_entries2 = num_sam_entries;
3172 r_u->ptr_entries2 = 1;
3176 /*******************************************************************
3177 reads or writes a structure.
3178 ********************************************************************/
3180 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3181 prs_struct *ps, int depth)
3188 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3194 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3196 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3199 if (r_u->ptr_entries1 != 0) {
3200 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3202 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3204 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3207 if (UNMARSHALLING(ps)) {
3208 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3209 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3212 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3213 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3214 r_u->num_entries4 = 0;
3215 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3219 for (i = 0; i < r_u->num_entries2; i++) {
3221 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3222 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3226 for (i = 0; i < r_u->num_entries2; i++) {
3228 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3229 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3230 r_u->sam[i].hdr_name.buffer, ps,
3239 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3241 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3247 /*******************************************************************
3248 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3249 ********************************************************************/
3251 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3253 uint32 start_idx, uint32 size)
3255 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3259 q_e->start_idx = start_idx;
3260 q_e->max_size = size;
3263 /*******************************************************************
3264 reads or writes a structure.
3265 ********************************************************************/
3267 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3268 prs_struct *ps, int depth)
3273 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3279 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3282 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3284 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3290 /*******************************************************************
3291 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3292 ********************************************************************/
3294 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3295 uint32 next_idx, uint32 num_sam_entries)
3297 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3299 r_u->next_idx = next_idx;
3301 if (num_sam_entries != 0) {
3302 r_u->ptr_entries1 = 1;
3303 r_u->ptr_entries2 = 1;
3304 r_u->num_entries2 = num_sam_entries;
3305 r_u->num_entries3 = num_sam_entries;
3307 r_u->num_entries4 = num_sam_entries;
3309 r_u->ptr_entries1 = 0;
3310 r_u->num_entries2 = num_sam_entries;
3311 r_u->ptr_entries2 = 1;
3315 /*******************************************************************
3316 reads or writes a structure.
3317 ********************************************************************/
3319 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3320 prs_struct *ps, int depth)
3327 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3333 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3335 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3338 if (r_u->ptr_entries1 != 0) {
3339 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3341 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3343 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3346 if (UNMARSHALLING(ps)) {
3347 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3348 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3351 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3353 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3354 r_u->num_entries4 = 0;
3355 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3359 for (i = 0; i < r_u->num_entries2; i++) {
3360 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3364 for (i = 0; i < r_u->num_entries2; i++) {
3365 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3366 r_u->sam[i].hdr_name.buffer, ps, depth))
3373 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3375 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3381 /*******************************************************************
3382 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3383 ********************************************************************/
3385 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3386 POLICY_HND *pol, uint32 start_idx,
3389 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3393 q_e->start_idx = start_idx;
3394 q_e->max_size = size;
3398 /*******************************************************************
3399 reads or writes a structure.
3400 ********************************************************************/
3402 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3403 prs_struct *ps, int depth)
3408 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3414 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3417 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3419 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3425 /*******************************************************************
3426 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3427 ********************************************************************/
3429 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3431 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3433 r_u->next_idx = next_idx;
3435 if (num_sam_entries != 0) {
3436 r_u->ptr_entries1 = 1;
3437 r_u->ptr_entries2 = 1;
3438 r_u->num_entries2 = num_sam_entries;
3439 r_u->num_entries3 = num_sam_entries;
3441 r_u->num_entries4 = num_sam_entries;
3443 r_u->ptr_entries1 = 0;
3444 r_u->num_entries2 = num_sam_entries;
3445 r_u->ptr_entries2 = 1;
3449 /*******************************************************************
3450 reads or writes a structure.
3451 ********************************************************************/
3453 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3454 prs_struct *ps, int depth)
3461 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3467 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3469 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3472 if (r_u->ptr_entries1 != 0) {
3473 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3475 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3477 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3480 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3481 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3482 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3485 if (r_u->num_entries2 != 0 &&
3486 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3487 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3488 r_u->num_entries4 = 0;
3489 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3493 for (i = 0; i < r_u->num_entries2; i++) {
3494 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3498 for (i = 0; i < r_u->num_entries2; i++) {
3499 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3500 r_u->sam[i].hdr_name.buffer, ps,
3508 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3510 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3516 /*******************************************************************
3517 inits a ALIAS_INFO1 structure.
3518 ********************************************************************/
3520 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3522 DEBUG(5, ("init_samr_alias_info1\n"));
3524 init_unistr2(&al1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
3525 init_uni_hdr(&al1->hdr_acct_name, &al1->uni_acct_name);
3527 al1->num_member=num_member;
3529 init_unistr2(&al1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3530 init_uni_hdr(&al1->hdr_acct_desc, &al1->uni_acct_name);
3533 /*******************************************************************
3534 reads or writes a structure.
3535 ********************************************************************/
3537 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3538 prs_struct *ps, int depth)
3543 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3549 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3551 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3553 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3556 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3557 al1->hdr_acct_name.buffer, ps, depth))
3563 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3564 al1->hdr_acct_desc.buffer, ps, depth))
3570 /*******************************************************************
3571 inits a ALIAS_INFO3 structure.
3572 ********************************************************************/
3574 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3576 DEBUG(5, ("init_samr_alias_info3\n"));
3578 init_unistr2(&al3->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3579 init_uni_hdr(&al3->hdr_acct_desc, &al3->uni_acct_desc);
3582 /*******************************************************************
3583 reads or writes a structure.
3584 ********************************************************************/
3586 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
3587 prs_struct *ps, int depth)
3592 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3598 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3600 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3601 al3->hdr_acct_desc.buffer, ps, depth))
3607 /*******************************************************************
3608 reads or writes a structure.
3609 ********************************************************************/
3611 BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr,
3612 prs_struct *ps, int depth)
3617 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3620 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3622 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3625 switch (ctr->switch_value1) {
3627 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3631 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3635 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3642 /*******************************************************************
3643 inits a SAMR_Q_QUERY_ALIASINFO structure.
3644 ********************************************************************/
3646 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3647 POLICY_HND *pol, uint16 switch_level)
3649 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3652 q_e->switch_level = switch_level;
3655 /*******************************************************************
3656 reads or writes a structure.
3657 ********************************************************************/
3659 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3660 prs_struct *ps, int depth)
3665 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3671 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3674 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3680 /*******************************************************************
3681 inits a SAMR_R_QUERY_ALIASINFO structure.
3682 ********************************************************************/
3684 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3685 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3687 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3689 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3691 r_u->status = status;
3694 /*******************************************************************
3695 reads or writes a structure.
3696 ********************************************************************/
3698 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3699 prs_struct *ps, int depth)
3704 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3710 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3713 if (r_u->ptr != 0) {
3714 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3720 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3726 /*******************************************************************
3727 inits a SAMR_Q_SET_ALIASINFO structure.
3728 ********************************************************************/
3730 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3731 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3733 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3735 q_u->alias_pol = *hnd;
3739 /*******************************************************************
3740 reads or writes a structure.
3741 ********************************************************************/
3743 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3744 prs_struct *ps, int depth)
3749 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3755 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3757 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3763 /*******************************************************************
3764 reads or writes a structure.
3765 ********************************************************************/
3767 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3768 prs_struct *ps, int depth)
3773 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3778 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3784 /*******************************************************************
3785 inits a SAMR_Q_QUERY_USERALIASES structure.
3786 ********************************************************************/
3788 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3791 uint32 *ptr_sid, DOM_SID2 * sid)
3793 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3797 q_u->num_sids1 = num_sids;
3799 q_u->num_sids2 = num_sids;
3801 q_u->ptr_sid = ptr_sid;
3805 /*******************************************************************
3806 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3807 ********************************************************************/
3809 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3810 prs_struct *ps, int depth)
3818 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3824 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3827 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3829 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3835 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3838 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3839 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3840 if (q_u->ptr_sid == NULL)
3843 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3844 if (q_u->sid == NULL)
3848 for (i = 0; i < q_u->num_sids2; i++) {
3849 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3850 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3854 for (i = 0; i < q_u->num_sids2; i++) {
3855 if (q_u->ptr_sid[i] != 0) {
3856 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3857 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3865 /*******************************************************************
3866 inits a SAMR_R_QUERY_USERALIASES structure.
3867 ********************************************************************/
3869 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3870 uint32 num_rids, uint32 *rid,
3873 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3875 if (NT_STATUS_IS_OK(status)) {
3876 r_u->num_entries = num_rids;
3878 r_u->num_entries2 = num_rids;
3882 r_u->num_entries = 0;
3884 r_u->num_entries2 = 0;
3887 r_u->status = status;
3890 /*******************************************************************
3891 reads or writes a structure.
3892 ********************************************************************/
3894 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3895 prs_struct *ps, int depth)
3902 prs_debug(ps, depth, desc, "samr_io_rids");
3908 if(!prs_uint32("num_rids", ps, depth, num_rids))
3911 if ((*num_rids) != 0) {
3912 if (UNMARSHALLING(ps)) {
3914 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3919 for (i = 0; i < (*num_rids); i++) {
3920 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3921 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3929 /*******************************************************************
3930 reads or writes a structure.
3931 ********************************************************************/
3933 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3934 prs_struct *ps, int depth)
3939 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3945 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3947 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3950 if (r_u->ptr != 0) {
3951 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3957 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3963 /*******************************************************************
3964 inits a SAMR_Q_OPEN_ALIAS structure.
3965 ********************************************************************/
3967 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3968 uint32 access_mask, uint32 rid)
3970 DEBUG(5, ("init_samr_q_open_alias\n"));
3972 q_u->dom_pol = *pol;
3973 q_u->access_mask = access_mask;
3974 q_u->rid_alias = rid;
3977 /*******************************************************************
3978 reads or writes a structure.
3979 ********************************************************************/
3981 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3982 prs_struct *ps, int depth)
3987 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3993 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3996 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3998 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
4004 /*******************************************************************
4005 reads or writes a structure.
4006 ********************************************************************/
4008 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4009 prs_struct *ps, int depth)
4014 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4020 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4023 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4029 /*******************************************************************
4030 inits a SAMR_Q_LOOKUP_RIDS structure.
4031 ********************************************************************/
4033 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4034 POLICY_HND *pol, uint32 flags,
4035 uint32 num_rids, uint32 *rid)
4037 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4041 q_u->num_rids1 = num_rids;
4044 q_u->num_rids2 = num_rids;
4045 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4046 if (q_u->rid == NULL) {
4050 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4054 /*******************************************************************
4055 reads or writes a structure.
4056 ********************************************************************/
4058 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4059 prs_struct *ps, int depth)
4067 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4070 if (UNMARSHALLING(ps))
4076 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4079 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4081 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4083 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4085 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4088 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4089 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4090 if (q_u->rid == NULL)
4094 for (i = 0; i < q_u->num_rids2; i++) {
4095 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4096 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4103 /*******************************************************************
4104 inits a SAMR_R_LOOKUP_RIDS structure.
4105 ********************************************************************/
4107 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4108 uint32 num_names, UNIHDR * hdr_name,
4109 UNISTR2 *uni_name, uint32 *type)
4111 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4113 r_u->hdr_name = NULL;
4114 r_u->uni_name = NULL;
4117 if (num_names != 0) {
4118 r_u->num_names1 = num_names;
4120 r_u->num_names2 = num_names;
4122 r_u->num_types1 = num_names;
4124 r_u->num_types2 = num_names;
4126 r_u->hdr_name = hdr_name;
4127 r_u->uni_name = uni_name;
4130 r_u->num_names1 = num_names;
4132 r_u->num_names2 = num_names;
4134 r_u->num_types1 = num_names;
4136 r_u->num_types2 = num_names;
4140 /*******************************************************************
4141 reads or writes a structure.
4142 ********************************************************************/
4144 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4145 prs_struct *ps, int depth)
4152 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4158 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4160 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4163 if (r_u->ptr_names != 0) {
4165 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4169 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4170 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4171 if (r_u->hdr_name == NULL)
4174 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4175 if (r_u->uni_name == NULL)
4179 for (i = 0; i < r_u->num_names2; i++) {
4180 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4181 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4184 for (i = 0; i < r_u->num_names2; i++) {
4185 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4186 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4194 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4196 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4199 if (r_u->ptr_types != 0) {
4201 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4204 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4205 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4206 if (r_u->type == NULL)
4210 for (i = 0; i < r_u->num_types2; i++) {
4211 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4212 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4217 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4223 /*******************************************************************
4224 inits a SAMR_Q_OPEN_ALIAS structure.
4225 ********************************************************************/
4227 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4229 DEBUG(5, ("init_samr_q_delete_alias\n"));
4231 q_u->alias_pol = *hnd;
4234 /*******************************************************************
4235 reads or writes a structure.
4236 ********************************************************************/
4238 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4239 prs_struct *ps, int depth)
4244 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4250 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4256 /*******************************************************************
4257 reads or writes a structure.
4258 ********************************************************************/
4260 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4261 prs_struct *ps, int depth)
4266 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4272 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4274 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4280 /*******************************************************************
4281 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4282 ********************************************************************/
4284 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4285 POLICY_HND *hnd, const char *acct_desc)
4287 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4289 q_u->dom_pol = *hnd;
4291 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4292 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4294 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4297 /*******************************************************************
4298 reads or writes a structure.
4299 ********************************************************************/
4301 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4302 prs_struct *ps, int depth)
4307 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4313 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4316 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4318 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4319 q_u->hdr_acct_desc.buffer, ps, depth))
4324 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4330 /*******************************************************************
4331 reads or writes a structure.
4332 ********************************************************************/
4334 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4335 prs_struct *ps, int depth)
4340 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4346 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4349 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4352 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4358 /*******************************************************************
4359 inits a SAMR_Q_ADD_ALIASMEM structure.
4360 ********************************************************************/
4362 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4365 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4367 q_u->alias_pol = *hnd;
4368 init_dom_sid2(&q_u->sid, sid);
4371 /*******************************************************************
4372 reads or writes a structure.
4373 ********************************************************************/
4375 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4376 prs_struct *ps, int depth)
4381 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4387 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4389 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4395 /*******************************************************************
4396 reads or writes a structure.
4397 ********************************************************************/
4399 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4400 prs_struct *ps, int depth)
4405 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4411 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4417 /*******************************************************************
4418 inits a SAMR_Q_DEL_ALIASMEM structure.
4419 ********************************************************************/
4421 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4424 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4426 q_u->alias_pol = *hnd;
4427 init_dom_sid2(&q_u->sid, sid);
4430 /*******************************************************************
4431 reads or writes a structure.
4432 ********************************************************************/
4434 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4435 prs_struct *ps, int depth)
4440 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4446 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4448 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4454 /*******************************************************************
4455 reads or writes a structure.
4456 ********************************************************************/
4458 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4459 prs_struct *ps, int depth)
4464 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4470 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4476 /*******************************************************************
4477 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4478 ********************************************************************/
4480 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4483 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4485 q_c->alias_pol = *hnd;
4488 /*******************************************************************
4489 reads or writes a structure.
4490 ********************************************************************/
4492 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4493 prs_struct *ps, int depth)
4498 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4504 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4510 /*******************************************************************
4511 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4512 ********************************************************************/
4514 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4517 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4519 r_u->status = status;
4522 /*******************************************************************
4523 reads or writes a structure.
4524 ********************************************************************/
4526 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4527 prs_struct *ps, int depth)
4532 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4538 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4544 /*******************************************************************
4545 inits a SAMR_Q_QUERY_ALIASMEM structure.
4546 ********************************************************************/
4548 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4551 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4553 q_c->alias_pol = *hnd;
4556 /*******************************************************************
4557 reads or writes a structure.
4558 ********************************************************************/
4560 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4561 prs_struct *ps, int depth)
4566 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4572 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4578 /*******************************************************************
4579 inits a SAMR_R_QUERY_ALIASMEM structure.
4580 ********************************************************************/
4582 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4583 uint32 num_sids, DOM_SID2 * sid,
4586 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4588 if (NT_STATUS_IS_OK(status)) {
4589 r_u->num_sids = num_sids;
4590 r_u->ptr = (num_sids != 0) ? 1 : 0;
4591 r_u->num_sids1 = num_sids;
4599 r_u->status = status;
4602 /*******************************************************************
4603 reads or writes a structure.
4604 ********************************************************************/
4606 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4607 prs_struct *ps, int depth)
4614 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4620 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4622 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4625 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4626 uint32 *ptr_sid = NULL;
4628 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4631 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4636 for (i = 0; i < r_u->num_sids1; i++) {
4638 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4642 if (UNMARSHALLING(ps)) {
4643 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4646 for (i = 0; i < r_u->num_sids1; i++) {
4647 if (ptr_sid[i] != 0) {
4648 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4656 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4662 /*******************************************************************
4663 inits a SAMR_Q_LOOKUP_NAMES structure.
4664 ********************************************************************/
4666 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4667 POLICY_HND *pol, uint32 flags,
4668 uint32 num_names, const char **name)
4672 DEBUG(5, ("init_samr_q_lookup_names\n"));
4676 q_u->num_names1 = num_names;
4679 q_u->num_names2 = num_names;
4681 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4682 return NT_STATUS_NO_MEMORY;
4684 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4685 return NT_STATUS_NO_MEMORY;
4687 for (i = 0; i < num_names; i++) {
4688 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4689 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4692 return NT_STATUS_OK;
4695 /*******************************************************************
4696 reads or writes a structure.
4697 ********************************************************************/
4699 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4700 prs_struct *ps, int depth)
4707 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4710 if (UNMARSHALLING(ps))
4716 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4719 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4721 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4723 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4725 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4728 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4729 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4730 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4731 if (!q_u->hdr_name || !q_u->uni_name)
4735 for (i = 0; i < q_u->num_names2; i++) {
4736 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4740 for (i = 0; i < q_u->num_names2; i++) {
4741 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4748 /*******************************************************************
4749 inits a SAMR_R_LOOKUP_NAMES structure.
4750 ********************************************************************/
4752 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4754 uint32 *rid, uint32 *type,
4757 DEBUG(5, ("init_samr_r_lookup_names\n"));
4759 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4762 r_u->num_types1 = num_rids;
4764 r_u->num_types2 = num_rids;
4766 r_u->num_rids1 = num_rids;
4768 r_u->num_rids2 = num_rids;
4770 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4771 return NT_STATUS_NO_MEMORY;
4772 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4773 return NT_STATUS_NO_MEMORY;
4775 if (!r_u->rids || !r_u->types)
4778 for (i = 0; i < num_rids; i++) {
4779 r_u->rids[i] = rid[i];
4780 r_u->types[i] = type[i];
4785 r_u->num_types1 = 0;
4787 r_u->num_types2 = 0;
4797 r_u->status = status;
4799 return NT_STATUS_OK;
4802 /*******************************************************************
4803 reads or writes a structure.
4804 ********************************************************************/
4806 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4807 prs_struct *ps, int depth)
4815 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4818 if (UNMARSHALLING(ps))
4824 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4826 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4829 if (r_u->ptr_rids != 0) {
4830 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4833 if (r_u->num_rids2 != r_u->num_rids1) {
4838 if (UNMARSHALLING(ps))
4839 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4842 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4846 for (i = 0; i < r_u->num_rids2; i++) {
4847 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4848 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4853 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4855 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4858 if (r_u->ptr_types != 0) {
4859 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4862 if (r_u->num_types2 != r_u->num_types1) {
4867 if (UNMARSHALLING(ps))
4868 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4871 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4875 for (i = 0; i < r_u->num_types2; i++) {
4876 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4877 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4882 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4888 /*******************************************************************
4889 inits a SAMR_Q_DELETE_DOM_USER structure.
4890 ********************************************************************/
4892 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4895 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4897 q_c->user_pol = *hnd;
4900 /*******************************************************************
4901 reads or writes a structure.
4902 ********************************************************************/
4904 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4905 prs_struct *ps, int depth)
4910 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4916 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4922 /*******************************************************************
4923 reads or writes a structure.
4924 ********************************************************************/
4926 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4927 prs_struct *ps, int depth)
4932 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4938 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4940 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4946 /*******************************************************************
4947 reads or writes a structure.
4948 ********************************************************************/
4950 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4952 uint32 access_mask, uint32 rid)
4954 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4956 q_u->domain_pol = *pol;
4957 q_u->access_mask = access_mask;
4958 q_u->user_rid = rid;
4961 /*******************************************************************
4962 reads or writes a structure.
4963 ********************************************************************/
4965 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4966 prs_struct *ps, int depth)
4971 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4977 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4980 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4982 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4988 /*******************************************************************
4989 reads or writes a structure.
4990 ********************************************************************/
4992 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4993 prs_struct *ps, int depth)
4998 prs_debug(ps, depth, desc, "samr_io_r_open_user");
5004 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5007 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5014 /*******************************************************************
5015 reads or writes a structure.
5016 ********************************************************************/
5018 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5021 uint32 acb_info, uint32 access_mask)
5023 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5025 q_u->domain_pol = *pol;
5027 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5028 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5030 q_u->acb_info = acb_info;
5031 q_u->access_mask = access_mask;
5034 /*******************************************************************
5035 reads or writes a structure.
5036 ********************************************************************/
5038 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5039 prs_struct *ps, int depth)
5044 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5050 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5053 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5055 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5060 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5062 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5068 /*******************************************************************
5069 reads or writes a structure.
5070 ********************************************************************/
5072 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5073 prs_struct *ps, int depth)
5078 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5084 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5087 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5089 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5091 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5097 /*******************************************************************
5098 inits a SAMR_Q_QUERY_USERINFO structure.
5099 ********************************************************************/
5101 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5102 POLICY_HND *hnd, uint16 switch_value)
5104 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5107 q_u->switch_value = switch_value;
5110 /*******************************************************************
5111 reads or writes a structure.
5112 ********************************************************************/
5114 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5115 prs_struct *ps, int depth)
5120 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5126 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5129 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5135 /*******************************************************************
5136 reads or writes a LOGON_HRS structure.
5137 ********************************************************************/
5139 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5140 prs_struct *ps, int depth)
5145 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5151 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5154 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5157 if(!prs_uint32("len ", ps, depth, &hrs->len))
5160 if (hrs->len > sizeof(hrs->hours)) {
5161 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5162 hrs->len = sizeof(hrs->hours);
5165 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5171 /*******************************************************************
5172 inits a SAM_USER_INFO_12 structure.
5173 ********************************************************************/
5175 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5176 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5178 DEBUG(5, ("init_sam_user_info12\n"));
5180 usr->lm_pwd_active =
5181 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5182 usr->nt_pwd_active =
5183 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5186 /*******************************************************************
5187 reads or writes a structure.
5188 ********************************************************************/
5190 static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u,
5191 prs_struct *ps, int depth)
5196 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5202 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5204 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5207 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5209 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5215 /*******************************************************************
5216 inits a SAM_USER_INFO_7 structure.
5217 ********************************************************************/
5219 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5221 DEBUG(5, ("init_sam_user_info7\n"));
5223 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5224 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5228 /*******************************************************************
5229 reads or writes a structure.
5230 ********************************************************************/
5232 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5233 prs_struct *ps, int depth)
5238 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5244 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5247 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5253 /*******************************************************************
5254 inits a SAM_USER_INFO_10 structure.
5255 ********************************************************************/
5257 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5259 DEBUG(5, ("init_sam_user_info10\n"));
5261 usr->acb_info = acb_info;
5264 /*******************************************************************
5265 reads or writes a structure.
5266 ********************************************************************/
5268 static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr,
5269 prs_struct *ps, int depth)
5274 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5280 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5286 /*******************************************************************
5287 inits a SAM_USER_INFO_11 structure.
5288 ********************************************************************/
5290 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5293 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5295 DEBUG(5, ("init_sam_user_info11\n"));
5297 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5298 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5300 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5302 usr->ptr_1 = 1; /* pointer */
5303 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5304 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5306 usr->ptr_2 = 1; /* pointer */
5307 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5309 usr->ptr_3 = 1; /* pointer */
5310 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5312 usr->rid_user = rid_user;
5313 usr->rid_group = rid_group;
5315 usr->acct_ctrl = acct_ctrl;
5316 usr->unknown_3 = 0x0000;
5318 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5319 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5321 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5322 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5324 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5325 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5328 /*******************************************************************
5329 reads or writes a structure.
5330 ********************************************************************/
5332 static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr,
5333 prs_struct *ps, int depth)
5338 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5344 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5347 if(!smb_io_time("time", &usr->expiry, ps, depth))
5350 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5353 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5356 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5359 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5361 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5364 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5367 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5369 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5372 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5374 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5377 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5379 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5381 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5383 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5385 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5387 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5390 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5393 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5396 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5402 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5408 /*************************************************************************
5410 *************************************************************************/
5412 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5414 DEBUG(10, ("init_sam_user_info24:\n"));
5415 memcpy(usr->pass, newpass, sizeof(usr->pass));
5416 usr->pw_len = pw_len;
5419 /*******************************************************************
5420 reads or writes a structure.
5421 ********************************************************************/
5423 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5424 prs_struct *ps, int depth)
5429 prs_debug(ps, depth, desc, "sam_io_user_info24");
5435 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5439 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5440 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5449 /*************************************************************************
5450 init_sam_user_info23
5452 unknown_6 = 0x0000 04ec
5454 *************************************************************************/
5456 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5457 NTTIME * logoff_time, /* all zeros */
5458 NTTIME * kickoff_time, /* all zeros */
5459 NTTIME * pass_last_set_time, /* all zeros */
5460 NTTIME * pass_can_change_time, /* all zeros */
5461 NTTIME * pass_must_change_time, /* all zeros */
5472 uint32 user_rid, /* 0x0000 0000 */
5475 uint32 fields_present,
5478 uint16 bad_password_count,
5482 usr->logon_time = *logon_time; /* all zeros */
5483 usr->logoff_time = *logoff_time; /* all zeros */
5484 usr->kickoff_time = *kickoff_time; /* all zeros */
5485 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5486 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5487 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5489 ZERO_STRUCT(usr->nt_pwd);
5490 ZERO_STRUCT(usr->lm_pwd);
5492 usr->user_rid = user_rid; /* 0x0000 0000 */
5493 usr->group_rid = group_rid;
5494 usr->acb_info = acb_info;
5495 usr->fields_present = fields_present; /* 09f8 27fa */
5497 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5498 usr->ptr_logon_hrs = hrs ? 1 : 0;
5500 if (nt_time_is_zero(pass_must_change_time)) {
5501 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5503 usr->passmustchange=0;
5506 ZERO_STRUCT(usr->padding1);
5507 ZERO_STRUCT(usr->padding2);
5509 usr->bad_password_count = bad_password_count;
5510 usr->logon_count = logon_count;
5512 memcpy(usr->pass, newpass, sizeof(usr->pass));
5514 copy_unistr2(&usr->uni_user_name, user_name);
5515 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5517 copy_unistr2(&usr->uni_full_name, full_name);
5518 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5520 copy_unistr2(&usr->uni_home_dir, home_dir);
5521 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5523 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5524 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5526 copy_unistr2(&usr->uni_logon_script, log_scr);
5527 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5529 copy_unistr2(&usr->uni_profile_path, prof_path);
5530 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5532 copy_unistr2(&usr->uni_acct_desc, desc);
5533 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5535 copy_unistr2(&usr->uni_workstations, wkstas);
5536 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5538 copy_unistr2(&usr->uni_unknown_str, unk_str);
5539 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5541 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5542 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5544 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5547 /*************************************************************************
5548 init_sam_user_info23
5550 unknown_6 = 0x0000 04ec
5552 *************************************************************************/
5554 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5555 NTTIME * logoff_time, /* all zeros */
5556 NTTIME * kickoff_time, /* all zeros */
5557 NTTIME * pass_last_set_time, /* all zeros */
5558 NTTIME * pass_can_change_time, /* all zeros */
5559 NTTIME * pass_must_change_time, /* all zeros */
5560 char *user_name, /* NULL */
5562 char *home_dir, char *dir_drive, char *log_scr,
5563 char *prof_path, const char *desc, char *wkstas,
5564 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5565 uint32 group_rid, uint32 acb_info,
5566 uint32 fields_present, uint16 logon_divs,
5567 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5570 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5572 usr->logon_time = *logon_time; /* all zeros */
5573 usr->logoff_time = *logoff_time; /* all zeros */
5574 usr->kickoff_time = *kickoff_time; /* all zeros */
5575 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5576 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5577 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5579 ZERO_STRUCT(usr->nt_pwd);
5580 ZERO_STRUCT(usr->lm_pwd);
5582 usr->user_rid = user_rid; /* 0x0000 0000 */
5583 usr->group_rid = group_rid;
5584 usr->acb_info = acb_info;
5585 usr->fields_present = fields_present; /* 09f8 27fa */
5587 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5588 usr->ptr_logon_hrs = hrs ? 1 : 0;
5590 if (nt_time_is_zero(pass_must_change_time)) {
5591 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5593 usr->passmustchange=0;
5596 ZERO_STRUCT(usr->padding1);
5597 ZERO_STRUCT(usr->padding2);
5599 usr->bad_password_count = bad_password_count;
5600 usr->logon_count = logon_count;
5602 memcpy(usr->pass, newpass, sizeof(usr->pass));
5604 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5605 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5607 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5608 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5610 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5611 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5613 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5614 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5616 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5617 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5619 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5620 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5622 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5623 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5625 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5626 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5628 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5629 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5631 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5632 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5634 data_blob_free(&blob);
5636 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5639 /*******************************************************************
5640 reads or writes a structure.
5641 ********************************************************************/
5643 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5644 prs_struct *ps, int depth)
5649 prs_debug(ps, depth, desc, "sam_io_user_info23");
5655 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5657 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5659 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5661 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5663 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5665 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5668 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5670 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5672 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5674 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5676 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5678 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5680 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5682 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5684 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5686 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5689 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5691 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5694 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5696 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5698 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5701 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5703 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5707 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5710 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5712 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5715 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5717 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5719 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5723 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5726 /* here begins pointed-to data */
5728 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5731 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5734 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5737 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5740 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5743 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5746 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5749 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5752 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5755 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5758 /* ok, this is only guess-work (as usual) */
5759 if (usr->ptr_logon_hrs) {
5760 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5767 /*******************************************************************
5768 reads or writes a structure.
5769 NB. This structure is *definately* incorrect. It's my best guess
5770 currently for W2K SP2. The password field is encrypted in a different
5771 way than normal... And there are definately other problems. JRA.
5772 ********************************************************************/
5774 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5779 prs_debug(ps, depth, desc, "sam_io_user_info25");
5785 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5787 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5789 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5791 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5793 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5795 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5798 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5800 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5802 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5804 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5806 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5808 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5810 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5812 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5814 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5816 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5819 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5821 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5824 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5826 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5828 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5831 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5834 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5837 /* here begins pointed-to data */
5839 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5842 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5845 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5848 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5851 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5854 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5857 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5860 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5863 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5866 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5869 #if 0 /* JRA - unknown... */
5870 /* ok, this is only guess-work (as usual) */
5871 if (usr->ptr_logon_hrs) {
5872 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5881 /*************************************************************************
5882 init_sam_user_info21W
5884 unknown_6 = 0x0000 04ec
5886 *************************************************************************/
5888 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5889 NTTIME * logon_time,
5890 NTTIME * logoff_time,
5891 NTTIME * kickoff_time,
5892 NTTIME * pass_last_set_time,
5893 NTTIME * pass_can_change_time,
5894 NTTIME * pass_must_change_time,
5910 uint32 fields_present,
5913 uint16 bad_password_count,
5916 usr->logon_time = *logon_time;
5917 usr->logoff_time = *logoff_time;
5918 usr->kickoff_time = *kickoff_time;
5919 usr->pass_last_set_time = *pass_last_set_time;
5920 usr->pass_can_change_time = *pass_can_change_time;
5921 usr->pass_must_change_time = *pass_must_change_time;
5923 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5924 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5926 usr->user_rid = user_rid;
5927 usr->group_rid = group_rid;
5928 usr->acb_info = acb_info;
5929 usr->fields_present = fields_present; /* 0x00ff ffff */
5931 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5932 usr->ptr_logon_hrs = hrs ? 1 : 0;
5933 usr->bad_password_count = bad_password_count;
5934 usr->logon_count = logon_count;
5936 if (nt_time_is_zero(pass_must_change_time)) {
5937 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5939 usr->passmustchange=0;
5942 ZERO_STRUCT(usr->padding1);
5943 ZERO_STRUCT(usr->padding2);
5945 copy_unistr2(&usr->uni_user_name, user_name);
5946 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5948 copy_unistr2(&usr->uni_full_name, full_name);
5949 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5951 copy_unistr2(&usr->uni_home_dir, home_dir);
5952 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5954 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5955 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5957 copy_unistr2(&usr->uni_logon_script, log_scr);
5958 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5960 copy_unistr2(&usr->uni_profile_path, prof_path);
5961 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5963 copy_unistr2(&usr->uni_acct_desc, desc);
5964 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5966 copy_unistr2(&usr->uni_workstations, wkstas);
5967 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5969 copy_unistr2(&usr->uni_unknown_str, unk_str);
5970 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5972 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5973 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5975 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5978 /*************************************************************************
5979 init_sam_user_info21
5981 unknown_6 = 0x0000 04ec
5983 *************************************************************************/
5985 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5987 NTTIME logon_time, logoff_time, kickoff_time,
5988 pass_last_set_time, pass_can_change_time,
5989 pass_must_change_time;
5991 const char* user_name = pdb_get_username(pw);
5992 const char* full_name = pdb_get_fullname(pw);
5993 const char* home_dir = pdb_get_homedir(pw);
5994 const char* dir_drive = pdb_get_dir_drive(pw);
5995 const char* logon_script = pdb_get_logon_script(pw);
5996 const char* profile_path = pdb_get_profile_path(pw);
5997 const char* description = pdb_get_acct_desc(pw);
5998 const char* workstations = pdb_get_workstations(pw);
5999 const char* munged_dial = pdb_get_munged_dial(pw);
6000 DATA_BLOB munged_dial_blob;
6003 const DOM_SID *user_sid;
6006 const DOM_SID *group_sid;
6009 munged_dial_blob = base64_decode_data_blob(munged_dial);
6011 munged_dial_blob = data_blob(NULL, 0);
6014 /* Create NTTIME structs */
6015 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6016 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6017 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6018 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6019 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6020 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6022 /* structure assignment */
6023 usr->logon_time = logon_time;
6024 usr->logoff_time = logoff_time;
6025 usr->kickoff_time = kickoff_time;
6026 usr->pass_last_set_time = pass_last_set_time;
6027 usr->pass_can_change_time = pass_can_change_time;
6028 usr->pass_must_change_time = pass_must_change_time;
6030 ZERO_STRUCT(usr->nt_pwd);
6031 ZERO_STRUCT(usr->lm_pwd);
6033 user_sid = pdb_get_user_sid(pw);
6035 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6036 fstring user_sid_string;
6037 fstring domain_sid_string;
6038 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6039 "the domain sid %s. Failing operation.\n",
6041 sid_to_string(user_sid_string, user_sid),
6042 sid_to_string(domain_sid_string, domain_sid)));
6043 data_blob_free(&munged_dial_blob);
6044 return NT_STATUS_UNSUCCESSFUL;
6047 group_sid = pdb_get_group_sid(pw);
6049 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6050 fstring group_sid_string;
6051 fstring domain_sid_string;
6052 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6053 "which conflicts with the domain sid %s. Failing operation.\n",
6055 sid_to_string(group_sid_string, group_sid),
6056 sid_to_string(domain_sid_string, domain_sid)));
6057 data_blob_free(&munged_dial_blob);
6058 return NT_STATUS_UNSUCCESSFUL;
6061 usr->user_rid = user_rid;
6062 usr->group_rid = group_rid;
6063 usr->acb_info = pdb_get_acct_ctrl(pw);
6066 Look at a user on a real NT4 PDC with usrmgr, press
6067 'ok'. Then you will see that fields_present is set to
6068 0x08f827fa. Look at the user immediately after that again,
6069 and you will see that 0x00fffff is returned. This solves
6070 the problem that you get access denied after having looked
6074 usr->fields_present = pdb_build_fields_present(pw);
6076 usr->logon_divs = pdb_get_logon_divs(pw);
6077 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6078 usr->bad_password_count = pdb_get_bad_password_count(pw);
6079 usr->logon_count = pdb_get_logon_count(pw);
6081 if (pdb_get_pass_must_change_time(pw) == 0) {
6082 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6084 usr->passmustchange=0;
6087 ZERO_STRUCT(usr->padding1);
6088 ZERO_STRUCT(usr->padding2);
6090 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6091 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6093 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6094 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6096 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6097 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6099 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6100 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6102 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6103 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6105 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6106 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6108 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6109 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6111 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6112 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6114 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6115 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6117 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6118 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6119 data_blob_free(&munged_dial_blob);
6121 if (pdb_get_hours(pw)) {
6122 usr->logon_hrs.max_len = 1260;
6123 usr->logon_hrs.offset = 0;
6124 usr->logon_hrs.len = pdb_get_hours_len(pw);
6125 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6127 usr->logon_hrs.max_len = 1260;
6128 usr->logon_hrs.offset = 0;
6129 usr->logon_hrs.len = 0;
6130 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6133 return NT_STATUS_OK;
6136 /*******************************************************************
6137 reads or writes a structure.
6138 ********************************************************************/
6140 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6141 prs_struct *ps, int depth)
6146 prs_debug(ps, depth, desc, "sam_io_user_info21");
6152 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6154 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6156 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6158 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6160 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6162 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6165 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6167 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6169 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6171 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6173 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6175 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6177 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6179 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6181 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6183 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6186 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6188 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6191 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6193 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6195 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6198 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6200 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6204 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6207 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6209 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6212 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6214 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6216 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6219 /* here begins pointed-to data */
6221 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6223 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6225 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6227 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6229 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6231 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6233 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6235 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6237 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6239 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6242 /* ok, this is only guess-work (as usual) */
6243 if (usr->ptr_logon_hrs) {
6244 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6251 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6253 const char *munged_dial = pdb_get_munged_dial(pw);
6254 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6256 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6257 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6258 data_blob_free(&blob);
6261 /*******************************************************************
6262 reads or writes a structure.
6263 ********************************************************************/
6265 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6266 prs_struct *ps, int depth)
6271 prs_debug(ps, depth, desc, "sam_io_user_info20");
6277 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6280 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6286 /*******************************************************************
6287 inits a SAM_USERINFO_CTR structure.
6288 ********************************************************************/
6290 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6291 uint16 switch_value,
6292 SAM_USER_INFO_21 * usr)
6294 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6296 ctr->switch_value = switch_value;
6297 ctr->info.id = NULL;
6299 switch (switch_value) {
6301 ctr->info.id10 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_10);
6302 if (ctr->info.id10 == NULL)
6303 return NT_STATUS_NO_MEMORY;
6305 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6308 /* whoops - got this wrong. i think. or don't understand what's happening. */
6312 info = (void *)&id11;
6314 expire.low = 0xffffffff;
6315 expire.high = 0x7fffffff;
6317 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_11);
6318 init_sam_user_info11(ctr->info.id11, &expire,
6319 "BROOKFIELDS$", /* name */
6320 0x03ef, /* user rid */
6321 0x201, /* group rid */
6322 0x0080); /* acb info */
6328 ctr->info.id12 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_12);
6329 if (ctr->info.id12 == NULL)
6330 return NT_STATUS_NO_MEMORY;
6332 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6336 SAM_USER_INFO_21 *cusr;
6337 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6338 ctr->info.id21 = cusr;
6339 if (ctr->info.id21 == NULL)
6340 return NT_STATUS_NO_MEMORY;
6341 memcpy(cusr, usr, sizeof(*usr));
6342 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6343 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6347 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6348 return NT_STATUS_INVALID_INFO_CLASS;
6351 return NT_STATUS_OK;
6354 /*******************************************************************
6355 inits a SAM_USERINFO_CTR structure.
6356 ********************************************************************/
6358 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6359 uint16 switch_value, void *info)
6361 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6363 ctr->switch_value = switch_value;
6364 ctr->info.id = info;
6366 switch (switch_value) {
6368 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6369 dump_data(100, (char *)sess_key->data, sess_key->length);
6370 dump_data(100, (char *)ctr->info.id24->pass, 516);
6373 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6374 dump_data(100, (char *)sess_key->data, sess_key->length);
6375 dump_data(100, (char *)ctr->info.id23->pass, 516);
6380 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6384 /*******************************************************************
6385 reads or writes a structure.
6386 ********************************************************************/
6388 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6389 prs_struct *ps, int depth)
6392 SAM_USERINFO_CTR *ctr;
6394 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6397 if (UNMARSHALLING(ps)) {
6398 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6406 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6408 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6415 switch (ctr->switch_value) {
6417 if (UNMARSHALLING(ps))
6418 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6419 if (ctr->info.id7 == NULL) {
6420 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6423 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6426 if (UNMARSHALLING(ps))
6427 ctr->info.id10 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_10,1);
6428 if (ctr->info.id10 == NULL) {
6429 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6432 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6435 if (UNMARSHALLING(ps))
6436 ctr->info.id11 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_11,1);
6438 if (ctr->info.id11 == NULL) {
6439 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6442 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6445 if (UNMARSHALLING(ps))
6446 ctr->info.id12 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_12,1);
6448 if (ctr->info.id12 == NULL) {
6449 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6452 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6455 if (UNMARSHALLING(ps))
6456 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6458 if (ctr->info.id20 == NULL) {
6459 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6462 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6465 if (UNMARSHALLING(ps))
6466 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6468 if (ctr->info.id21 == NULL) {
6469 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6472 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6475 if (UNMARSHALLING(ps))
6476 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6478 if (ctr->info.id23 == NULL) {
6479 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6482 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6485 if (UNMARSHALLING(ps))
6486 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6488 if (ctr->info.id24 == NULL) {
6489 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6492 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6495 if (UNMARSHALLING(ps))
6496 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6498 if (ctr->info.id25 == NULL) {
6499 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6502 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6505 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6513 /*******************************************************************
6514 inits a SAMR_R_QUERY_USERINFO structure.
6515 ********************************************************************/
6517 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6518 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6520 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6525 if (NT_STATUS_IS_OK(status)) {
6530 r_u->status = status; /* return status */
6533 /*******************************************************************
6534 reads or writes a structure.
6535 ********************************************************************/
6537 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6538 prs_struct *ps, int depth)
6543 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6549 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6552 if (r_u->ptr != 0) {
6553 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6559 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6565 /*******************************************************************
6566 inits a SAMR_Q_SET_USERINFO structure.
6567 ********************************************************************/
6569 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6570 POLICY_HND *hnd, DATA_BLOB *sess_key,
6571 uint16 switch_value, void *info)
6573 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6576 q_u->switch_value = switch_value;
6577 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6580 /*******************************************************************
6581 reads or writes a structure.
6582 ********************************************************************/
6584 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6585 prs_struct *ps, int depth)
6590 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6596 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6598 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6600 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6606 /*******************************************************************
6607 inits a SAMR_R_SET_USERINFO structure.
6608 ********************************************************************/
6610 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6612 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6614 r_u->status = status; /* return status */
6617 /*******************************************************************
6618 reads or writes a structure.
6619 ********************************************************************/
6621 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6622 prs_struct *ps, int depth)
6627 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6633 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6639 /*******************************************************************
6640 inits a SAMR_Q_SET_USERINFO2 structure.
6641 ********************************************************************/
6643 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6644 POLICY_HND *hnd, DATA_BLOB *sess_key,
6645 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6647 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6650 q_u->switch_value = switch_value;
6653 if (q_u->ctr != NULL)
6654 q_u->ctr->switch_value = switch_value;
6656 switch (switch_value) {
6658 SamOEMhashBlob(ctr->info.id12->lm_pwd, 16, sess_key);
6659 SamOEMhashBlob(ctr->info.id12->nt_pwd, 16, sess_key);
6660 dump_data(100, (char *)sess_key->data, sess_key->length);
6661 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6662 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6667 /*******************************************************************
6668 reads or writes a structure.
6669 ********************************************************************/
6671 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6672 prs_struct *ps, int depth)
6677 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6683 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6686 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6688 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6694 /*******************************************************************
6695 inits a SAMR_R_SET_USERINFO2 structure.
6696 ********************************************************************/
6698 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6700 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6702 r_u->status = status; /* return status */
6705 /*******************************************************************
6706 reads or writes a structure.
6707 ********************************************************************/
6709 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6710 prs_struct *ps, int depth)
6715 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6721 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6727 /*******************************************************************
6728 inits a SAMR_Q_CONNECT structure.
6729 ********************************************************************/
6731 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6732 char *srv_name, uint32 access_mask)
6734 DEBUG(5, ("init_samr_q_connect\n"));
6736 /* make PDC server name \\server */
6737 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6738 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6740 /* example values: 0x0000 0002 */
6741 q_u->access_mask = access_mask;
6744 /*******************************************************************
6745 reads or writes a structure.
6746 ********************************************************************/
6748 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6749 prs_struct *ps, int depth)
6754 prs_debug(ps, depth, desc, "samr_io_q_connect");
6760 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6762 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6767 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6773 /*******************************************************************
6774 reads or writes a structure.
6775 ********************************************************************/
6777 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6778 prs_struct *ps, int depth)
6783 prs_debug(ps, depth, desc, "samr_io_r_connect");
6789 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6792 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6798 /*******************************************************************
6799 inits a SAMR_Q_CONNECT4 structure.
6800 ********************************************************************/
6802 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6803 char *srv_name, uint32 access_mask)
6805 DEBUG(5, ("init_samr_q_connect\n"));
6807 /* make PDC server name \\server */
6808 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6809 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6811 /* Only value we've seen, possibly an address type ? */
6814 /* example values: 0x0000 0002 */
6815 q_u->access_mask = access_mask;
6818 /*******************************************************************
6819 reads or writes a structure.
6820 ********************************************************************/
6822 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6823 prs_struct *ps, int depth)
6828 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6834 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6836 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6841 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6843 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6849 /*******************************************************************
6850 reads or writes a structure.
6851 ********************************************************************/
6853 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6854 prs_struct *ps, int depth)
6859 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6865 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6868 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6874 /*******************************************************************
6875 inits a SAMR_Q_CONNECT_ANON structure.
6876 ********************************************************************/
6878 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6880 DEBUG(5, ("init_samr_q_connect_anon\n"));
6883 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6884 q_u->unknown_1 = 0x01;
6885 q_u->access_mask = 0x20;
6888 /*******************************************************************
6889 reads or writes a structure.
6890 ********************************************************************/
6892 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6893 prs_struct *ps, int depth)
6898 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6904 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6906 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6908 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6910 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6916 /*******************************************************************
6917 reads or writes a structure.
6918 ********************************************************************/
6920 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6921 prs_struct *ps, int depth)
6926 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6932 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6935 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6941 /*******************************************************************
6942 inits a SAMR_Q_GET_DOM_PWINFO structure.
6943 ********************************************************************/
6945 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6948 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6951 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
6952 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
6955 /*******************************************************************
6956 reads or writes a structure.
6957 ********************************************************************/
6959 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6960 prs_struct *ps, int depth)
6965 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6971 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6973 if (q_u->ptr != 0) {
6974 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6976 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6983 /*******************************************************************
6984 reads or writes a structure.
6985 ********************************************************************/
6987 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6988 prs_struct *ps, int depth)
6993 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7000 * see the Samba4 IDL for what these actually are.
7003 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
7007 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
7010 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7016 /*******************************************************************
7017 make a SAMR_ENC_PASSWD structure.
7018 ********************************************************************/
7020 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7028 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7032 /*******************************************************************
7033 reads or writes a SAMR_ENC_PASSWD structure.
7034 ********************************************************************/
7036 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7037 prs_struct *ps, int depth)
7042 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7048 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7051 if (pwd->ptr != 0) {
7052 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7059 /*******************************************************************
7060 inits a SAMR_ENC_HASH structure.
7061 ********************************************************************/
7063 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7071 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7075 /*******************************************************************
7076 reads or writes a SAMR_ENC_HASH structure.
7077 ********************************************************************/
7079 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7080 prs_struct *ps, int depth)
7085 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7091 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7093 if (hsh->ptr != 0) {
7094 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7101 /*******************************************************************
7102 inits a SAMR_R_GET_DOM_PWINFO structure.
7103 ********************************************************************/
7105 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7106 const char *dest_host, const char *user_name,
7107 const char nt_newpass[516],
7108 const uchar nt_oldhash[16],
7109 const char lm_newpass[516],
7110 const uchar lm_oldhash[16])
7112 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7115 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7116 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7118 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7119 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7121 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7122 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7124 q_u->unknown = 0x01;
7126 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7127 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7130 /*******************************************************************
7131 reads or writes a structure.
7132 ********************************************************************/
7134 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7135 prs_struct *ps, int depth)
7140 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7146 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7149 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7151 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7156 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7158 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7161 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7163 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7166 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7169 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7171 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7177 /*******************************************************************
7178 inits a SAMR_R_CHGPASSWD_USER structure.
7179 ********************************************************************/
7181 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7183 DEBUG(5, ("init_r_chgpasswd_user\n"));
7185 r_u->status = status;
7188 /*******************************************************************
7189 reads or writes a structure.
7190 ********************************************************************/
7192 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7193 prs_struct *ps, int depth)
7198 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7204 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7210 /*******************************************************************
7211 reads or writes a structure.
7212 ********************************************************************/
7214 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7215 POLICY_HND *domain_pol, uint16 switch_value)
7217 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7219 q_u->domain_pol = *domain_pol;
7220 q_u->switch_value = switch_value;
7223 /*******************************************************************
7224 reads or writes a structure.
7225 ********************************************************************/
7227 BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7228 prs_struct *ps, int depth)
7233 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7239 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7242 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7248 /*******************************************************************
7249 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7250 ********************************************************************/
7252 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7253 uint16 switch_value, SAM_UNK_CTR * ctr,
7256 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7259 r_u->switch_value = 0;
7260 r_u->status = status; /* return status */
7262 if (NT_STATUS_IS_OK(status)) {
7263 r_u->switch_value = switch_value;
7269 /*******************************************************************
7270 reads or writes a structure.
7271 ********************************************************************/
7273 BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u,
7274 prs_struct *ps, int depth)
7279 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7285 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7288 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7289 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7294 switch (r_u->switch_value) {
7296 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7300 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7304 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7308 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7312 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7316 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7320 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7324 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7325 r_u->switch_value));
7326 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7334 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7341 /*******************************************************************
7342 reads or writes a structure.
7343 ********************************************************************/
7345 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7346 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7348 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7350 q_u->domain_pol = *domain_pol;
7351 q_u->switch_value0 = switch_value;
7353 q_u->switch_value = switch_value;
7358 /*******************************************************************
7359 reads or writes a structure.
7360 ********************************************************************/
7362 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7363 prs_struct *ps, int depth)
7368 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7374 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7377 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7380 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7386 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7389 switch (q_u->switch_value) {
7392 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7396 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7400 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7404 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7408 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7412 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7416 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7420 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7421 q_u->switch_value));
7428 /*******************************************************************
7429 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7430 ********************************************************************/
7432 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7434 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7436 r_u->status = status; /* return status */
7439 /*******************************************************************
7440 reads or writes a structure.
7441 ********************************************************************/
7443 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7444 prs_struct *ps, int depth)
7449 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7455 if(!prs_ntstatus("status", ps, depth, &r_u->status))