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,
1520 uint32 num_entries, uint32 start_idx,
1521 struct samr_displayentry *entries)
1525 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1528 return NT_STATUS_OK;
1530 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1532 return NT_STATUS_NO_MEMORY;
1534 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1535 if ((*sam)->sam == NULL)
1536 return NT_STATUS_NO_MEMORY;
1538 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1539 if ((*sam)->str == NULL)
1540 return NT_STATUS_NO_MEMORY;
1542 for (i = 0; i < num_entries ; i++) {
1543 init_unistr2(&(*sam)->str[i].uni_acct_name,
1544 entries[i].account_name, UNI_FLAGS_NONE);
1545 init_unistr2(&(*sam)->str[i].uni_full_name,
1546 entries[i].fullname, UNI_FLAGS_NONE);
1547 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1548 entries[i].description, UNI_FLAGS_NONE);
1550 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1551 &(*sam)->str[i].uni_acct_name,
1552 &(*sam)->str[i].uni_full_name,
1553 &(*sam)->str[i].uni_acct_desc,
1554 entries[i].rid, entries[i].acct_flags);
1557 return NT_STATUS_OK;
1560 /*******************************************************************
1561 reads or writes a structure.
1562 ********************************************************************/
1564 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1566 prs_struct *ps, int depth)
1570 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1576 if (UNMARSHALLING(ps) && num_entries > 0) {
1578 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1579 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1583 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1584 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1589 for (i = 0; i < num_entries; i++) {
1590 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1594 for (i = 0; i < num_entries; i++) {
1595 if(!sam_io_sam_str1("", &sam->str[i],
1596 sam->sam[i].hdr_acct_name.buffer,
1597 sam->sam[i].hdr_user_name.buffer,
1598 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1605 /*******************************************************************
1606 inits a SAM_DISPINFO_2 structure.
1607 ********************************************************************/
1609 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1610 uint32 num_entries, uint32 start_idx,
1611 struct samr_displayentry *entries)
1615 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1618 return NT_STATUS_OK;
1620 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1622 return NT_STATUS_NO_MEMORY;
1624 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1625 if ((*sam)->sam == NULL)
1626 return NT_STATUS_NO_MEMORY;
1628 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1629 if ((*sam)->str == NULL)
1630 return NT_STATUS_NO_MEMORY;
1632 for (i = 0; i < num_entries; i++) {
1633 init_unistr2(&(*sam)->str[i].uni_srv_name,
1634 entries[i].account_name, UNI_FLAGS_NONE);
1635 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1636 entries[i].description, UNI_FLAGS_NONE);
1638 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1639 &(*sam)->str[i].uni_srv_name,
1640 &(*sam)->str[i].uni_srv_desc,
1641 entries[i].rid, entries[i].acct_flags);
1644 return NT_STATUS_OK;
1647 /*******************************************************************
1648 reads or writes a structure.
1649 ********************************************************************/
1651 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1653 prs_struct *ps, int depth)
1660 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1666 if (UNMARSHALLING(ps) && num_entries > 0) {
1668 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1669 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1673 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1674 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1679 for (i = 0; i < num_entries; i++) {
1680 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1684 for (i = 0; i < num_entries; i++) {
1685 if(!sam_io_sam_str2("", &sam->str[i],
1686 sam->sam[i].hdr_srv_name.buffer,
1687 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1694 /*******************************************************************
1695 inits a SAM_DISPINFO_3 structure.
1696 ********************************************************************/
1698 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1699 uint32 num_entries, uint32 start_idx,
1700 struct samr_displayentry *entries)
1704 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1707 return NT_STATUS_OK;
1709 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1711 return NT_STATUS_NO_MEMORY;
1713 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1714 return NT_STATUS_NO_MEMORY;
1716 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1717 return NT_STATUS_NO_MEMORY;
1719 for (i = 0; i < num_entries; i++) {
1720 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1722 init_unistr2(&(*sam)->str[i].uni_grp_name,
1723 entries[i].account_name, UNI_FLAGS_NONE);
1724 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1725 entries[i].description, UNI_FLAGS_NONE);
1727 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1728 &(*sam)->str[i].uni_grp_name,
1729 &(*sam)->str[i].uni_grp_desc,
1733 return NT_STATUS_OK;
1736 /*******************************************************************
1737 reads or writes a structure.
1738 ********************************************************************/
1740 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1742 prs_struct *ps, int depth)
1749 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1755 if (UNMARSHALLING(ps) && num_entries > 0) {
1757 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1758 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1762 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1763 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1768 for (i = 0; i < num_entries; i++) {
1769 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1773 for (i = 0; i < num_entries; i++) {
1774 if(!sam_io_sam_str3("", &sam->str[i],
1775 sam->sam[i].hdr_grp_name.buffer,
1776 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1783 /*******************************************************************
1784 inits a SAM_DISPINFO_4 structure.
1785 ********************************************************************/
1787 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1788 uint32 num_entries, uint32 start_idx,
1789 struct samr_displayentry *entries)
1793 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1796 return NT_STATUS_OK;
1798 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1800 return NT_STATUS_NO_MEMORY;
1802 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1803 if ((*sam)->sam == NULL)
1804 return NT_STATUS_NO_MEMORY;
1806 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1807 if ((*sam)->str == NULL)
1808 return NT_STATUS_NO_MEMORY;
1810 for (i = 0; i < num_entries; i++) {
1811 size_t len_sam_name = strlen(entries[i].account_name);
1813 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1815 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1818 init_string2(&(*sam)->str[i].acct_name,
1819 entries[i].account_name, len_sam_name+1,
1823 return NT_STATUS_OK;
1826 /*******************************************************************
1827 reads or writes a structure.
1828 ********************************************************************/
1830 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1832 prs_struct *ps, int depth)
1839 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1845 if (UNMARSHALLING(ps) && num_entries > 0) {
1847 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1848 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1852 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1853 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1858 for (i = 0; i < num_entries; i++) {
1859 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1863 for (i = 0; i < num_entries; i++) {
1864 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1865 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1872 /*******************************************************************
1873 inits a SAM_DISPINFO_5 structure.
1874 ********************************************************************/
1876 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1877 uint32 num_entries, uint32 start_idx,
1878 struct samr_displayentry *entries)
1880 uint32 len_sam_name;
1883 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1886 return NT_STATUS_OK;
1888 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1890 return NT_STATUS_NO_MEMORY;
1892 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1893 return NT_STATUS_NO_MEMORY;
1895 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1896 return NT_STATUS_NO_MEMORY;
1898 for (i = 0; i < num_entries; i++) {
1899 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1901 len_sam_name = strlen(entries[i].account_name);
1903 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
1904 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
1905 len_sam_name+1, len_sam_name);
1908 return NT_STATUS_OK;
1911 /*******************************************************************
1912 reads or writes a structure.
1913 ********************************************************************/
1915 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1917 prs_struct *ps, int depth)
1924 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1930 if (UNMARSHALLING(ps) && num_entries > 0) {
1932 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1933 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1937 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1938 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1943 for (i = 0; i < num_entries; i++) {
1944 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1948 for (i = 0; i < num_entries; i++) {
1949 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1950 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1957 /*******************************************************************
1958 inits a SAMR_R_QUERY_DISPINFO structure.
1959 ********************************************************************/
1961 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1962 uint32 num_entries, uint32 total_size, uint32 data_size,
1963 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1966 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1968 r_u->total_size = total_size;
1970 r_u->data_size = data_size;
1972 r_u->switch_level = switch_level;
1973 r_u->num_entries = num_entries;
1976 r_u->ptr_entries = 0;
1978 r_u->ptr_entries = 1;
1980 r_u->num_entries2 = num_entries;
1983 r_u->status = status;
1986 /*******************************************************************
1987 reads or writes a structure.
1988 ********************************************************************/
1990 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1991 prs_struct *ps, int depth)
1996 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2002 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2004 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2006 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2011 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2013 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2016 if (r_u->ptr_entries==0) {
2019 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2025 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2028 switch (r_u->switch_level) {
2030 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2031 r_u->num_entries, ps, depth))
2035 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2036 r_u->num_entries, ps, depth))
2040 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2041 r_u->num_entries, ps, depth))
2045 if(!sam_io_sam_dispinfo_4("user list",
2046 r_u->ctr->sam.info4,
2047 r_u->num_entries, ps, depth))
2051 if(!sam_io_sam_dispinfo_5("group list",
2052 r_u->ctr->sam.info5,
2053 r_u->num_entries, ps, depth))
2057 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2063 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2069 /*******************************************************************
2070 inits a SAMR_Q_OPEN_GROUP structure.
2071 ********************************************************************/
2073 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2075 uint32 access_mask, uint32 rid)
2077 DEBUG(5, ("init_samr_q_open_group\n"));
2079 q_c->domain_pol = *hnd;
2080 q_c->access_mask = access_mask;
2081 q_c->rid_group = rid;
2084 /*******************************************************************
2085 reads or writes a structure.
2086 ********************************************************************/
2088 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2089 prs_struct *ps, int depth)
2094 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2100 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2103 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2105 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2111 /*******************************************************************
2112 reads or writes a structure.
2113 ********************************************************************/
2115 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2116 prs_struct *ps, int depth)
2121 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2127 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2130 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2136 /*******************************************************************
2137 inits a GROUP_INFO1 structure.
2138 ********************************************************************/
2140 void init_samr_group_info1(GROUP_INFO1 * gr1,
2141 char *acct_name, char *acct_desc,
2144 DEBUG(5, ("init_samr_group_info1\n"));
2146 gr1->unknown_1 = 0x3;
2147 gr1->num_members = num_members;
2149 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2150 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2151 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2152 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2155 /*******************************************************************
2156 reads or writes a structure.
2157 ********************************************************************/
2159 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2160 prs_struct *ps, int depth)
2167 prs_debug(ps, depth, desc, "samr_io_group_info1");
2170 if(!prs_uint16("level", ps, depth, &dummy))
2176 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2179 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2181 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2184 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2187 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2188 gr1->hdr_acct_name.buffer, ps, depth))
2191 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2192 gr1->hdr_acct_desc.buffer, ps, depth))
2198 /*******************************************************************
2199 inits a GROUP_INFO2 structure.
2200 ********************************************************************/
2202 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2204 DEBUG(5, ("init_samr_group_info2\n"));
2207 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2208 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2211 /*******************************************************************
2212 reads or writes a structure.
2213 ********************************************************************/
2215 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2220 prs_debug(ps, depth, desc, "samr_io_group_info2");
2223 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2226 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2228 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2229 gr2->hdr_acct_name.buffer, ps, depth))
2235 /*******************************************************************
2236 inits a GROUP_INFO3 structure.
2237 ********************************************************************/
2239 void init_samr_group_info3(GROUP_INFO3 *gr3)
2241 DEBUG(5, ("init_samr_group_info3\n"));
2243 gr3->unknown_1 = 0x3;
2246 /*******************************************************************
2247 reads or writes a structure.
2248 ********************************************************************/
2250 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2255 prs_debug(ps, depth, desc, "samr_io_group_info3");
2261 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2267 /*******************************************************************
2268 inits a GROUP_INFO4 structure.
2269 ********************************************************************/
2271 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2273 DEBUG(5, ("init_samr_group_info4\n"));
2276 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2277 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2280 /*******************************************************************
2281 reads or writes a structure.
2282 ********************************************************************/
2284 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2285 prs_struct *ps, int depth)
2290 prs_debug(ps, depth, desc, "samr_io_group_info4");
2293 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2295 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2297 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2298 gr4->hdr_acct_desc.buffer, ps, depth))
2304 /*******************************************************************
2305 reads or writes a structure.
2306 ********************************************************************/
2308 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2309 prs_struct *ps, int depth)
2311 if (UNMARSHALLING(ps))
2312 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2317 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2320 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2323 switch ((*ctr)->switch_value1) {
2325 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2329 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2333 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2337 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2341 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2348 /*******************************************************************
2349 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2350 ********************************************************************/
2352 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2353 POLICY_HND *pol, const char *acct_desc,
2356 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2360 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2361 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2363 q_e->access_mask = access_mask;
2366 /*******************************************************************
2367 reads or writes a structure.
2368 ********************************************************************/
2370 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2371 prs_struct *ps, int depth)
2376 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2382 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2385 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2387 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2388 q_e->hdr_acct_desc.buffer, ps, depth))
2393 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2399 /*******************************************************************
2400 reads or writes a structure.
2401 ********************************************************************/
2403 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2404 prs_struct *ps, int depth)
2409 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2415 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2418 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2420 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2426 /*******************************************************************
2427 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2428 ********************************************************************/
2430 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2433 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2435 q_c->group_pol = *hnd;
2438 /*******************************************************************
2439 reads or writes a structure.
2440 ********************************************************************/
2442 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2443 prs_struct *ps, int depth)
2448 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2454 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2460 /*******************************************************************
2461 reads or writes a structure.
2462 ********************************************************************/
2464 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2465 prs_struct *ps, int depth)
2470 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2476 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2479 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2485 /*******************************************************************
2486 inits a SAMR_Q_DEL_GROUPMEM structure.
2487 ********************************************************************/
2489 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2490 POLICY_HND *pol, uint32 rid)
2492 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2498 /*******************************************************************
2499 reads or writes a structure.
2500 ********************************************************************/
2502 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2503 prs_struct *ps, int depth)
2508 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2514 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2517 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2523 /*******************************************************************
2524 inits a SAMR_R_DEL_GROUPMEM structure.
2525 ********************************************************************/
2527 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2530 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2532 r_u->status = status;
2535 /*******************************************************************
2536 reads or writes a structure.
2537 ********************************************************************/
2539 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2540 prs_struct *ps, int depth)
2545 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2551 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2557 /*******************************************************************
2558 inits a SAMR_Q_ADD_GROUPMEM structure.
2559 ********************************************************************/
2561 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2562 POLICY_HND *pol, uint32 rid)
2564 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2568 q_e->unknown = 0x0005;
2571 /*******************************************************************
2572 reads or writes a structure.
2573 ********************************************************************/
2575 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2576 prs_struct *ps, int depth)
2581 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2587 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2590 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2592 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2598 /*******************************************************************
2599 inits a SAMR_R_ADD_GROUPMEM structure.
2600 ********************************************************************/
2602 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2605 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2607 r_u->status = status;
2610 /*******************************************************************
2611 reads or writes a structure.
2612 ********************************************************************/
2614 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2615 prs_struct *ps, int depth)
2620 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2626 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2632 /*******************************************************************
2633 inits a SAMR_Q_SET_GROUPINFO structure.
2634 ********************************************************************/
2636 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2637 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2639 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2645 /*******************************************************************
2646 reads or writes a structure.
2647 ********************************************************************/
2649 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2650 prs_struct *ps, int depth)
2655 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2661 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2664 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2670 /*******************************************************************
2671 inits a SAMR_R_SET_GROUPINFO structure.
2672 ********************************************************************/
2674 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2676 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2678 r_u->status = status;
2681 /*******************************************************************
2682 reads or writes a structure.
2683 ********************************************************************/
2685 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2686 prs_struct *ps, int depth)
2691 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2697 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2703 /*******************************************************************
2704 inits a SAMR_Q_QUERY_GROUPINFO structure.
2705 ********************************************************************/
2707 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2708 POLICY_HND *pol, uint16 switch_level)
2710 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2714 q_e->switch_level = switch_level;
2717 /*******************************************************************
2718 reads or writes a structure.
2719 ********************************************************************/
2721 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2722 prs_struct *ps, int depth)
2727 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2733 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2736 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2742 /*******************************************************************
2743 inits a SAMR_R_QUERY_GROUPINFO structure.
2744 ********************************************************************/
2746 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2747 GROUP_INFO_CTR * ctr, NTSTATUS status)
2749 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2751 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2753 r_u->status = status;
2756 /*******************************************************************
2757 reads or writes a structure.
2758 ********************************************************************/
2760 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2761 prs_struct *ps, int depth)
2766 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2772 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2775 if (r_u->ptr != 0) {
2776 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2782 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2788 /*******************************************************************
2789 inits a SAMR_Q_QUERY_GROUPMEM structure.
2790 ********************************************************************/
2792 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2794 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2796 q_c->group_pol = *hnd;
2799 /*******************************************************************
2800 reads or writes a structure.
2801 ********************************************************************/
2803 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2804 prs_struct *ps, int depth)
2809 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2815 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2821 /*******************************************************************
2822 inits a SAMR_R_QUERY_GROUPMEM structure.
2823 ********************************************************************/
2825 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2826 uint32 num_entries, uint32 *rid,
2827 uint32 *attr, NTSTATUS status)
2829 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2831 if (NT_STATUS_IS_OK(status)) {
2833 r_u->num_entries = num_entries;
2835 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2836 r_u->ptr_rids = rid != NULL ? 1 : 0;
2838 r_u->num_rids = num_entries;
2841 r_u->num_attrs = num_entries;
2845 r_u->num_entries = 0;
2848 r_u->status = status;
2851 /*******************************************************************
2852 reads or writes a structure.
2853 ********************************************************************/
2855 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2856 prs_struct *ps, int depth)
2863 if (UNMARSHALLING(ps))
2866 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2872 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2874 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2877 if (r_u->ptr != 0) {
2878 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2880 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2883 if (r_u->ptr_rids != 0) {
2884 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2886 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2887 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2888 if (r_u->rid == NULL)
2892 for (i = 0; i < r_u->num_rids; i++) {
2893 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2898 if (r_u->ptr_attrs != 0) {
2899 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2902 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2903 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2904 if (r_u->attr == NULL)
2908 for (i = 0; i < r_u->num_attrs; i++) {
2909 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2921 /*******************************************************************
2922 inits a SAMR_Q_QUERY_USERGROUPS structure.
2923 ********************************************************************/
2925 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2928 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2933 /*******************************************************************
2934 reads or writes a structure.
2935 ********************************************************************/
2937 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2938 prs_struct *ps, int depth)
2943 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2949 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2955 /*******************************************************************
2956 inits a SAMR_R_QUERY_USERGROUPS structure.
2957 ********************************************************************/
2959 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2960 uint32 num_gids, DOM_GID * gid,
2963 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2965 if (NT_STATUS_IS_OK(status)) {
2967 r_u->num_entries = num_gids;
2968 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2969 r_u->num_entries2 = num_gids;
2974 r_u->num_entries = 0;
2979 r_u->status = status;
2982 /*******************************************************************
2983 reads or writes a structure.
2984 ********************************************************************/
2986 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
2987 prs_struct *ps, int depth)
2993 prs_debug(ps, depth, desc, "samr_io_gids");
2999 if(!prs_uint32("num_gids", ps, depth, num_gids))
3002 if ((*num_gids) != 0) {
3003 if (UNMARSHALLING(ps)) {
3004 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3007 if ((*gid) == NULL) {
3011 for (i = 0; i < (*num_gids); i++) {
3012 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3020 /*******************************************************************
3021 reads or writes a structure.
3022 ********************************************************************/
3024 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3025 prs_struct *ps, int depth)
3030 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3036 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3039 if (r_u->ptr_0 != 0) {
3040 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3042 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3045 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3046 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3053 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3059 /*******************************************************************
3060 inits a SAMR_Q_ENUM_DOMAINS structure.
3061 ********************************************************************/
3063 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3065 uint32 start_idx, uint32 size)
3067 DEBUG(5, ("init_samr_q_enum_domains\n"));
3071 q_e->start_idx = start_idx;
3072 q_e->max_size = size;
3075 /*******************************************************************
3076 reads or writes a structure.
3077 ********************************************************************/
3079 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3080 prs_struct *ps, int depth)
3085 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3091 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3094 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3096 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3102 /*******************************************************************
3103 inits a SAMR_R_ENUM_DOMAINS structure.
3104 ********************************************************************/
3106 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3107 uint32 next_idx, uint32 num_sam_entries)
3109 DEBUG(5, ("init_samr_r_enum_domains\n"));
3111 r_u->next_idx = next_idx;
3113 if (num_sam_entries != 0) {
3114 r_u->ptr_entries1 = 1;
3115 r_u->ptr_entries2 = 1;
3116 r_u->num_entries2 = num_sam_entries;
3117 r_u->num_entries3 = num_sam_entries;
3119 r_u->num_entries4 = num_sam_entries;
3121 r_u->ptr_entries1 = 0;
3122 r_u->num_entries2 = num_sam_entries;
3123 r_u->ptr_entries2 = 1;
3127 /*******************************************************************
3128 reads or writes a structure.
3129 ********************************************************************/
3131 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3132 prs_struct *ps, int depth)
3139 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3145 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3147 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3150 if (r_u->ptr_entries1 != 0) {
3151 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3153 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3155 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3158 if (UNMARSHALLING(ps)) {
3159 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3160 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3163 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3164 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3165 r_u->num_entries4 = 0;
3166 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3170 for (i = 0; i < r_u->num_entries2; i++) {
3172 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3173 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3177 for (i = 0; i < r_u->num_entries2; i++) {
3179 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3180 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3181 r_u->sam[i].hdr_name.buffer, ps,
3190 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3192 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3198 /*******************************************************************
3199 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3200 ********************************************************************/
3202 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3204 uint32 start_idx, uint32 size)
3206 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3210 q_e->start_idx = start_idx;
3211 q_e->max_size = size;
3214 /*******************************************************************
3215 reads or writes a structure.
3216 ********************************************************************/
3218 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3219 prs_struct *ps, int depth)
3224 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3230 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3233 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3235 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3241 /*******************************************************************
3242 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3243 ********************************************************************/
3245 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3246 uint32 next_idx, uint32 num_sam_entries)
3248 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3250 r_u->next_idx = next_idx;
3252 if (num_sam_entries != 0) {
3253 r_u->ptr_entries1 = 1;
3254 r_u->ptr_entries2 = 1;
3255 r_u->num_entries2 = num_sam_entries;
3256 r_u->num_entries3 = num_sam_entries;
3258 r_u->num_entries4 = num_sam_entries;
3260 r_u->ptr_entries1 = 0;
3261 r_u->num_entries2 = num_sam_entries;
3262 r_u->ptr_entries2 = 1;
3266 /*******************************************************************
3267 reads or writes a structure.
3268 ********************************************************************/
3270 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3271 prs_struct *ps, int depth)
3278 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3284 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3286 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3289 if (r_u->ptr_entries1 != 0) {
3290 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3292 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3294 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3297 if (UNMARSHALLING(ps)) {
3298 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3299 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3302 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3304 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3305 r_u->num_entries4 = 0;
3306 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3310 for (i = 0; i < r_u->num_entries2; i++) {
3311 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3315 for (i = 0; i < r_u->num_entries2; i++) {
3316 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3317 r_u->sam[i].hdr_name.buffer, ps, depth))
3324 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3326 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3332 /*******************************************************************
3333 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3334 ********************************************************************/
3336 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3337 POLICY_HND *pol, uint32 start_idx,
3340 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3344 q_e->start_idx = start_idx;
3345 q_e->max_size = size;
3349 /*******************************************************************
3350 reads or writes a structure.
3351 ********************************************************************/
3353 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3354 prs_struct *ps, int depth)
3359 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3365 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3368 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3370 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3376 /*******************************************************************
3377 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3378 ********************************************************************/
3380 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3382 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3384 r_u->next_idx = next_idx;
3386 if (num_sam_entries != 0) {
3387 r_u->ptr_entries1 = 1;
3388 r_u->ptr_entries2 = 1;
3389 r_u->num_entries2 = num_sam_entries;
3390 r_u->num_entries3 = num_sam_entries;
3392 r_u->num_entries4 = num_sam_entries;
3394 r_u->ptr_entries1 = 0;
3395 r_u->num_entries2 = num_sam_entries;
3396 r_u->ptr_entries2 = 1;
3400 /*******************************************************************
3401 reads or writes a structure.
3402 ********************************************************************/
3404 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3405 prs_struct *ps, int depth)
3412 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3418 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3420 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3423 if (r_u->ptr_entries1 != 0) {
3424 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3426 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3428 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3431 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3432 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3433 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3436 if (r_u->num_entries2 != 0 &&
3437 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3438 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3439 r_u->num_entries4 = 0;
3440 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3444 for (i = 0; i < r_u->num_entries2; i++) {
3445 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3449 for (i = 0; i < r_u->num_entries2; i++) {
3450 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3451 r_u->sam[i].hdr_name.buffer, ps,
3459 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3461 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3467 /*******************************************************************
3468 inits a ALIAS_INFO1 structure.
3469 ********************************************************************/
3471 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3473 DEBUG(5, ("init_samr_alias_info1\n"));
3475 init_unistr2(&al1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
3476 init_uni_hdr(&al1->hdr_acct_name, &al1->uni_acct_name);
3478 al1->num_member=num_member;
3480 init_unistr2(&al1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3481 init_uni_hdr(&al1->hdr_acct_desc, &al1->uni_acct_name);
3484 /*******************************************************************
3485 reads or writes a structure.
3486 ********************************************************************/
3488 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3489 prs_struct *ps, int depth)
3494 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3500 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3502 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3504 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3507 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3508 al1->hdr_acct_name.buffer, ps, depth))
3514 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3515 al1->hdr_acct_desc.buffer, ps, depth))
3521 /*******************************************************************
3522 inits a ALIAS_INFO3 structure.
3523 ********************************************************************/
3525 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3527 DEBUG(5, ("init_samr_alias_info3\n"));
3529 init_unistr2(&al3->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3530 init_uni_hdr(&al3->hdr_acct_desc, &al3->uni_acct_desc);
3533 /*******************************************************************
3534 reads or writes a structure.
3535 ********************************************************************/
3537 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
3538 prs_struct *ps, int depth)
3543 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3549 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3551 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3552 al3->hdr_acct_desc.buffer, ps, depth))
3558 /*******************************************************************
3559 reads or writes a structure.
3560 ********************************************************************/
3562 BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr,
3563 prs_struct *ps, int depth)
3568 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3571 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3573 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3576 switch (ctr->switch_value1) {
3578 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3582 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3586 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3593 /*******************************************************************
3594 inits a SAMR_Q_QUERY_ALIASINFO structure.
3595 ********************************************************************/
3597 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3598 POLICY_HND *pol, uint16 switch_level)
3600 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3603 q_e->switch_level = switch_level;
3606 /*******************************************************************
3607 reads or writes a structure.
3608 ********************************************************************/
3610 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3611 prs_struct *ps, int depth)
3616 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3622 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3625 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3631 /*******************************************************************
3632 inits a SAMR_R_QUERY_ALIASINFO structure.
3633 ********************************************************************/
3635 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3636 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3638 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3640 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3642 r_u->status = status;
3645 /*******************************************************************
3646 reads or writes a structure.
3647 ********************************************************************/
3649 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3650 prs_struct *ps, int depth)
3655 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3661 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3664 if (r_u->ptr != 0) {
3665 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3671 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3677 /*******************************************************************
3678 inits a SAMR_Q_SET_ALIASINFO structure.
3679 ********************************************************************/
3681 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3682 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3684 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3686 q_u->alias_pol = *hnd;
3690 /*******************************************************************
3691 reads or writes a structure.
3692 ********************************************************************/
3694 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3695 prs_struct *ps, int depth)
3700 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3706 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3708 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3714 /*******************************************************************
3715 reads or writes a structure.
3716 ********************************************************************/
3718 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3719 prs_struct *ps, int depth)
3724 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3729 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3735 /*******************************************************************
3736 inits a SAMR_Q_QUERY_USERALIASES structure.
3737 ********************************************************************/
3739 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3742 uint32 *ptr_sid, DOM_SID2 * sid)
3744 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3748 q_u->num_sids1 = num_sids;
3750 q_u->num_sids2 = num_sids;
3752 q_u->ptr_sid = ptr_sid;
3756 /*******************************************************************
3757 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3758 ********************************************************************/
3760 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3761 prs_struct *ps, int depth)
3769 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3775 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3778 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3780 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3786 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3789 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3790 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3791 if (q_u->ptr_sid == NULL)
3794 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3795 if (q_u->sid == NULL)
3799 for (i = 0; i < q_u->num_sids2; i++) {
3800 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3801 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3805 for (i = 0; i < q_u->num_sids2; i++) {
3806 if (q_u->ptr_sid[i] != 0) {
3807 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3808 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3816 /*******************************************************************
3817 inits a SAMR_R_QUERY_USERALIASES structure.
3818 ********************************************************************/
3820 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3821 uint32 num_rids, uint32 *rid,
3824 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3826 if (NT_STATUS_IS_OK(status)) {
3827 r_u->num_entries = num_rids;
3829 r_u->num_entries2 = num_rids;
3833 r_u->num_entries = 0;
3835 r_u->num_entries2 = 0;
3838 r_u->status = status;
3841 /*******************************************************************
3842 reads or writes a structure.
3843 ********************************************************************/
3845 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3846 prs_struct *ps, int depth)
3853 prs_debug(ps, depth, desc, "samr_io_rids");
3859 if(!prs_uint32("num_rids", ps, depth, num_rids))
3862 if ((*num_rids) != 0) {
3863 if (UNMARSHALLING(ps)) {
3865 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3870 for (i = 0; i < (*num_rids); i++) {
3871 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3872 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3880 /*******************************************************************
3881 reads or writes a structure.
3882 ********************************************************************/
3884 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3885 prs_struct *ps, int depth)
3890 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3896 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3898 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3901 if (r_u->ptr != 0) {
3902 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3908 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3914 /*******************************************************************
3915 inits a SAMR_Q_OPEN_ALIAS structure.
3916 ********************************************************************/
3918 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3919 uint32 access_mask, uint32 rid)
3921 DEBUG(5, ("init_samr_q_open_alias\n"));
3923 q_u->dom_pol = *pol;
3924 q_u->access_mask = access_mask;
3925 q_u->rid_alias = rid;
3928 /*******************************************************************
3929 reads or writes a structure.
3930 ********************************************************************/
3932 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3933 prs_struct *ps, int depth)
3938 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3944 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3947 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3949 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3955 /*******************************************************************
3956 reads or writes a structure.
3957 ********************************************************************/
3959 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
3960 prs_struct *ps, int depth)
3965 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3971 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3974 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3980 /*******************************************************************
3981 inits a SAMR_Q_LOOKUP_RIDS structure.
3982 ********************************************************************/
3984 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3985 POLICY_HND *pol, uint32 flags,
3986 uint32 num_rids, uint32 *rid)
3988 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3992 q_u->num_rids1 = num_rids;
3995 q_u->num_rids2 = num_rids;
3996 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
3997 if (q_u->rid == NULL) {
4001 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4005 /*******************************************************************
4006 reads or writes a structure.
4007 ********************************************************************/
4009 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4010 prs_struct *ps, int depth)
4018 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4021 if (UNMARSHALLING(ps))
4027 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4030 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4032 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4034 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4036 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4039 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4040 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4041 if (q_u->rid == NULL)
4045 for (i = 0; i < q_u->num_rids2; i++) {
4046 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4047 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4054 /*******************************************************************
4055 inits a SAMR_R_LOOKUP_RIDS structure.
4056 ********************************************************************/
4058 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4059 uint32 num_names, UNIHDR * hdr_name,
4060 UNISTR2 *uni_name, uint32 *type)
4062 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4064 r_u->hdr_name = NULL;
4065 r_u->uni_name = NULL;
4068 if (num_names != 0) {
4069 r_u->num_names1 = num_names;
4071 r_u->num_names2 = num_names;
4073 r_u->num_types1 = num_names;
4075 r_u->num_types2 = num_names;
4077 r_u->hdr_name = hdr_name;
4078 r_u->uni_name = uni_name;
4081 r_u->num_names1 = num_names;
4083 r_u->num_names2 = num_names;
4085 r_u->num_types1 = num_names;
4087 r_u->num_types2 = num_names;
4091 /*******************************************************************
4092 reads or writes a structure.
4093 ********************************************************************/
4095 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4096 prs_struct *ps, int depth)
4103 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4109 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4111 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4114 if (r_u->ptr_names != 0) {
4116 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4120 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4121 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4122 if (r_u->hdr_name == NULL)
4125 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4126 if (r_u->uni_name == NULL)
4130 for (i = 0; i < r_u->num_names2; i++) {
4131 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4132 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4135 for (i = 0; i < r_u->num_names2; i++) {
4136 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4137 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4145 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4147 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4150 if (r_u->ptr_types != 0) {
4152 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4155 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4156 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4157 if (r_u->type == NULL)
4161 for (i = 0; i < r_u->num_types2; i++) {
4162 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4163 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4168 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4174 /*******************************************************************
4175 inits a SAMR_Q_OPEN_ALIAS structure.
4176 ********************************************************************/
4178 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4180 DEBUG(5, ("init_samr_q_delete_alias\n"));
4182 q_u->alias_pol = *hnd;
4185 /*******************************************************************
4186 reads or writes a structure.
4187 ********************************************************************/
4189 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4190 prs_struct *ps, int depth)
4195 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4201 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4207 /*******************************************************************
4208 reads or writes a structure.
4209 ********************************************************************/
4211 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4212 prs_struct *ps, int depth)
4217 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4223 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4225 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4231 /*******************************************************************
4232 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4233 ********************************************************************/
4235 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4236 POLICY_HND *hnd, const char *acct_desc)
4238 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4240 q_u->dom_pol = *hnd;
4242 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4243 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4245 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4248 /*******************************************************************
4249 reads or writes a structure.
4250 ********************************************************************/
4252 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4253 prs_struct *ps, int depth)
4258 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4264 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4267 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4269 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4270 q_u->hdr_acct_desc.buffer, ps, depth))
4275 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4281 /*******************************************************************
4282 reads or writes a structure.
4283 ********************************************************************/
4285 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4286 prs_struct *ps, int depth)
4291 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4297 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4300 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4303 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4309 /*******************************************************************
4310 inits a SAMR_Q_ADD_ALIASMEM structure.
4311 ********************************************************************/
4313 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4316 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4318 q_u->alias_pol = *hnd;
4319 init_dom_sid2(&q_u->sid, sid);
4322 /*******************************************************************
4323 reads or writes a structure.
4324 ********************************************************************/
4326 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4327 prs_struct *ps, int depth)
4332 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4338 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4340 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4346 /*******************************************************************
4347 reads or writes a structure.
4348 ********************************************************************/
4350 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4351 prs_struct *ps, int depth)
4356 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4362 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4368 /*******************************************************************
4369 inits a SAMR_Q_DEL_ALIASMEM structure.
4370 ********************************************************************/
4372 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4375 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4377 q_u->alias_pol = *hnd;
4378 init_dom_sid2(&q_u->sid, sid);
4381 /*******************************************************************
4382 reads or writes a structure.
4383 ********************************************************************/
4385 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4386 prs_struct *ps, int depth)
4391 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4397 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4399 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4405 /*******************************************************************
4406 reads or writes a structure.
4407 ********************************************************************/
4409 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4410 prs_struct *ps, int depth)
4415 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4421 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4427 /*******************************************************************
4428 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4429 ********************************************************************/
4431 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4434 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4436 q_c->alias_pol = *hnd;
4439 /*******************************************************************
4440 reads or writes a structure.
4441 ********************************************************************/
4443 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4444 prs_struct *ps, int depth)
4449 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4455 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4461 /*******************************************************************
4462 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4463 ********************************************************************/
4465 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4468 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4470 r_u->status = status;
4473 /*******************************************************************
4474 reads or writes a structure.
4475 ********************************************************************/
4477 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4478 prs_struct *ps, int depth)
4483 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4489 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4495 /*******************************************************************
4496 inits a SAMR_Q_QUERY_ALIASMEM structure.
4497 ********************************************************************/
4499 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4502 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4504 q_c->alias_pol = *hnd;
4507 /*******************************************************************
4508 reads or writes a structure.
4509 ********************************************************************/
4511 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4512 prs_struct *ps, int depth)
4517 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4523 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4529 /*******************************************************************
4530 inits a SAMR_R_QUERY_ALIASMEM structure.
4531 ********************************************************************/
4533 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4534 uint32 num_sids, DOM_SID2 * sid,
4537 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4539 if (NT_STATUS_IS_OK(status)) {
4540 r_u->num_sids = num_sids;
4541 r_u->ptr = (num_sids != 0) ? 1 : 0;
4542 r_u->num_sids1 = num_sids;
4550 r_u->status = status;
4553 /*******************************************************************
4554 reads or writes a structure.
4555 ********************************************************************/
4557 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4558 prs_struct *ps, int depth)
4565 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4571 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4573 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4576 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4577 uint32 *ptr_sid = NULL;
4579 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4582 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4587 for (i = 0; i < r_u->num_sids1; i++) {
4589 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4593 if (UNMARSHALLING(ps)) {
4594 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4597 for (i = 0; i < r_u->num_sids1; i++) {
4598 if (ptr_sid[i] != 0) {
4599 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4607 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4613 /*******************************************************************
4614 inits a SAMR_Q_LOOKUP_NAMES structure.
4615 ********************************************************************/
4617 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4618 POLICY_HND *pol, uint32 flags,
4619 uint32 num_names, const char **name)
4623 DEBUG(5, ("init_samr_q_lookup_names\n"));
4627 q_u->num_names1 = num_names;
4630 q_u->num_names2 = num_names;
4632 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4633 return NT_STATUS_NO_MEMORY;
4635 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4636 return NT_STATUS_NO_MEMORY;
4638 for (i = 0; i < num_names; i++) {
4639 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4640 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4643 return NT_STATUS_OK;
4646 /*******************************************************************
4647 reads or writes a structure.
4648 ********************************************************************/
4650 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4651 prs_struct *ps, int depth)
4658 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4661 if (UNMARSHALLING(ps))
4667 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4670 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4672 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4674 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4676 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4679 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4680 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4681 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4682 if (!q_u->hdr_name || !q_u->uni_name)
4686 for (i = 0; i < q_u->num_names2; i++) {
4687 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4691 for (i = 0; i < q_u->num_names2; i++) {
4692 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4699 /*******************************************************************
4700 inits a SAMR_R_LOOKUP_NAMES structure.
4701 ********************************************************************/
4703 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4705 uint32 *rid, uint32 *type,
4708 DEBUG(5, ("init_samr_r_lookup_names\n"));
4710 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4713 r_u->num_types1 = num_rids;
4715 r_u->num_types2 = num_rids;
4717 r_u->num_rids1 = num_rids;
4719 r_u->num_rids2 = num_rids;
4721 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4722 return NT_STATUS_NO_MEMORY;
4723 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4724 return NT_STATUS_NO_MEMORY;
4726 if (!r_u->rids || !r_u->types)
4729 for (i = 0; i < num_rids; i++) {
4730 r_u->rids[i] = rid[i];
4731 r_u->types[i] = type[i];
4736 r_u->num_types1 = 0;
4738 r_u->num_types2 = 0;
4748 r_u->status = status;
4750 return NT_STATUS_OK;
4753 /*******************************************************************
4754 reads or writes a structure.
4755 ********************************************************************/
4757 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4758 prs_struct *ps, int depth)
4766 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4769 if (UNMARSHALLING(ps))
4775 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4777 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4780 if (r_u->ptr_rids != 0) {
4781 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4784 if (r_u->num_rids2 != r_u->num_rids1) {
4789 if (UNMARSHALLING(ps))
4790 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4793 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4797 for (i = 0; i < r_u->num_rids2; i++) {
4798 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4799 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4804 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4806 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4809 if (r_u->ptr_types != 0) {
4810 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4813 if (r_u->num_types2 != r_u->num_types1) {
4818 if (UNMARSHALLING(ps))
4819 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4822 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4826 for (i = 0; i < r_u->num_types2; i++) {
4827 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4828 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4833 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4839 /*******************************************************************
4840 inits a SAMR_Q_DELETE_DOM_USER structure.
4841 ********************************************************************/
4843 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4846 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4848 q_c->user_pol = *hnd;
4851 /*******************************************************************
4852 reads or writes a structure.
4853 ********************************************************************/
4855 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4856 prs_struct *ps, int depth)
4861 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4867 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4873 /*******************************************************************
4874 reads or writes a structure.
4875 ********************************************************************/
4877 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4878 prs_struct *ps, int depth)
4883 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4889 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4891 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4897 /*******************************************************************
4898 reads or writes a structure.
4899 ********************************************************************/
4901 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4903 uint32 access_mask, uint32 rid)
4905 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4907 q_u->domain_pol = *pol;
4908 q_u->access_mask = access_mask;
4909 q_u->user_rid = rid;
4912 /*******************************************************************
4913 reads or writes a structure.
4914 ********************************************************************/
4916 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4917 prs_struct *ps, int depth)
4922 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4928 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4931 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4933 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4939 /*******************************************************************
4940 reads or writes a structure.
4941 ********************************************************************/
4943 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4944 prs_struct *ps, int depth)
4949 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4955 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4958 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4965 /*******************************************************************
4966 reads or writes a structure.
4967 ********************************************************************/
4969 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4972 uint32 acb_info, uint32 access_mask)
4974 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4976 q_u->domain_pol = *pol;
4978 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
4979 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
4981 q_u->acb_info = acb_info;
4982 q_u->access_mask = access_mask;
4985 /*******************************************************************
4986 reads or writes a structure.
4987 ********************************************************************/
4989 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
4990 prs_struct *ps, int depth)
4995 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5001 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5004 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5006 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5011 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5013 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5019 /*******************************************************************
5020 reads or writes a structure.
5021 ********************************************************************/
5023 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5024 prs_struct *ps, int depth)
5029 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5035 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5038 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5040 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5042 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5048 /*******************************************************************
5049 inits a SAMR_Q_QUERY_USERINFO structure.
5050 ********************************************************************/
5052 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5053 POLICY_HND *hnd, uint16 switch_value)
5055 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5058 q_u->switch_value = switch_value;
5061 /*******************************************************************
5062 reads or writes a structure.
5063 ********************************************************************/
5065 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5066 prs_struct *ps, int depth)
5071 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5077 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5080 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5086 /*******************************************************************
5087 reads or writes a LOGON_HRS structure.
5088 ********************************************************************/
5090 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5091 prs_struct *ps, int depth)
5096 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5102 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5105 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5108 if(!prs_uint32("len ", ps, depth, &hrs->len))
5111 if (hrs->len > sizeof(hrs->hours)) {
5112 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5113 hrs->len = sizeof(hrs->hours);
5116 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5122 /*******************************************************************
5123 inits a SAM_USER_INFO_12 structure.
5124 ********************************************************************/
5126 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5127 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5129 DEBUG(5, ("init_sam_user_info12\n"));
5131 usr->lm_pwd_active =
5132 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5133 usr->nt_pwd_active =
5134 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5137 /*******************************************************************
5138 reads or writes a structure.
5139 ********************************************************************/
5141 static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u,
5142 prs_struct *ps, int depth)
5147 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5153 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5155 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5158 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5160 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5166 /*******************************************************************
5167 inits a SAM_USER_INFO_7 structure.
5168 ********************************************************************/
5170 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5172 DEBUG(5, ("init_sam_user_info7\n"));
5174 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5175 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5179 /*******************************************************************
5180 reads or writes a structure.
5181 ********************************************************************/
5183 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5184 prs_struct *ps, int depth)
5189 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5195 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5198 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5204 /*******************************************************************
5205 inits a SAM_USER_INFO_10 structure.
5206 ********************************************************************/
5208 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5210 DEBUG(5, ("init_sam_user_info10\n"));
5212 usr->acb_info = acb_info;
5215 /*******************************************************************
5216 reads or writes a structure.
5217 ********************************************************************/
5219 static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr,
5220 prs_struct *ps, int depth)
5225 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5231 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5237 /*******************************************************************
5238 inits a SAM_USER_INFO_11 structure.
5239 ********************************************************************/
5241 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5244 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5246 DEBUG(5, ("init_sam_user_info11\n"));
5248 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5249 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5251 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5253 usr->ptr_1 = 1; /* pointer */
5254 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5255 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5257 usr->ptr_2 = 1; /* pointer */
5258 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5260 usr->ptr_3 = 1; /* pointer */
5261 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5263 usr->rid_user = rid_user;
5264 usr->rid_group = rid_group;
5266 usr->acct_ctrl = acct_ctrl;
5267 usr->unknown_3 = 0x0000;
5269 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5270 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5272 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5273 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5275 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5276 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5279 /*******************************************************************
5280 reads or writes a structure.
5281 ********************************************************************/
5283 static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr,
5284 prs_struct *ps, int depth)
5289 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5295 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5298 if(!smb_io_time("time", &usr->expiry, ps, depth))
5301 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5304 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5307 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5310 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5312 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5315 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5318 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5320 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5323 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5325 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5328 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5330 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5332 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5334 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5336 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5338 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5341 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5344 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5347 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5353 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5359 /*************************************************************************
5361 *************************************************************************/
5363 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5365 DEBUG(10, ("init_sam_user_info24:\n"));
5366 memcpy(usr->pass, newpass, sizeof(usr->pass));
5367 usr->pw_len = pw_len;
5370 /*******************************************************************
5371 reads or writes a structure.
5372 ********************************************************************/
5374 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5375 prs_struct *ps, int depth)
5380 prs_debug(ps, depth, desc, "sam_io_user_info24");
5386 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5390 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5391 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5400 /*************************************************************************
5401 init_sam_user_info23
5403 unknown_6 = 0x0000 04ec
5405 *************************************************************************/
5407 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5408 NTTIME * logoff_time, /* all zeros */
5409 NTTIME * kickoff_time, /* all zeros */
5410 NTTIME * pass_last_set_time, /* all zeros */
5411 NTTIME * pass_can_change_time, /* all zeros */
5412 NTTIME * pass_must_change_time, /* all zeros */
5423 uint32 user_rid, /* 0x0000 0000 */
5426 uint32 fields_present,
5429 uint16 bad_password_count,
5433 usr->logon_time = *logon_time; /* all zeros */
5434 usr->logoff_time = *logoff_time; /* all zeros */
5435 usr->kickoff_time = *kickoff_time; /* all zeros */
5436 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5437 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5438 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5440 ZERO_STRUCT(usr->nt_pwd);
5441 ZERO_STRUCT(usr->lm_pwd);
5443 usr->user_rid = user_rid; /* 0x0000 0000 */
5444 usr->group_rid = group_rid;
5445 usr->acb_info = acb_info;
5446 usr->fields_present = fields_present; /* 09f8 27fa */
5448 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5449 usr->ptr_logon_hrs = hrs ? 1 : 0;
5451 if (nt_time_is_zero(pass_must_change_time)) {
5452 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5454 usr->passmustchange=0;
5457 ZERO_STRUCT(usr->padding1);
5458 ZERO_STRUCT(usr->padding2);
5460 usr->bad_password_count = bad_password_count;
5461 usr->logon_count = logon_count;
5463 memcpy(usr->pass, newpass, sizeof(usr->pass));
5465 copy_unistr2(&usr->uni_user_name, user_name);
5466 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5468 copy_unistr2(&usr->uni_full_name, full_name);
5469 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5471 copy_unistr2(&usr->uni_home_dir, home_dir);
5472 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5474 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5475 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5477 copy_unistr2(&usr->uni_logon_script, log_scr);
5478 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5480 copy_unistr2(&usr->uni_profile_path, prof_path);
5481 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5483 copy_unistr2(&usr->uni_acct_desc, desc);
5484 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5486 copy_unistr2(&usr->uni_workstations, wkstas);
5487 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5489 copy_unistr2(&usr->uni_unknown_str, unk_str);
5490 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5492 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5493 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5495 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5498 /*************************************************************************
5499 init_sam_user_info23
5501 unknown_6 = 0x0000 04ec
5503 *************************************************************************/
5505 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5506 NTTIME * logoff_time, /* all zeros */
5507 NTTIME * kickoff_time, /* all zeros */
5508 NTTIME * pass_last_set_time, /* all zeros */
5509 NTTIME * pass_can_change_time, /* all zeros */
5510 NTTIME * pass_must_change_time, /* all zeros */
5511 char *user_name, /* NULL */
5513 char *home_dir, char *dir_drive, char *log_scr,
5514 char *prof_path, const char *desc, char *wkstas,
5515 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5516 uint32 group_rid, uint32 acb_info,
5517 uint32 fields_present, uint16 logon_divs,
5518 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5521 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5523 usr->logon_time = *logon_time; /* all zeros */
5524 usr->logoff_time = *logoff_time; /* all zeros */
5525 usr->kickoff_time = *kickoff_time; /* all zeros */
5526 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5527 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5528 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5530 ZERO_STRUCT(usr->nt_pwd);
5531 ZERO_STRUCT(usr->lm_pwd);
5533 usr->user_rid = user_rid; /* 0x0000 0000 */
5534 usr->group_rid = group_rid;
5535 usr->acb_info = acb_info;
5536 usr->fields_present = fields_present; /* 09f8 27fa */
5538 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5539 usr->ptr_logon_hrs = hrs ? 1 : 0;
5541 if (nt_time_is_zero(pass_must_change_time)) {
5542 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5544 usr->passmustchange=0;
5547 ZERO_STRUCT(usr->padding1);
5548 ZERO_STRUCT(usr->padding2);
5550 usr->bad_password_count = bad_password_count;
5551 usr->logon_count = logon_count;
5553 memcpy(usr->pass, newpass, sizeof(usr->pass));
5555 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5556 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5558 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5559 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5561 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5562 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5564 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5565 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5567 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5568 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5570 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5571 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5573 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5574 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5576 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5577 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5579 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5580 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5582 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5583 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5585 data_blob_free(&blob);
5587 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5590 /*******************************************************************
5591 reads or writes a structure.
5592 ********************************************************************/
5594 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5595 prs_struct *ps, int depth)
5600 prs_debug(ps, depth, desc, "sam_io_user_info23");
5606 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5608 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5610 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5612 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5614 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5616 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5619 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5621 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5623 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5625 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5627 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5629 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5631 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5633 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5635 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5637 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5640 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5642 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5645 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5647 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5649 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5652 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5654 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5658 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5661 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5663 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5666 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5668 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5670 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5674 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5677 /* here begins pointed-to data */
5679 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5682 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5685 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5688 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5691 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5694 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5697 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5700 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5703 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5706 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5709 /* ok, this is only guess-work (as usual) */
5710 if (usr->ptr_logon_hrs) {
5711 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5718 /*******************************************************************
5719 reads or writes a structure.
5720 NB. This structure is *definately* incorrect. It's my best guess
5721 currently for W2K SP2. The password field is encrypted in a different
5722 way than normal... And there are definately other problems. JRA.
5723 ********************************************************************/
5725 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5730 prs_debug(ps, depth, desc, "sam_io_user_info25");
5736 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5738 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5740 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5742 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5744 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5746 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5749 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5751 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5753 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5755 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5757 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5759 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5761 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5763 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5765 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5767 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5770 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5772 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5775 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5777 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5779 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5782 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5785 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5788 /* here begins pointed-to data */
5790 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5793 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5796 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5799 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5802 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5805 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5808 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5811 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5814 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5817 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5820 #if 0 /* JRA - unknown... */
5821 /* ok, this is only guess-work (as usual) */
5822 if (usr->ptr_logon_hrs) {
5823 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5832 /*************************************************************************
5833 init_sam_user_info21W
5835 unknown_6 = 0x0000 04ec
5837 *************************************************************************/
5839 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5840 NTTIME * logon_time,
5841 NTTIME * logoff_time,
5842 NTTIME * kickoff_time,
5843 NTTIME * pass_last_set_time,
5844 NTTIME * pass_can_change_time,
5845 NTTIME * pass_must_change_time,
5861 uint32 fields_present,
5864 uint16 bad_password_count,
5867 usr->logon_time = *logon_time;
5868 usr->logoff_time = *logoff_time;
5869 usr->kickoff_time = *kickoff_time;
5870 usr->pass_last_set_time = *pass_last_set_time;
5871 usr->pass_can_change_time = *pass_can_change_time;
5872 usr->pass_must_change_time = *pass_must_change_time;
5874 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5875 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5877 usr->user_rid = user_rid;
5878 usr->group_rid = group_rid;
5879 usr->acb_info = acb_info;
5880 usr->fields_present = fields_present; /* 0x00ff ffff */
5882 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5883 usr->ptr_logon_hrs = hrs ? 1 : 0;
5884 usr->bad_password_count = bad_password_count;
5885 usr->logon_count = logon_count;
5887 if (nt_time_is_zero(pass_must_change_time)) {
5888 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5890 usr->passmustchange=0;
5893 ZERO_STRUCT(usr->padding1);
5894 ZERO_STRUCT(usr->padding2);
5896 copy_unistr2(&usr->uni_user_name, user_name);
5897 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5899 copy_unistr2(&usr->uni_full_name, full_name);
5900 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5902 copy_unistr2(&usr->uni_home_dir, home_dir);
5903 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5905 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5906 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5908 copy_unistr2(&usr->uni_logon_script, log_scr);
5909 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5911 copy_unistr2(&usr->uni_profile_path, prof_path);
5912 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5914 copy_unistr2(&usr->uni_acct_desc, desc);
5915 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5917 copy_unistr2(&usr->uni_workstations, wkstas);
5918 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5920 copy_unistr2(&usr->uni_unknown_str, unk_str);
5921 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5923 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5924 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5926 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5929 /*************************************************************************
5930 init_sam_user_info21
5932 unknown_6 = 0x0000 04ec
5934 *************************************************************************/
5936 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5938 NTTIME logon_time, logoff_time, kickoff_time,
5939 pass_last_set_time, pass_can_change_time,
5940 pass_must_change_time;
5942 const char* user_name = pdb_get_username(pw);
5943 const char* full_name = pdb_get_fullname(pw);
5944 const char* home_dir = pdb_get_homedir(pw);
5945 const char* dir_drive = pdb_get_dir_drive(pw);
5946 const char* logon_script = pdb_get_logon_script(pw);
5947 const char* profile_path = pdb_get_profile_path(pw);
5948 const char* description = pdb_get_acct_desc(pw);
5949 const char* workstations = pdb_get_workstations(pw);
5950 const char* munged_dial = pdb_get_munged_dial(pw);
5951 DATA_BLOB munged_dial_blob;
5954 const DOM_SID *user_sid;
5957 const DOM_SID *group_sid;
5960 munged_dial_blob = base64_decode_data_blob(munged_dial);
5962 munged_dial_blob = data_blob(NULL, 0);
5965 /* Create NTTIME structs */
5966 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5967 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5968 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5969 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5970 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
5971 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
5973 /* structure assignment */
5974 usr->logon_time = logon_time;
5975 usr->logoff_time = logoff_time;
5976 usr->kickoff_time = kickoff_time;
5977 usr->pass_last_set_time = pass_last_set_time;
5978 usr->pass_can_change_time = pass_can_change_time;
5979 usr->pass_must_change_time = pass_must_change_time;
5981 ZERO_STRUCT(usr->nt_pwd);
5982 ZERO_STRUCT(usr->lm_pwd);
5984 user_sid = pdb_get_user_sid(pw);
5986 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
5987 fstring user_sid_string;
5988 fstring domain_sid_string;
5989 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
5990 "the domain sid %s. Failing operation.\n",
5992 sid_to_string(user_sid_string, user_sid),
5993 sid_to_string(domain_sid_string, domain_sid)));
5994 data_blob_free(&munged_dial_blob);
5995 return NT_STATUS_UNSUCCESSFUL;
5998 group_sid = pdb_get_group_sid(pw);
6000 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6001 fstring group_sid_string;
6002 fstring domain_sid_string;
6003 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6004 "which conflicts with the domain sid %s. Failing operation.\n",
6006 sid_to_string(group_sid_string, group_sid),
6007 sid_to_string(domain_sid_string, domain_sid)));
6008 data_blob_free(&munged_dial_blob);
6009 return NT_STATUS_UNSUCCESSFUL;
6012 usr->user_rid = user_rid;
6013 usr->group_rid = group_rid;
6014 usr->acb_info = pdb_get_acct_ctrl(pw);
6017 Look at a user on a real NT4 PDC with usrmgr, press
6018 'ok'. Then you will see that fields_present is set to
6019 0x08f827fa. Look at the user immediately after that again,
6020 and you will see that 0x00fffff is returned. This solves
6021 the problem that you get access denied after having looked
6025 usr->fields_present = pdb_build_fields_present(pw);
6027 usr->logon_divs = pdb_get_logon_divs(pw);
6028 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6029 usr->bad_password_count = pdb_get_bad_password_count(pw);
6030 usr->logon_count = pdb_get_logon_count(pw);
6032 if (pdb_get_pass_must_change_time(pw) == 0) {
6033 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6035 usr->passmustchange=0;
6038 ZERO_STRUCT(usr->padding1);
6039 ZERO_STRUCT(usr->padding2);
6041 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6042 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6044 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6045 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6047 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6048 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6050 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6051 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6053 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6054 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6056 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6057 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6059 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6060 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6062 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6063 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6065 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6066 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6068 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6069 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6070 data_blob_free(&munged_dial_blob);
6072 if (pdb_get_hours(pw)) {
6073 usr->logon_hrs.max_len = 1260;
6074 usr->logon_hrs.offset = 0;
6075 usr->logon_hrs.len = pdb_get_hours_len(pw);
6076 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6078 usr->logon_hrs.max_len = 1260;
6079 usr->logon_hrs.offset = 0;
6080 usr->logon_hrs.len = 0;
6081 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6084 return NT_STATUS_OK;
6087 /*******************************************************************
6088 reads or writes a structure.
6089 ********************************************************************/
6091 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6092 prs_struct *ps, int depth)
6097 prs_debug(ps, depth, desc, "sam_io_user_info21");
6103 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6105 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6107 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6109 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6111 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6113 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6116 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6118 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6120 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6122 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6124 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6126 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6128 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6130 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6132 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6134 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6137 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6139 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6142 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6144 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6146 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6149 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6151 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6155 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6158 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6160 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6163 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6165 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6167 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6170 /* here begins pointed-to data */
6172 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6174 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6176 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6178 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6180 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6182 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6184 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6186 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6188 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6190 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6193 /* ok, this is only guess-work (as usual) */
6194 if (usr->ptr_logon_hrs) {
6195 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6202 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6204 const char *munged_dial = pdb_get_munged_dial(pw);
6205 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6207 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6208 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6209 data_blob_free(&blob);
6212 /*******************************************************************
6213 reads or writes a structure.
6214 ********************************************************************/
6216 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6217 prs_struct *ps, int depth)
6222 prs_debug(ps, depth, desc, "sam_io_user_info20");
6228 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6231 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6237 /*******************************************************************
6238 inits a SAM_USERINFO_CTR structure.
6239 ********************************************************************/
6241 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6242 uint16 switch_value,
6243 SAM_USER_INFO_21 * usr)
6245 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6247 ctr->switch_value = switch_value;
6248 ctr->info.id = NULL;
6250 switch (switch_value) {
6252 ctr->info.id10 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_10);
6253 if (ctr->info.id10 == NULL)
6254 return NT_STATUS_NO_MEMORY;
6256 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6259 /* whoops - got this wrong. i think. or don't understand what's happening. */
6263 info = (void *)&id11;
6265 expire.low = 0xffffffff;
6266 expire.high = 0x7fffffff;
6268 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_11);
6269 init_sam_user_info11(ctr->info.id11, &expire,
6270 "BROOKFIELDS$", /* name */
6271 0x03ef, /* user rid */
6272 0x201, /* group rid */
6273 0x0080); /* acb info */
6279 ctr->info.id12 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_12);
6280 if (ctr->info.id12 == NULL)
6281 return NT_STATUS_NO_MEMORY;
6283 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6287 SAM_USER_INFO_21 *cusr;
6288 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6289 ctr->info.id21 = cusr;
6290 if (ctr->info.id21 == NULL)
6291 return NT_STATUS_NO_MEMORY;
6292 memcpy(cusr, usr, sizeof(*usr));
6293 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6294 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6298 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6299 return NT_STATUS_INVALID_INFO_CLASS;
6302 return NT_STATUS_OK;
6305 /*******************************************************************
6306 inits a SAM_USERINFO_CTR structure.
6307 ********************************************************************/
6309 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6310 uint16 switch_value, void *info)
6312 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6314 ctr->switch_value = switch_value;
6315 ctr->info.id = info;
6317 switch (switch_value) {
6319 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6320 dump_data(100, (char *)sess_key->data, sess_key->length);
6321 dump_data(100, (char *)ctr->info.id24->pass, 516);
6324 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6325 dump_data(100, (char *)sess_key->data, sess_key->length);
6326 dump_data(100, (char *)ctr->info.id23->pass, 516);
6331 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6335 /*******************************************************************
6336 reads or writes a structure.
6337 ********************************************************************/
6339 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6340 prs_struct *ps, int depth)
6343 SAM_USERINFO_CTR *ctr;
6345 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6348 if (UNMARSHALLING(ps)) {
6349 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6357 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6359 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6366 switch (ctr->switch_value) {
6368 if (UNMARSHALLING(ps))
6369 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6370 if (ctr->info.id7 == NULL) {
6371 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6374 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6377 if (UNMARSHALLING(ps))
6378 ctr->info.id10 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_10,1);
6379 if (ctr->info.id10 == NULL) {
6380 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6383 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6386 if (UNMARSHALLING(ps))
6387 ctr->info.id11 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_11,1);
6389 if (ctr->info.id11 == NULL) {
6390 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6393 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6396 if (UNMARSHALLING(ps))
6397 ctr->info.id12 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_12,1);
6399 if (ctr->info.id12 == NULL) {
6400 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6403 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6406 if (UNMARSHALLING(ps))
6407 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6409 if (ctr->info.id20 == NULL) {
6410 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6413 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6416 if (UNMARSHALLING(ps))
6417 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6419 if (ctr->info.id21 == NULL) {
6420 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6423 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6426 if (UNMARSHALLING(ps))
6427 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6429 if (ctr->info.id23 == NULL) {
6430 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6433 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6436 if (UNMARSHALLING(ps))
6437 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6439 if (ctr->info.id24 == NULL) {
6440 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6443 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6446 if (UNMARSHALLING(ps))
6447 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6449 if (ctr->info.id25 == NULL) {
6450 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6453 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6456 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6464 /*******************************************************************
6465 inits a SAMR_R_QUERY_USERINFO structure.
6466 ********************************************************************/
6468 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6469 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6471 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6476 if (NT_STATUS_IS_OK(status)) {
6481 r_u->status = status; /* return status */
6484 /*******************************************************************
6485 reads or writes a structure.
6486 ********************************************************************/
6488 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6489 prs_struct *ps, int depth)
6494 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6500 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6503 if (r_u->ptr != 0) {
6504 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6510 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6516 /*******************************************************************
6517 inits a SAMR_Q_SET_USERINFO structure.
6518 ********************************************************************/
6520 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6521 POLICY_HND *hnd, DATA_BLOB *sess_key,
6522 uint16 switch_value, void *info)
6524 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6527 q_u->switch_value = switch_value;
6528 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6531 /*******************************************************************
6532 reads or writes a structure.
6533 ********************************************************************/
6535 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6536 prs_struct *ps, int depth)
6541 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6547 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6549 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6551 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6557 /*******************************************************************
6558 inits a SAMR_R_SET_USERINFO structure.
6559 ********************************************************************/
6561 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6563 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6565 r_u->status = status; /* return status */
6568 /*******************************************************************
6569 reads or writes a structure.
6570 ********************************************************************/
6572 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6573 prs_struct *ps, int depth)
6578 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6584 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6590 /*******************************************************************
6591 inits a SAMR_Q_SET_USERINFO2 structure.
6592 ********************************************************************/
6594 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6595 POLICY_HND *hnd, DATA_BLOB *sess_key,
6596 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6598 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6601 q_u->switch_value = switch_value;
6604 if (q_u->ctr != NULL)
6605 q_u->ctr->switch_value = switch_value;
6607 switch (switch_value) {
6609 SamOEMhashBlob(ctr->info.id12->lm_pwd, 16, sess_key);
6610 SamOEMhashBlob(ctr->info.id12->nt_pwd, 16, sess_key);
6611 dump_data(100, (char *)sess_key->data, sess_key->length);
6612 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6613 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6618 /*******************************************************************
6619 reads or writes a structure.
6620 ********************************************************************/
6622 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6623 prs_struct *ps, int depth)
6628 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6634 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6637 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6639 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6645 /*******************************************************************
6646 inits a SAMR_R_SET_USERINFO2 structure.
6647 ********************************************************************/
6649 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6651 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6653 r_u->status = status; /* return status */
6656 /*******************************************************************
6657 reads or writes a structure.
6658 ********************************************************************/
6660 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6661 prs_struct *ps, int depth)
6666 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6672 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6678 /*******************************************************************
6679 inits a SAMR_Q_CONNECT structure.
6680 ********************************************************************/
6682 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6683 char *srv_name, uint32 access_mask)
6685 DEBUG(5, ("init_samr_q_connect\n"));
6687 /* make PDC server name \\server */
6688 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6689 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6691 /* example values: 0x0000 0002 */
6692 q_u->access_mask = access_mask;
6695 /*******************************************************************
6696 reads or writes a structure.
6697 ********************************************************************/
6699 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6700 prs_struct *ps, int depth)
6705 prs_debug(ps, depth, desc, "samr_io_q_connect");
6711 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6713 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6718 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6724 /*******************************************************************
6725 reads or writes a structure.
6726 ********************************************************************/
6728 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6729 prs_struct *ps, int depth)
6734 prs_debug(ps, depth, desc, "samr_io_r_connect");
6740 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6743 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6749 /*******************************************************************
6750 inits a SAMR_Q_CONNECT4 structure.
6751 ********************************************************************/
6753 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6754 char *srv_name, uint32 access_mask)
6756 DEBUG(5, ("init_samr_q_connect\n"));
6758 /* make PDC server name \\server */
6759 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6760 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6762 /* Only value we've seen, possibly an address type ? */
6765 /* example values: 0x0000 0002 */
6766 q_u->access_mask = access_mask;
6769 /*******************************************************************
6770 reads or writes a structure.
6771 ********************************************************************/
6773 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6774 prs_struct *ps, int depth)
6779 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6785 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6787 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6792 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6794 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6800 /*******************************************************************
6801 reads or writes a structure.
6802 ********************************************************************/
6804 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6805 prs_struct *ps, int depth)
6810 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6816 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6819 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6825 /*******************************************************************
6826 inits a SAMR_Q_CONNECT_ANON structure.
6827 ********************************************************************/
6829 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6831 DEBUG(5, ("init_samr_q_connect_anon\n"));
6834 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6835 q_u->unknown_1 = 0x01;
6836 q_u->access_mask = 0x20;
6839 /*******************************************************************
6840 reads or writes a structure.
6841 ********************************************************************/
6843 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6844 prs_struct *ps, int depth)
6849 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6855 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6857 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6859 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6861 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6867 /*******************************************************************
6868 reads or writes a structure.
6869 ********************************************************************/
6871 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6872 prs_struct *ps, int depth)
6877 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6883 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6886 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6892 /*******************************************************************
6893 inits a SAMR_Q_GET_DOM_PWINFO structure.
6894 ********************************************************************/
6896 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6899 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6902 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
6903 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
6906 /*******************************************************************
6907 reads or writes a structure.
6908 ********************************************************************/
6910 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6911 prs_struct *ps, int depth)
6916 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6922 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6924 if (q_u->ptr != 0) {
6925 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6927 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6934 /*******************************************************************
6935 reads or writes a structure.
6936 ********************************************************************/
6938 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6939 prs_struct *ps, int depth)
6944 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6951 * see the Samba4 IDL for what these actually are.
6954 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
6958 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
6961 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6967 /*******************************************************************
6968 make a SAMR_ENC_PASSWD structure.
6969 ********************************************************************/
6971 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
6979 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6983 /*******************************************************************
6984 reads or writes a SAMR_ENC_PASSWD structure.
6985 ********************************************************************/
6987 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
6988 prs_struct *ps, int depth)
6993 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6999 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7002 if (pwd->ptr != 0) {
7003 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7010 /*******************************************************************
7011 inits a SAMR_ENC_HASH structure.
7012 ********************************************************************/
7014 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7022 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7026 /*******************************************************************
7027 reads or writes a SAMR_ENC_HASH structure.
7028 ********************************************************************/
7030 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7031 prs_struct *ps, int depth)
7036 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7042 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7044 if (hsh->ptr != 0) {
7045 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7052 /*******************************************************************
7053 inits a SAMR_R_GET_DOM_PWINFO structure.
7054 ********************************************************************/
7056 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7057 const char *dest_host, const char *user_name,
7058 const char nt_newpass[516],
7059 const uchar nt_oldhash[16],
7060 const char lm_newpass[516],
7061 const uchar lm_oldhash[16])
7063 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7066 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7067 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7069 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7070 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7072 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7073 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7075 q_u->unknown = 0x01;
7077 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7078 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7081 /*******************************************************************
7082 reads or writes a structure.
7083 ********************************************************************/
7085 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7086 prs_struct *ps, int depth)
7091 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7097 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7100 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7102 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7107 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7109 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7112 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7114 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7117 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7120 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7122 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7128 /*******************************************************************
7129 inits a SAMR_R_CHGPASSWD_USER structure.
7130 ********************************************************************/
7132 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7134 DEBUG(5, ("init_r_chgpasswd_user\n"));
7136 r_u->status = status;
7139 /*******************************************************************
7140 reads or writes a structure.
7141 ********************************************************************/
7143 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7144 prs_struct *ps, int depth)
7149 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7155 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7161 /*******************************************************************
7162 reads or writes a structure.
7163 ********************************************************************/
7165 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7166 POLICY_HND *domain_pol, uint16 switch_value)
7168 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7170 q_u->domain_pol = *domain_pol;
7171 q_u->switch_value = switch_value;
7174 /*******************************************************************
7175 reads or writes a structure.
7176 ********************************************************************/
7178 BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7179 prs_struct *ps, int depth)
7184 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7190 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7193 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7199 /*******************************************************************
7200 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7201 ********************************************************************/
7203 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7204 uint16 switch_value, SAM_UNK_CTR * ctr,
7207 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7210 r_u->switch_value = 0;
7211 r_u->status = status; /* return status */
7213 if (NT_STATUS_IS_OK(status)) {
7214 r_u->switch_value = switch_value;
7220 /*******************************************************************
7221 reads or writes a structure.
7222 ********************************************************************/
7224 BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u,
7225 prs_struct *ps, int depth)
7230 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7236 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7239 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7240 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7245 switch (r_u->switch_value) {
7247 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7251 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7255 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7259 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7263 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7267 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7271 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7275 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7276 r_u->switch_value));
7277 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7285 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7292 /*******************************************************************
7293 reads or writes a structure.
7294 ********************************************************************/
7296 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7297 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7299 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7301 q_u->domain_pol = *domain_pol;
7302 q_u->switch_value0 = switch_value;
7304 q_u->switch_value = switch_value;
7309 /*******************************************************************
7310 reads or writes a structure.
7311 ********************************************************************/
7313 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7314 prs_struct *ps, int depth)
7319 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7325 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7328 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7331 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7337 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7340 switch (q_u->switch_value) {
7343 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7347 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7351 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7355 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7359 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7363 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7367 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7371 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7372 q_u->switch_value));
7379 /*******************************************************************
7380 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7381 ********************************************************************/
7383 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7385 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7387 r_u->status = status; /* return status */
7390 /*******************************************************************
7391 reads or writes a structure.
7392 ********************************************************************/
7394 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7395 prs_struct *ps, int depth)
7400 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7406 if(!prs_ntstatus("status", ps, depth, &r_u->status))