2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Paul Ashton 1997-2000,
7 * Copyright (C) Elrond 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Jean François Micouleau 1998-2001,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include "rpc_parse.h"
32 #define DBGC_CLASS DBGC_RPC_PARSE
34 /*******************************************************************
35 inits a SAMR_Q_CLOSE_HND structure.
36 ********************************************************************/
38 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
40 DEBUG(5, ("init_samr_q_close_hnd\n"));
45 /*******************************************************************
46 reads or writes a structure.
47 ********************************************************************/
49 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
50 prs_struct *ps, int depth)
55 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
61 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
64 /*******************************************************************
65 reads or writes a structure.
66 ********************************************************************/
68 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
69 prs_struct *ps, int depth)
74 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
80 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
83 if(!prs_ntstatus("status", ps, depth, &r_u->status))
89 /*******************************************************************
90 inits a SAMR_Q_LOOKUP_DOMAIN structure.
91 ********************************************************************/
93 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
94 POLICY_HND *pol, char *dom_name)
96 DEBUG(5, ("init_samr_q_lookup_domain\n"));
98 q_u->connect_pol = *pol;
100 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
101 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
104 /*******************************************************************
105 reads or writes a structure.
106 ********************************************************************/
107 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
108 prs_struct *ps, int depth)
113 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
119 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
122 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
125 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
131 /*******************************************************************
132 inits a SAMR_R_LOOKUP_DOMAIN structure.
133 ********************************************************************/
135 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
136 DOM_SID *dom_sid, NTSTATUS status)
138 DEBUG(5, ("init_samr_r_lookup_domain\n"));
140 r_u->status = status;
142 if (NT_STATUS_IS_OK(status)) {
144 init_dom_sid2(&r_u->dom_sid, dom_sid);
148 /*******************************************************************
149 reads or writes a structure.
150 ********************************************************************/
152 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
153 prs_struct *ps, int depth)
158 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
164 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
167 if (r_u->ptr_sid != 0) {
168 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
174 if(!prs_ntstatus("status", ps, depth, &r_u->status))
180 /*******************************************************************
181 reads or writes a structure.
182 ********************************************************************/
184 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
186 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
188 q_u->dom_pol = *dom_pol;
189 init_dom_sid2(&q_u->sid, sid);
192 /*******************************************************************
193 reads or writes a structure.
194 ********************************************************************/
196 BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
197 prs_struct *ps, int depth)
202 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
208 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
211 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
220 /*******************************************************************
221 reads or writes a structure.
222 ********************************************************************/
224 BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
225 prs_struct *ps, int depth)
230 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
236 if(!prs_ntstatus("status", ps, depth, &r_u->status))
242 /*******************************************************************
243 reads or writes a structure.
244 ********************************************************************/
246 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
247 POLICY_HND *pol, uint32 flags,
250 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
254 init_dom_sid2(&q_u->dom_sid, sid);
257 /*******************************************************************
258 reads or writes a structure.
259 ********************************************************************/
261 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
262 prs_struct *ps, int depth)
267 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
273 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
276 if(!prs_uint32("flags", ps, depth, &q_u->flags))
279 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
285 /*******************************************************************
286 reads or writes a structure.
287 ********************************************************************/
289 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
290 prs_struct *ps, int depth)
295 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
301 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
304 if(!prs_ntstatus("status", ps, depth, &r_u->status))
310 /*******************************************************************
311 reads or writes a structure.
312 ********************************************************************/
314 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
315 POLICY_HND *user_pol)
317 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
319 q_u->user_pol = *user_pol;
322 /*******************************************************************
323 reads or writes a structure.
324 ********************************************************************/
326 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
327 prs_struct *ps, int depth)
332 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
338 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
341 /*******************************************************************
343 ********************************************************************/
345 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
347 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
349 r_u->unknown_0 = 0x0000;
353 * r_u->unknown_1 = 0x0015;
356 r_u->unknown_1 = 0x01D1;
357 r_u->unknown_1 = 0x0015;
359 r_u->unknown_2 = 0x00000000;
361 r_u->status = status;
364 /*******************************************************************
365 reads or writes a structure.
366 ********************************************************************/
368 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
369 prs_struct *ps, int depth)
374 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
380 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
382 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
384 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
386 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
393 /*******************************************************************
394 reads or writes a structure.
395 ********************************************************************/
397 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
398 prs_struct *ps, int depth)
403 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
409 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
412 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
415 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
422 /*******************************************************************
423 reads or writes a structure.
424 ********************************************************************/
426 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
427 POLICY_HND *user_pol, uint32 sec_info)
429 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
431 q_u->user_pol = *user_pol;
432 q_u->sec_info = sec_info;
436 /*******************************************************************
437 reads or writes a structure.
438 ********************************************************************/
440 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
441 prs_struct *ps, int depth)
446 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
452 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
455 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
461 /*******************************************************************
462 reads or writes a structure.
463 ********************************************************************/
465 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
466 POLICY_HND *domain_pol, uint16 switch_value)
468 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
470 q_u->domain_pol = *domain_pol;
471 q_u->switch_value = switch_value;
474 /*******************************************************************
475 reads or writes a structure.
476 ********************************************************************/
478 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
479 prs_struct *ps, int depth)
484 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
490 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
493 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
500 /*******************************************************************
502 ********************************************************************/
504 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
506 u_3->logout.low = nt_logout.low;
507 u_3->logout.high = nt_logout.high;
510 /*******************************************************************
511 reads or writes a structure.
512 ********************************************************************/
514 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
515 prs_struct *ps, int depth)
520 prs_debug(ps, depth, desc, "sam_io_unk_info3");
523 if(!smb_io_time("logout", &u_3->logout, ps, depth))
529 /*******************************************************************
531 ********************************************************************/
533 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
535 u_6->unknown_0 = 0x00000000;
537 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
540 /*******************************************************************
541 reads or writes a structure.
542 ********************************************************************/
544 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
545 prs_struct *ps, int depth)
550 prs_debug(ps, depth, desc, "sam_io_unk_info6");
553 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
555 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
557 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
563 /*******************************************************************
565 ********************************************************************/
567 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
569 u_7->server_role = server_role;
572 /*******************************************************************
573 reads or writes a structure.
574 ********************************************************************/
576 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
577 prs_struct *ps, int depth)
582 prs_debug(ps, depth, desc, "sam_io_unk_info7");
585 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
591 /*******************************************************************
593 ********************************************************************/
595 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
597 unix_to_nt_time(&u_8->domain_create_time, 0);
598 u_8->seq_num.low = seq_num;
599 u_8->seq_num.high = 0x0000;
602 /*******************************************************************
603 reads or writes a structure.
604 ********************************************************************/
606 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
607 prs_struct *ps, int depth)
612 prs_debug(ps, depth, desc, "sam_io_unk_info8");
615 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
618 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
625 /*******************************************************************
627 ********************************************************************/
629 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
631 u_12->duration.low = nt_lock_duration.low;
632 u_12->duration.high = nt_lock_duration.high;
633 u_12->reset_count.low = nt_reset_time.low;
634 u_12->reset_count.high = nt_reset_time.high;
636 u_12->bad_attempt_lockout = lockout;
639 /*******************************************************************
640 reads or writes a structure.
641 ********************************************************************/
643 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
644 prs_struct *ps, int depth)
649 prs_debug(ps, depth, desc, "sam_io_unk_info12");
652 if(!smb_io_time("duration", &u_12->duration, ps, depth))
654 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
656 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
662 /*******************************************************************
664 ********************************************************************/
666 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
668 init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE);
669 init_uni_hdr(&u_5->hdr_server, &u_5->uni_server);
672 /*******************************************************************
673 reads or writes a structure.
674 ********************************************************************/
676 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
677 prs_struct *ps, int depth)
682 prs_debug(ps, depth, desc, "sam_io_unk_info5");
685 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
688 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
694 /*******************************************************************
696 ********************************************************************/
698 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
699 const char *comment, const char *domain, const char *server,
700 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
702 u_2->logout.low = nt_logout.low;
703 u_2->logout.high = nt_logout.high;
705 u_2->seq_num.low = seq_num;
706 u_2->seq_num.high = 0x00000000;
709 u_2->unknown_4 = 0x00000001;
710 u_2->server_role = server_role;
711 u_2->unknown_6 = 0x00000001;
712 u_2->num_domain_usrs = num_users;
713 u_2->num_domain_grps = num_groups;
714 u_2->num_local_grps = num_alias;
716 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
718 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
719 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
720 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
721 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
722 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
723 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
726 /*******************************************************************
727 reads or writes a structure.
728 ********************************************************************/
730 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
731 prs_struct *ps, int depth)
736 prs_debug(ps, depth, desc, "sam_io_unk_info2");
739 if(!smb_io_time("logout", &u_2->logout, ps, depth))
741 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
743 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
745 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
748 /* put all the data in here, at the moment, including what the above
749 pointer is referring to
752 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
755 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
757 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
759 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
761 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
763 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
765 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
768 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
770 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
772 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
778 /*******************************************************************
780 ********************************************************************/
782 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
783 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
785 u_1->min_length_password = min_pass_len;
786 u_1->password_history = pass_hist;
789 /* password never expire */
790 u_1->expire.high = nt_expire.high;
791 u_1->expire.low = nt_expire.low;
793 /* can change the password now */
794 u_1->min_passwordage.high = nt_min_age.high;
795 u_1->min_passwordage.low = nt_min_age.low;
799 /*******************************************************************
800 reads or writes a structure.
801 ********************************************************************/
803 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
804 prs_struct *ps, int depth)
809 prs_debug(ps, depth, desc, "sam_io_unk_info1");
812 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
814 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
816 if(!prs_uint32("flag", ps, depth, &u_1->flag))
818 if(!smb_io_time("expire", &u_1->expire, ps, depth))
820 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
826 /*******************************************************************
827 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
828 ********************************************************************/
830 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
831 uint16 switch_value, SAM_UNK_CTR * ctr,
834 DEBUG(5, ("init_samr_r_query_dom_info\n"));
837 r_u->switch_value = 0;
838 r_u->status = status; /* return status */
840 if (NT_STATUS_IS_OK(status)) {
841 r_u->switch_value = switch_value;
847 /*******************************************************************
848 reads or writes a structure.
849 ********************************************************************/
851 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
852 prs_struct *ps, int depth)
857 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
863 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
866 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
867 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
872 switch (r_u->switch_value) {
874 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
878 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
882 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
886 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
890 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
894 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
898 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
902 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
906 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
908 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
916 if(!prs_ntstatus("status", ps, depth, &r_u->status))
922 /*******************************************************************
923 reads or writes a SAMR_R_SET_SEC_OBJ structure.
924 ********************************************************************/
926 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
927 prs_struct *ps, int depth)
932 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
938 if(!prs_ntstatus("status", ps, depth, &r_u->status))
944 /*******************************************************************
945 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
946 ********************************************************************/
948 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
949 prs_struct *ps, int depth)
954 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
960 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
963 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
967 if(!prs_ntstatus("status", ps, depth, &r_u->status))
973 /*******************************************************************
974 reads or writes a SAM_STR1 structure.
975 ********************************************************************/
977 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
978 uint32 name_buf, uint32 desc_buf,
979 prs_struct *ps, int depth)
984 prs_debug(ps, depth, desc, "sam_io_sam_str1");
989 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
992 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
995 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1001 /*******************************************************************
1002 inits a SAM_ENTRY1 structure.
1003 ********************************************************************/
1005 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1006 UNISTR2 *sam_name, UNISTR2 *sam_full,
1007 UNISTR2 *sam_desc, uint32 rid_user,
1010 DEBUG(5, ("init_sam_entry1\n"));
1014 sam->user_idx = user_idx;
1015 sam->rid_user = rid_user;
1016 sam->acb_info = acb_info;
1018 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1019 init_uni_hdr(&sam->hdr_user_name, sam_full);
1020 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1023 /*******************************************************************
1024 reads or writes a SAM_ENTRY1 structure.
1025 ********************************************************************/
1027 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1028 prs_struct *ps, int depth)
1033 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1039 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1042 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1044 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1050 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1052 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1054 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1060 /*******************************************************************
1061 reads or writes a SAM_STR2 structure.
1062 ********************************************************************/
1064 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1065 uint32 desc_buf, prs_struct *ps, int depth)
1070 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1076 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1078 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1084 /*******************************************************************
1085 inits a SAM_ENTRY2 structure.
1086 ********************************************************************/
1087 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1088 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1089 uint32 rid_user, uint16 acb_info)
1091 DEBUG(5, ("init_sam_entry2\n"));
1093 sam->user_idx = user_idx;
1094 sam->rid_user = rid_user;
1095 sam->acb_info = acb_info;
1097 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1098 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1101 /*******************************************************************
1102 reads or writes a SAM_ENTRY2 structure.
1103 ********************************************************************/
1105 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1106 prs_struct *ps, int depth)
1111 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1117 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1120 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1122 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1128 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1130 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1136 /*******************************************************************
1137 reads or writes a SAM_STR3 structure.
1138 ********************************************************************/
1140 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1141 uint32 desc_buf, prs_struct *ps, int depth)
1146 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1152 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1154 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1160 /*******************************************************************
1161 inits a SAM_ENTRY3 structure.
1162 ********************************************************************/
1164 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1165 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1168 DEBUG(5, ("init_sam_entry3\n"));
1170 sam->grp_idx = grp_idx;
1171 sam->rid_grp = rid_grp;
1172 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1174 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1175 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1178 /*******************************************************************
1179 reads or writes a SAM_ENTRY3 structure.
1180 ********************************************************************/
1182 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1183 prs_struct *ps, int depth)
1188 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1194 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1197 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1199 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1202 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1204 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1210 /*******************************************************************
1211 inits a SAM_ENTRY4 structure.
1212 ********************************************************************/
1214 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1215 uint32 len_acct_name)
1217 DEBUG(5, ("init_sam_entry4\n"));
1219 sam->user_idx = user_idx;
1220 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1223 /*******************************************************************
1224 reads or writes a SAM_ENTRY4 structure.
1225 ********************************************************************/
1227 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1228 prs_struct *ps, int depth)
1233 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1239 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1241 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1247 /*******************************************************************
1248 inits a SAM_ENTRY5 structure.
1249 ********************************************************************/
1251 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1252 uint32 len_grp_name)
1254 DEBUG(5, ("init_sam_entry5\n"));
1256 sam->grp_idx = grp_idx;
1257 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1261 /*******************************************************************
1262 reads or writes a SAM_ENTRY5 structure.
1263 ********************************************************************/
1265 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1266 prs_struct *ps, int depth)
1271 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1277 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1279 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1285 /*******************************************************************
1286 inits a SAM_ENTRY structure.
1287 ********************************************************************/
1289 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1291 DEBUG(10, ("init_sam_entry: %d\n", rid));
1294 init_uni_hdr(&sam->hdr_name, uni2);
1297 /*******************************************************************
1298 reads or writes a SAM_ENTRY structure.
1299 ********************************************************************/
1301 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1302 prs_struct *ps, int depth)
1307 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1312 if(!prs_uint32("rid", ps, depth, &sam->rid))
1314 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1320 /*******************************************************************
1321 inits a SAMR_Q_ENUM_DOM_USERS structure.
1322 ********************************************************************/
1324 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1326 uint16 acb_mask, uint16 unk_1, uint32 size)
1328 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1332 q_e->start_idx = start_idx; /* zero indicates lots */
1333 q_e->acb_mask = acb_mask;
1334 q_e->unknown_1 = unk_1;
1335 q_e->max_size = size;
1338 /*******************************************************************
1339 reads or writes a structure.
1340 ********************************************************************/
1342 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1343 prs_struct *ps, int depth)
1348 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1354 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1357 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1359 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1361 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1364 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1371 /*******************************************************************
1372 inits a SAMR_R_ENUM_DOM_USERS structure.
1373 ********************************************************************/
1375 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1376 uint32 next_idx, uint32 num_sam_entries)
1378 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1380 r_u->next_idx = next_idx;
1382 if (num_sam_entries != 0) {
1383 r_u->ptr_entries1 = 1;
1384 r_u->ptr_entries2 = 1;
1385 r_u->num_entries2 = num_sam_entries;
1386 r_u->num_entries3 = num_sam_entries;
1388 r_u->num_entries4 = num_sam_entries;
1390 r_u->ptr_entries1 = 0;
1391 r_u->num_entries2 = num_sam_entries;
1392 r_u->ptr_entries2 = 1;
1396 /*******************************************************************
1397 reads or writes a structure.
1398 ********************************************************************/
1400 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1401 prs_struct *ps, int depth)
1408 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1414 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1416 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1419 if (r_u->ptr_entries1 != 0) {
1420 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1422 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1424 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1427 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1428 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1429 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1432 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1433 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1434 r_u->num_entries4 = 0;
1435 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1439 for (i = 0; i < r_u->num_entries2; i++) {
1440 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1444 for (i = 0; i < r_u->num_entries2; i++) {
1445 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1454 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1456 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1462 /*******************************************************************
1463 inits a SAMR_Q_QUERY_DISPINFO structure.
1464 ********************************************************************/
1466 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1467 uint16 switch_level, uint32 start_idx,
1468 uint32 max_entries, uint32 max_size)
1470 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1472 q_e->domain_pol = *pol;
1474 q_e->switch_level = switch_level;
1476 q_e->start_idx = start_idx;
1477 q_e->max_entries = max_entries;
1478 q_e->max_size = max_size;
1481 /*******************************************************************
1482 reads or writes a structure.
1483 ********************************************************************/
1485 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1486 prs_struct *ps, int depth)
1491 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1497 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1500 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1505 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1507 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1509 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1515 /*******************************************************************
1516 inits a SAM_DISPINFO_1 structure.
1517 ********************************************************************/
1519 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1520 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1521 DOM_SID *domain_sid)
1525 SAM_ACCOUNT *pwd = NULL;
1528 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1531 return NT_STATUS_OK;
1533 sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1535 return NT_STATUS_NO_MEMORY;
1537 sam->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1539 return NT_STATUS_NO_MEMORY;
1541 ZERO_STRUCTP(sam->sam);
1542 ZERO_STRUCTP(sam->str);
1544 for (i = 0; i < num_entries ; i++) {
1545 const char *username;
1546 const char *fullname;
1547 const char *acct_desc;
1549 const DOM_SID *user_sid;
1550 fstring user_sid_string, domain_sid_string;
1552 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1554 pwd=&disp_user_info[i+start_idx];
1556 username = pdb_get_username(pwd);
1557 fullname = pdb_get_fullname(pwd);
1558 acct_desc = pdb_get_acct_desc(pwd);
1569 user_sid = pdb_get_user_sid(pwd);
1571 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1572 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1573 "the domain sid %s. Failing operation.\n",
1575 sid_to_string(user_sid_string, user_sid),
1576 sid_to_string(domain_sid_string, domain_sid)));
1577 return NT_STATUS_UNSUCCESSFUL;
1580 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), UNI_FLAGS_NONE);
1581 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), UNI_FLAGS_NONE);
1582 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), UNI_FLAGS_NONE);
1584 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1585 &sam->str[i].uni_acct_name, &sam->str[i].uni_full_name, &sam->str[i].uni_acct_desc,
1586 user_rid, pdb_get_acct_ctrl(pwd));
1590 return NT_STATUS_OK;
1593 /*******************************************************************
1594 reads or writes a structure.
1595 ********************************************************************/
1597 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1599 prs_struct *ps, int depth)
1603 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1609 if (UNMARSHALLING(ps) && num_entries > 0) {
1611 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1612 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1616 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1617 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1622 for (i = 0; i < num_entries; i++) {
1623 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1627 for (i = 0; i < num_entries; i++) {
1628 if(!sam_io_sam_str1("", &sam->str[i],
1629 sam->sam[i].hdr_acct_name.buffer,
1630 sam->sam[i].hdr_user_name.buffer,
1631 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1638 /*******************************************************************
1639 inits a SAM_DISPINFO_2 structure.
1640 ********************************************************************/
1642 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1643 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1644 DOM_SID *domain_sid )
1648 SAM_ACCOUNT *pwd = NULL;
1651 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1654 return NT_STATUS_OK;
1656 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries)))
1657 return NT_STATUS_NO_MEMORY;
1659 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries)))
1660 return NT_STATUS_NO_MEMORY;
1662 ZERO_STRUCTP(sam->sam);
1663 ZERO_STRUCTP(sam->str);
1665 for (i = 0; i < num_entries; i++) {
1667 const DOM_SID *user_sid;
1668 const char *username;
1669 const char *acct_desc;
1670 fstring user_sid_string, domain_sid_string;
1672 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1673 pwd=&disp_user_info[i+start_idx];
1675 username = pdb_get_username(pwd);
1676 acct_desc = pdb_get_acct_desc(pwd);
1677 user_sid = pdb_get_user_sid(pwd);
1679 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1680 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1681 "the domain sid %s. Failing operation.\n",
1683 sid_to_string(user_sid_string, user_sid),
1684 sid_to_string(domain_sid_string, domain_sid)));
1685 return NT_STATUS_UNSUCCESSFUL;
1688 init_unistr2(&sam->str[i].uni_srv_name, username, UNI_FLAGS_NONE);
1689 init_unistr2(&sam->str[i].uni_srv_desc, acct_desc, UNI_FLAGS_NONE);
1691 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1692 &sam->str[i].uni_srv_name, &sam->str[i].uni_srv_desc,
1693 user_rid, pdb_get_acct_ctrl(pwd));
1696 return NT_STATUS_OK;
1699 /*******************************************************************
1700 reads or writes a structure.
1701 ********************************************************************/
1703 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1705 prs_struct *ps, int depth)
1712 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1718 if (UNMARSHALLING(ps) && num_entries > 0) {
1720 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1721 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1725 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1726 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1731 for (i = 0; i < num_entries; i++) {
1732 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1736 for (i = 0; i < num_entries; i++) {
1737 if(!sam_io_sam_str2("", &sam->str[i],
1738 sam->sam[i].hdr_srv_name.buffer,
1739 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1746 /*******************************************************************
1747 inits a SAM_DISPINFO_3 structure.
1748 ********************************************************************/
1750 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1751 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1757 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1760 return NT_STATUS_OK;
1762 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1763 return NT_STATUS_NO_MEMORY;
1765 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1766 return NT_STATUS_NO_MEMORY;
1768 ZERO_STRUCTP(sam->sam);
1769 ZERO_STRUCTP(sam->str);
1771 for (i = 0; i < num_entries; i++) {
1772 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1774 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1776 init_unistr2(&sam->str[i].uni_grp_name, grp->name, UNI_FLAGS_NONE);
1777 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, UNI_FLAGS_NONE);
1779 init_sam_entry3(&sam->sam[i], start_idx + i + 1, &sam->str[i].uni_grp_name,
1780 &sam->str[i].uni_grp_desc, grp->rid);
1783 return NT_STATUS_OK;
1786 /*******************************************************************
1787 reads or writes a structure.
1788 ********************************************************************/
1790 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1792 prs_struct *ps, int depth)
1799 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1805 if (UNMARSHALLING(ps) && num_entries > 0) {
1807 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1808 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1812 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1813 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1818 for (i = 0; i < num_entries; i++) {
1819 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1823 for (i = 0; i < num_entries; i++) {
1824 if(!sam_io_sam_str3("", &sam->str[i],
1825 sam->sam[i].hdr_grp_name.buffer,
1826 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1833 /*******************************************************************
1834 inits a SAM_DISPINFO_4 structure.
1835 ********************************************************************/
1837 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1838 uint32 start_idx, SAM_ACCOUNT *disp_user_info)
1840 uint32 len_sam_name;
1843 SAM_ACCOUNT *pwd = NULL;
1846 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1849 return NT_STATUS_OK;
1851 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries)))
1852 return NT_STATUS_NO_MEMORY;
1854 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries)))
1855 return NT_STATUS_NO_MEMORY;
1857 ZERO_STRUCTP(sam->sam);
1858 ZERO_STRUCTP(sam->str);
1860 for (i = 0; i < num_entries; i++) {
1861 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1862 pwd=&disp_user_info[i+start_idx];
1864 len_sam_name = strlen(pdb_get_username(pwd));
1866 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1868 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1871 return NT_STATUS_OK;
1874 /*******************************************************************
1875 reads or writes a structure.
1876 ********************************************************************/
1878 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1880 prs_struct *ps, int depth)
1887 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1893 if (UNMARSHALLING(ps) && num_entries > 0) {
1895 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1896 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1900 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1901 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1906 for (i = 0; i < num_entries; i++) {
1907 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1911 for (i = 0; i < num_entries; i++) {
1912 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1913 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1920 /*******************************************************************
1921 inits a SAM_DISPINFO_5 structure.
1922 ********************************************************************/
1924 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1925 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1927 uint32 len_sam_name;
1932 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1935 return NT_STATUS_OK;
1937 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1938 return NT_STATUS_NO_MEMORY;
1940 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1941 return NT_STATUS_NO_MEMORY;
1943 ZERO_STRUCTP(sam->sam);
1944 ZERO_STRUCTP(sam->str);
1946 for (i = 0; i < num_entries; i++) {
1947 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1949 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1951 len_sam_name = strlen(grp->name);
1953 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1954 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1957 return NT_STATUS_OK;
1960 /*******************************************************************
1961 reads or writes a structure.
1962 ********************************************************************/
1964 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1966 prs_struct *ps, int depth)
1973 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1979 if (UNMARSHALLING(ps) && num_entries > 0) {
1981 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1982 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1986 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1987 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1992 for (i = 0; i < num_entries; i++) {
1993 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1997 for (i = 0; i < num_entries; i++) {
1998 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1999 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2006 /*******************************************************************
2007 inits a SAMR_R_QUERY_DISPINFO structure.
2008 ********************************************************************/
2010 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2011 uint32 num_entries, uint32 total_size, uint32 data_size,
2012 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2015 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2017 r_u->total_size = total_size;
2019 r_u->data_size = data_size;
2021 r_u->switch_level = switch_level;
2022 r_u->num_entries = num_entries;
2025 r_u->ptr_entries = 0;
2027 r_u->ptr_entries = 1;
2029 r_u->num_entries2 = num_entries;
2032 r_u->status = status;
2035 /*******************************************************************
2036 reads or writes a structure.
2037 ********************************************************************/
2039 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2040 prs_struct *ps, int depth)
2045 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2051 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2053 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2055 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2060 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2062 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2065 if (r_u->ptr_entries==0) {
2068 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2074 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2077 switch (r_u->switch_level) {
2079 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2080 r_u->num_entries, ps, depth))
2084 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2085 r_u->num_entries, ps, depth))
2089 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2090 r_u->num_entries, ps, depth))
2094 if(!sam_io_sam_dispinfo_4("user list",
2095 r_u->ctr->sam.info4,
2096 r_u->num_entries, ps, depth))
2100 if(!sam_io_sam_dispinfo_5("group list",
2101 r_u->ctr->sam.info5,
2102 r_u->num_entries, ps, depth))
2106 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2112 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2118 /*******************************************************************
2119 inits a SAMR_Q_OPEN_GROUP structure.
2120 ********************************************************************/
2122 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2124 uint32 access_mask, uint32 rid)
2126 DEBUG(5, ("init_samr_q_open_group\n"));
2128 q_c->domain_pol = *hnd;
2129 q_c->access_mask = access_mask;
2130 q_c->rid_group = rid;
2133 /*******************************************************************
2134 reads or writes a structure.
2135 ********************************************************************/
2137 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2138 prs_struct *ps, int depth)
2143 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2149 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2152 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2154 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2160 /*******************************************************************
2161 reads or writes a structure.
2162 ********************************************************************/
2164 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2165 prs_struct *ps, int depth)
2170 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2176 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2179 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2185 /*******************************************************************
2186 inits a GROUP_INFO1 structure.
2187 ********************************************************************/
2189 void init_samr_group_info1(GROUP_INFO1 * gr1,
2190 char *acct_name, char *acct_desc,
2193 DEBUG(5, ("init_samr_group_info1\n"));
2195 gr1->unknown_1 = 0x3;
2196 gr1->num_members = num_members;
2198 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2199 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2200 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2201 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2204 /*******************************************************************
2205 reads or writes a structure.
2206 ********************************************************************/
2208 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2209 prs_struct *ps, int depth)
2216 prs_debug(ps, depth, desc, "samr_io_group_info1");
2219 if(!prs_uint16("level", ps, depth, &dummy))
2225 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2228 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2230 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2233 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2236 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2237 gr1->hdr_acct_name.buffer, ps, depth))
2240 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2241 gr1->hdr_acct_desc.buffer, ps, depth))
2247 /*******************************************************************
2248 inits a GROUP_INFO2 structure.
2249 ********************************************************************/
2251 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2253 DEBUG(5, ("init_samr_group_info2\n"));
2256 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2257 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2260 /*******************************************************************
2261 reads or writes a structure.
2262 ********************************************************************/
2264 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2269 prs_debug(ps, depth, desc, "samr_io_group_info2");
2272 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2275 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2277 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2278 gr2->hdr_acct_name.buffer, ps, depth))
2284 /*******************************************************************
2285 inits a GROUP_INFO3 structure.
2286 ********************************************************************/
2288 void init_samr_group_info3(GROUP_INFO3 *gr3)
2290 DEBUG(5, ("init_samr_group_info3\n"));
2292 gr3->unknown_1 = 0x3;
2295 /*******************************************************************
2296 reads or writes a structure.
2297 ********************************************************************/
2299 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2304 prs_debug(ps, depth, desc, "samr_io_group_info3");
2310 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2316 /*******************************************************************
2317 inits a GROUP_INFO4 structure.
2318 ********************************************************************/
2320 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2322 DEBUG(5, ("init_samr_group_info4\n"));
2325 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2326 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2329 /*******************************************************************
2330 reads or writes a structure.
2331 ********************************************************************/
2333 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2334 prs_struct *ps, int depth)
2339 prs_debug(ps, depth, desc, "samr_io_group_info4");
2342 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2344 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2346 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2347 gr4->hdr_acct_desc.buffer, ps, depth))
2353 /*******************************************************************
2354 reads or writes a structure.
2355 ********************************************************************/
2357 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2358 prs_struct *ps, int depth)
2360 if (UNMARSHALLING(ps))
2361 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2366 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2369 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2372 switch ((*ctr)->switch_value1) {
2374 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2378 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2382 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2386 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2390 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2397 /*******************************************************************
2398 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2399 ********************************************************************/
2401 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2402 POLICY_HND *pol, const char *acct_desc,
2405 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2409 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2410 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2412 q_e->access_mask = access_mask;
2415 /*******************************************************************
2416 reads or writes a structure.
2417 ********************************************************************/
2419 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2420 prs_struct *ps, int depth)
2425 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2431 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2434 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2436 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2437 q_e->hdr_acct_desc.buffer, ps, depth))
2442 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2448 /*******************************************************************
2449 reads or writes a structure.
2450 ********************************************************************/
2452 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2453 prs_struct *ps, int depth)
2458 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2464 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2467 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2469 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2475 /*******************************************************************
2476 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2477 ********************************************************************/
2479 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2482 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2484 q_c->group_pol = *hnd;
2487 /*******************************************************************
2488 reads or writes a structure.
2489 ********************************************************************/
2491 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2492 prs_struct *ps, int depth)
2497 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2503 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2509 /*******************************************************************
2510 reads or writes a structure.
2511 ********************************************************************/
2513 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2514 prs_struct *ps, int depth)
2519 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2525 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2528 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2534 /*******************************************************************
2535 inits a SAMR_Q_DEL_GROUPMEM structure.
2536 ********************************************************************/
2538 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2539 POLICY_HND *pol, uint32 rid)
2541 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2547 /*******************************************************************
2548 reads or writes a structure.
2549 ********************************************************************/
2551 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2552 prs_struct *ps, int depth)
2557 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2563 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2566 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2572 /*******************************************************************
2573 inits a SAMR_R_DEL_GROUPMEM structure.
2574 ********************************************************************/
2576 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2579 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2581 r_u->status = status;
2584 /*******************************************************************
2585 reads or writes a structure.
2586 ********************************************************************/
2588 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2589 prs_struct *ps, int depth)
2594 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2600 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2606 /*******************************************************************
2607 inits a SAMR_Q_ADD_GROUPMEM structure.
2608 ********************************************************************/
2610 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2611 POLICY_HND *pol, uint32 rid)
2613 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2617 q_e->unknown = 0x0005;
2620 /*******************************************************************
2621 reads or writes a structure.
2622 ********************************************************************/
2624 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2625 prs_struct *ps, int depth)
2630 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2636 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2639 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2641 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2647 /*******************************************************************
2648 inits a SAMR_R_ADD_GROUPMEM structure.
2649 ********************************************************************/
2651 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2654 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2656 r_u->status = status;
2659 /*******************************************************************
2660 reads or writes a structure.
2661 ********************************************************************/
2663 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2664 prs_struct *ps, int depth)
2669 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2675 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2681 /*******************************************************************
2682 inits a SAMR_Q_SET_GROUPINFO structure.
2683 ********************************************************************/
2685 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2686 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2688 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2694 /*******************************************************************
2695 reads or writes a structure.
2696 ********************************************************************/
2698 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2699 prs_struct *ps, int depth)
2704 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2710 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2713 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2719 /*******************************************************************
2720 inits a SAMR_R_SET_GROUPINFO structure.
2721 ********************************************************************/
2723 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2725 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2727 r_u->status = status;
2730 /*******************************************************************
2731 reads or writes a structure.
2732 ********************************************************************/
2734 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2735 prs_struct *ps, int depth)
2740 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2746 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2752 /*******************************************************************
2753 inits a SAMR_Q_QUERY_GROUPINFO structure.
2754 ********************************************************************/
2756 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2757 POLICY_HND *pol, uint16 switch_level)
2759 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2763 q_e->switch_level = switch_level;
2766 /*******************************************************************
2767 reads or writes a structure.
2768 ********************************************************************/
2770 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2771 prs_struct *ps, int depth)
2776 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2782 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2785 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2791 /*******************************************************************
2792 inits a SAMR_R_QUERY_GROUPINFO structure.
2793 ********************************************************************/
2795 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2796 GROUP_INFO_CTR * ctr, NTSTATUS status)
2798 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2800 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2802 r_u->status = status;
2805 /*******************************************************************
2806 reads or writes a structure.
2807 ********************************************************************/
2809 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2810 prs_struct *ps, int depth)
2815 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2821 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2824 if (r_u->ptr != 0) {
2825 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2831 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2837 /*******************************************************************
2838 inits a SAMR_Q_QUERY_GROUPMEM structure.
2839 ********************************************************************/
2841 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2843 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2845 q_c->group_pol = *hnd;
2848 /*******************************************************************
2849 reads or writes a structure.
2850 ********************************************************************/
2852 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2853 prs_struct *ps, int depth)
2858 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2864 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2870 /*******************************************************************
2871 inits a SAMR_R_QUERY_GROUPMEM structure.
2872 ********************************************************************/
2874 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2875 uint32 num_entries, uint32 *rid,
2876 uint32 *attr, NTSTATUS status)
2878 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2880 if (NT_STATUS_IS_OK(status)) {
2882 r_u->num_entries = num_entries;
2884 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2885 r_u->ptr_rids = rid != NULL ? 1 : 0;
2887 r_u->num_rids = num_entries;
2890 r_u->num_attrs = num_entries;
2894 r_u->num_entries = 0;
2897 r_u->status = status;
2900 /*******************************************************************
2901 reads or writes a structure.
2902 ********************************************************************/
2904 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2905 prs_struct *ps, int depth)
2912 if (UNMARSHALLING(ps))
2915 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2921 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2923 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2926 if (r_u->ptr != 0) {
2927 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2929 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2932 if (r_u->ptr_rids != 0) {
2933 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2935 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2936 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2937 if (r_u->rid == NULL)
2941 for (i = 0; i < r_u->num_rids; i++) {
2942 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2947 if (r_u->ptr_attrs != 0) {
2948 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2951 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2952 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2953 if (r_u->attr == NULL)
2957 for (i = 0; i < r_u->num_attrs; i++) {
2958 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2964 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2970 /*******************************************************************
2971 inits a SAMR_Q_QUERY_USERGROUPS structure.
2972 ********************************************************************/
2974 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2977 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2982 /*******************************************************************
2983 reads or writes a structure.
2984 ********************************************************************/
2986 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2987 prs_struct *ps, int depth)
2992 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2998 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3004 /*******************************************************************
3005 inits a SAMR_R_QUERY_USERGROUPS structure.
3006 ********************************************************************/
3008 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3009 uint32 num_gids, DOM_GID * gid,
3012 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3014 if (NT_STATUS_IS_OK(status)) {
3016 r_u->num_entries = num_gids;
3017 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3018 r_u->num_entries2 = num_gids;
3023 r_u->num_entries = 0;
3028 r_u->status = status;
3031 /*******************************************************************
3032 reads or writes a structure.
3033 ********************************************************************/
3035 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3036 prs_struct *ps, int depth)
3042 prs_debug(ps, depth, desc, "samr_io_gids");
3048 if(!prs_uint32("num_gids", ps, depth, num_gids))
3051 if ((*num_gids) != 0) {
3052 if (UNMARSHALLING(ps)) {
3053 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3056 if ((*gid) == NULL) {
3060 for (i = 0; i < (*num_gids); i++) {
3061 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3069 /*******************************************************************
3070 reads or writes a structure.
3071 ********************************************************************/
3073 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3074 prs_struct *ps, int depth)
3079 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3085 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3088 if (r_u->ptr_0 != 0) {
3089 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3091 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3094 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3095 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3102 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3108 /*******************************************************************
3109 inits a SAMR_Q_ENUM_DOMAINS structure.
3110 ********************************************************************/
3112 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3114 uint32 start_idx, uint32 size)
3116 DEBUG(5, ("init_samr_q_enum_domains\n"));
3120 q_e->start_idx = start_idx;
3121 q_e->max_size = size;
3124 /*******************************************************************
3125 reads or writes a structure.
3126 ********************************************************************/
3128 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3129 prs_struct *ps, int depth)
3134 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3140 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3143 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3145 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3151 /*******************************************************************
3152 inits a SAMR_R_ENUM_DOMAINS structure.
3153 ********************************************************************/
3155 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3156 uint32 next_idx, uint32 num_sam_entries)
3158 DEBUG(5, ("init_samr_r_enum_domains\n"));
3160 r_u->next_idx = next_idx;
3162 if (num_sam_entries != 0) {
3163 r_u->ptr_entries1 = 1;
3164 r_u->ptr_entries2 = 1;
3165 r_u->num_entries2 = num_sam_entries;
3166 r_u->num_entries3 = num_sam_entries;
3168 r_u->num_entries4 = num_sam_entries;
3170 r_u->ptr_entries1 = 0;
3171 r_u->num_entries2 = num_sam_entries;
3172 r_u->ptr_entries2 = 1;
3176 /*******************************************************************
3177 reads or writes a structure.
3178 ********************************************************************/
3180 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3181 prs_struct *ps, int depth)
3188 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3194 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3196 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3199 if (r_u->ptr_entries1 != 0) {
3200 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3202 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3204 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3207 if (UNMARSHALLING(ps)) {
3208 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3209 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3212 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3213 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3214 r_u->num_entries4 = 0;
3215 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3219 for (i = 0; i < r_u->num_entries2; i++) {
3221 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3222 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3226 for (i = 0; i < r_u->num_entries2; i++) {
3228 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3229 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3230 r_u->sam[i].hdr_name.buffer, ps,
3239 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3241 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3247 /*******************************************************************
3248 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3249 ********************************************************************/
3251 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3253 uint32 start_idx, uint32 size)
3255 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3259 q_e->start_idx = start_idx;
3260 q_e->max_size = size;
3263 /*******************************************************************
3264 reads or writes a structure.
3265 ********************************************************************/
3267 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3268 prs_struct *ps, int depth)
3273 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3279 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3282 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3284 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3290 /*******************************************************************
3291 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3292 ********************************************************************/
3294 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3295 uint32 next_idx, uint32 num_sam_entries)
3297 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3299 r_u->next_idx = next_idx;
3301 if (num_sam_entries != 0) {
3302 r_u->ptr_entries1 = 1;
3303 r_u->ptr_entries2 = 1;
3304 r_u->num_entries2 = num_sam_entries;
3305 r_u->num_entries3 = num_sam_entries;
3307 r_u->num_entries4 = num_sam_entries;
3309 r_u->ptr_entries1 = 0;
3310 r_u->num_entries2 = num_sam_entries;
3311 r_u->ptr_entries2 = 1;
3315 /*******************************************************************
3316 reads or writes a structure.
3317 ********************************************************************/
3319 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3320 prs_struct *ps, int depth)
3327 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3333 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3335 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3338 if (r_u->ptr_entries1 != 0) {
3339 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3341 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3343 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3346 if (UNMARSHALLING(ps)) {
3347 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3348 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3351 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3353 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3354 r_u->num_entries4 = 0;
3355 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3359 for (i = 0; i < r_u->num_entries2; i++) {
3360 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3364 for (i = 0; i < r_u->num_entries2; i++) {
3365 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3366 r_u->sam[i].hdr_name.buffer, ps, depth))
3373 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3375 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3381 /*******************************************************************
3382 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3383 ********************************************************************/
3385 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3386 POLICY_HND *pol, uint32 start_idx,
3389 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3393 q_e->start_idx = start_idx;
3394 q_e->max_size = size;
3398 /*******************************************************************
3399 reads or writes a structure.
3400 ********************************************************************/
3402 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3403 prs_struct *ps, int depth)
3408 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3414 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3417 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3419 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3425 /*******************************************************************
3426 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3427 ********************************************************************/
3429 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3431 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3433 r_u->next_idx = next_idx;
3435 if (num_sam_entries != 0) {
3436 r_u->ptr_entries1 = 1;
3437 r_u->ptr_entries2 = 1;
3438 r_u->num_entries2 = num_sam_entries;
3439 r_u->num_entries3 = num_sam_entries;
3441 r_u->num_entries4 = num_sam_entries;
3443 r_u->ptr_entries1 = 0;
3444 r_u->num_entries2 = num_sam_entries;
3445 r_u->ptr_entries2 = 1;
3449 /*******************************************************************
3450 reads or writes a structure.
3451 ********************************************************************/
3453 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3454 prs_struct *ps, int depth)
3461 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3467 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3469 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3472 if (r_u->ptr_entries1 != 0) {
3473 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3475 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3477 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3480 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3481 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3482 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3485 if (r_u->num_entries2 != 0 &&
3486 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3487 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3488 r_u->num_entries4 = 0;
3489 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3493 for (i = 0; i < r_u->num_entries2; i++) {
3494 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3498 for (i = 0; i < r_u->num_entries2; i++) {
3499 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3500 r_u->sam[i].hdr_name.buffer, ps,
3508 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3510 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3516 /*******************************************************************
3517 inits a ALIAS_INFO1 structure.
3518 ********************************************************************/
3520 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3522 DEBUG(5, ("init_samr_alias_info1\n"));
3524 init_unistr2(&al1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
3525 init_uni_hdr(&al1->hdr_acct_name, &al1->uni_acct_name);
3527 al1->num_member=num_member;
3529 init_unistr2(&al1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3530 init_uni_hdr(&al1->hdr_acct_desc, &al1->uni_acct_name);
3533 /*******************************************************************
3534 reads or writes a structure.
3535 ********************************************************************/
3537 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3538 prs_struct *ps, int depth)
3543 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3549 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3551 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3553 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3556 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3557 al1->hdr_acct_name.buffer, ps, depth))
3563 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3564 al1->hdr_acct_desc.buffer, ps, depth))
3570 /*******************************************************************
3571 inits a ALIAS_INFO3 structure.
3572 ********************************************************************/
3574 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3576 DEBUG(5, ("init_samr_alias_info3\n"));
3578 init_unistr2(&al3->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3579 init_uni_hdr(&al3->hdr_acct_desc, &al3->uni_acct_desc);
3582 /*******************************************************************
3583 reads or writes a structure.
3584 ********************************************************************/
3586 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
3587 prs_struct *ps, int depth)
3592 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3598 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3600 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3601 al3->hdr_acct_desc.buffer, ps, depth))
3607 /*******************************************************************
3608 reads or writes a structure.
3609 ********************************************************************/
3611 BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr,
3612 prs_struct *ps, int depth)
3617 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3620 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3622 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3625 switch (ctr->switch_value1) {
3627 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3631 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3635 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3642 /*******************************************************************
3643 inits a SAMR_Q_QUERY_ALIASINFO structure.
3644 ********************************************************************/
3646 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3647 POLICY_HND *pol, uint16 switch_level)
3649 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3652 q_e->switch_level = switch_level;
3655 /*******************************************************************
3656 reads or writes a structure.
3657 ********************************************************************/
3659 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3660 prs_struct *ps, int depth)
3665 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3671 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3674 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3680 /*******************************************************************
3681 inits a SAMR_R_QUERY_ALIASINFO structure.
3682 ********************************************************************/
3684 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3685 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3687 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3689 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3691 r_u->status = status;
3694 /*******************************************************************
3695 reads or writes a structure.
3696 ********************************************************************/
3698 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3699 prs_struct *ps, int depth)
3704 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3710 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3713 if (r_u->ptr != 0) {
3714 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3720 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3726 /*******************************************************************
3727 inits a SAMR_Q_SET_ALIASINFO structure.
3728 ********************************************************************/
3730 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3731 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3733 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3735 q_u->alias_pol = *hnd;
3739 /*******************************************************************
3740 reads or writes a structure.
3741 ********************************************************************/
3743 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3744 prs_struct *ps, int depth)
3749 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3755 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3757 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3763 /*******************************************************************
3764 reads or writes a structure.
3765 ********************************************************************/
3767 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3768 prs_struct *ps, int depth)
3773 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3778 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3784 /*******************************************************************
3785 inits a SAMR_Q_QUERY_USERALIASES structure.
3786 ********************************************************************/
3788 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3791 uint32 *ptr_sid, DOM_SID2 * sid)
3793 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3797 q_u->num_sids1 = num_sids;
3799 q_u->num_sids2 = num_sids;
3801 q_u->ptr_sid = ptr_sid;
3805 /*******************************************************************
3806 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3807 ********************************************************************/
3809 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3810 prs_struct *ps, int depth)
3818 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3824 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3827 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3829 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3835 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3838 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3839 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3840 if (q_u->ptr_sid == NULL)
3843 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3844 if (q_u->sid == NULL)
3848 for (i = 0; i < q_u->num_sids2; i++) {
3849 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3850 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3854 for (i = 0; i < q_u->num_sids2; i++) {
3855 if (q_u->ptr_sid[i] != 0) {
3856 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3857 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3865 /*******************************************************************
3866 inits a SAMR_R_QUERY_USERALIASES structure.
3867 ********************************************************************/
3869 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3870 uint32 num_rids, uint32 *rid,
3873 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3875 if (NT_STATUS_IS_OK(status)) {
3876 r_u->num_entries = num_rids;
3878 r_u->num_entries2 = num_rids;
3882 r_u->num_entries = 0;
3884 r_u->num_entries2 = 0;
3887 r_u->status = status;
3890 /*******************************************************************
3891 reads or writes a structure.
3892 ********************************************************************/
3894 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3895 prs_struct *ps, int depth)
3902 prs_debug(ps, depth, desc, "samr_io_rids");
3908 if(!prs_uint32("num_rids", ps, depth, num_rids))
3911 if ((*num_rids) != 0) {
3912 if (UNMARSHALLING(ps)) {
3914 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3919 for (i = 0; i < (*num_rids); i++) {
3920 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3921 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3929 /*******************************************************************
3930 reads or writes a structure.
3931 ********************************************************************/
3933 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3934 prs_struct *ps, int depth)
3939 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3945 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3947 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3950 if (r_u->ptr != 0) {
3951 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3957 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3963 /*******************************************************************
3964 inits a SAMR_Q_OPEN_ALIAS structure.
3965 ********************************************************************/
3967 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3968 uint32 access_mask, uint32 rid)
3970 DEBUG(5, ("init_samr_q_open_alias\n"));
3972 q_u->dom_pol = *pol;
3973 q_u->access_mask = access_mask;
3974 q_u->rid_alias = rid;
3977 /*******************************************************************
3978 reads or writes a structure.
3979 ********************************************************************/
3981 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3982 prs_struct *ps, int depth)
3987 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3993 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3996 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3998 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
4004 /*******************************************************************
4005 reads or writes a structure.
4006 ********************************************************************/
4008 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4009 prs_struct *ps, int depth)
4014 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4020 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4023 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4029 /*******************************************************************
4030 inits a SAMR_Q_LOOKUP_RIDS structure.
4031 ********************************************************************/
4033 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4034 POLICY_HND *pol, uint32 flags,
4035 uint32 num_rids, uint32 *rid)
4037 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4041 q_u->num_rids1 = num_rids;
4044 q_u->num_rids2 = num_rids;
4045 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4046 if (q_u->rid == NULL) {
4050 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4054 /*******************************************************************
4055 reads or writes a structure.
4056 ********************************************************************/
4058 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4059 prs_struct *ps, int depth)
4067 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4070 if (UNMARSHALLING(ps))
4076 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4079 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4081 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4083 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4085 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4088 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4089 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4090 if (q_u->rid == NULL)
4094 for (i = 0; i < q_u->num_rids2; i++) {
4095 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4096 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4103 /*******************************************************************
4104 inits a SAMR_R_LOOKUP_RIDS structure.
4105 ********************************************************************/
4107 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4108 uint32 num_names, UNIHDR * hdr_name,
4109 UNISTR2 *uni_name, uint32 *type)
4111 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4113 r_u->hdr_name = NULL;
4114 r_u->uni_name = NULL;
4117 if (num_names != 0) {
4118 r_u->num_names1 = num_names;
4120 r_u->num_names2 = num_names;
4122 r_u->num_types1 = num_names;
4124 r_u->num_types2 = num_names;
4126 r_u->hdr_name = hdr_name;
4127 r_u->uni_name = uni_name;
4130 r_u->num_names1 = num_names;
4132 r_u->num_names2 = num_names;
4134 r_u->num_types1 = num_names;
4136 r_u->num_types2 = num_names;
4140 /*******************************************************************
4141 reads or writes a structure.
4142 ********************************************************************/
4144 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4145 prs_struct *ps, int depth)
4152 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4158 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4160 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4163 if (r_u->ptr_names != 0) {
4165 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4169 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4170 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4171 if (r_u->hdr_name == NULL)
4174 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4175 if (r_u->uni_name == NULL)
4179 for (i = 0; i < r_u->num_names2; i++) {
4180 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4181 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4184 for (i = 0; i < r_u->num_names2; i++) {
4185 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4186 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4194 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4196 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4199 if (r_u->ptr_types != 0) {
4201 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4204 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4205 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4206 if (r_u->type == NULL)
4210 for (i = 0; i < r_u->num_types2; i++) {
4211 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4212 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4217 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4223 /*******************************************************************
4224 inits a SAMR_Q_OPEN_ALIAS structure.
4225 ********************************************************************/
4227 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4229 DEBUG(5, ("init_samr_q_delete_alias\n"));
4231 q_u->alias_pol = *hnd;
4234 /*******************************************************************
4235 reads or writes a structure.
4236 ********************************************************************/
4238 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4239 prs_struct *ps, int depth)
4244 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4250 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4256 /*******************************************************************
4257 reads or writes a structure.
4258 ********************************************************************/
4260 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4261 prs_struct *ps, int depth)
4266 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4272 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4274 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4280 /*******************************************************************
4281 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4282 ********************************************************************/
4284 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4285 POLICY_HND *hnd, const char *acct_desc)
4287 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4289 q_u->dom_pol = *hnd;
4291 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4292 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4294 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4297 /*******************************************************************
4298 reads or writes a structure.
4299 ********************************************************************/
4301 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4302 prs_struct *ps, int depth)
4307 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4313 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4316 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4318 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4319 q_u->hdr_acct_desc.buffer, ps, depth))
4324 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4330 /*******************************************************************
4331 reads or writes a structure.
4332 ********************************************************************/
4334 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4335 prs_struct *ps, int depth)
4340 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4346 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4349 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4352 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4358 /*******************************************************************
4359 inits a SAMR_Q_ADD_ALIASMEM structure.
4360 ********************************************************************/
4362 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4365 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4367 q_u->alias_pol = *hnd;
4368 init_dom_sid2(&q_u->sid, sid);
4371 /*******************************************************************
4372 reads or writes a structure.
4373 ********************************************************************/
4375 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4376 prs_struct *ps, int depth)
4381 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4387 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4389 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4395 /*******************************************************************
4396 reads or writes a structure.
4397 ********************************************************************/
4399 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4400 prs_struct *ps, int depth)
4405 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4411 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4417 /*******************************************************************
4418 inits a SAMR_Q_DEL_ALIASMEM structure.
4419 ********************************************************************/
4421 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4424 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4426 q_u->alias_pol = *hnd;
4427 init_dom_sid2(&q_u->sid, sid);
4430 /*******************************************************************
4431 reads or writes a structure.
4432 ********************************************************************/
4434 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4435 prs_struct *ps, int depth)
4440 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4446 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4448 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4454 /*******************************************************************
4455 reads or writes a structure.
4456 ********************************************************************/
4458 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4459 prs_struct *ps, int depth)
4464 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4470 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4476 /*******************************************************************
4477 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4478 ********************************************************************/
4480 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4483 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4485 q_c->alias_pol = *hnd;
4488 /*******************************************************************
4489 reads or writes a structure.
4490 ********************************************************************/
4492 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4493 prs_struct *ps, int depth)
4498 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4504 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4510 /*******************************************************************
4511 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4512 ********************************************************************/
4514 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4517 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4519 r_u->status = status;
4522 /*******************************************************************
4523 reads or writes a structure.
4524 ********************************************************************/
4526 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4527 prs_struct *ps, int depth)
4532 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4538 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4544 /*******************************************************************
4545 inits a SAMR_Q_QUERY_ALIASMEM structure.
4546 ********************************************************************/
4548 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4551 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4553 q_c->alias_pol = *hnd;
4556 /*******************************************************************
4557 reads or writes a structure.
4558 ********************************************************************/
4560 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4561 prs_struct *ps, int depth)
4566 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4572 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4578 /*******************************************************************
4579 inits a SAMR_R_QUERY_ALIASMEM structure.
4580 ********************************************************************/
4582 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4583 uint32 num_sids, DOM_SID2 * sid,
4586 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4588 if (NT_STATUS_IS_OK(status)) {
4589 r_u->num_sids = num_sids;
4590 r_u->ptr = (num_sids != 0) ? 1 : 0;
4591 r_u->num_sids1 = num_sids;
4599 r_u->status = status;
4602 /*******************************************************************
4603 reads or writes a structure.
4604 ********************************************************************/
4606 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4607 prs_struct *ps, int depth)
4614 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4620 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4622 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4625 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4626 uint32 *ptr_sid = NULL;
4628 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4631 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4636 for (i = 0; i < r_u->num_sids1; i++) {
4638 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4642 if (UNMARSHALLING(ps)) {
4643 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4646 for (i = 0; i < r_u->num_sids1; i++) {
4647 if (ptr_sid[i] != 0) {
4648 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4656 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4662 /*******************************************************************
4663 inits a SAMR_Q_LOOKUP_NAMES structure.
4664 ********************************************************************/
4666 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4667 POLICY_HND *pol, uint32 flags,
4668 uint32 num_names, const char **name)
4672 DEBUG(5, ("init_samr_q_lookup_names\n"));
4676 q_u->num_names1 = num_names;
4679 q_u->num_names2 = num_names;
4681 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4682 return NT_STATUS_NO_MEMORY;
4684 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4685 return NT_STATUS_NO_MEMORY;
4687 for (i = 0; i < num_names; i++) {
4688 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4689 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4692 return NT_STATUS_OK;
4695 /*******************************************************************
4696 reads or writes a structure.
4697 ********************************************************************/
4699 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4700 prs_struct *ps, int depth)
4707 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4710 if (UNMARSHALLING(ps))
4716 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4719 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4721 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4723 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4725 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4728 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4729 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4730 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4731 if (!q_u->hdr_name || !q_u->uni_name)
4735 for (i = 0; i < q_u->num_names2; i++) {
4736 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4740 for (i = 0; i < q_u->num_names2; i++) {
4741 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4748 /*******************************************************************
4749 inits a SAMR_R_LOOKUP_NAMES structure.
4750 ********************************************************************/
4752 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4754 uint32 *rid, uint32 *type,
4757 DEBUG(5, ("init_samr_r_lookup_names\n"));
4759 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4762 r_u->num_types1 = num_rids;
4764 r_u->num_types2 = num_rids;
4766 r_u->num_rids1 = num_rids;
4768 r_u->num_rids2 = num_rids;
4770 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4771 return NT_STATUS_NO_MEMORY;
4772 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4773 return NT_STATUS_NO_MEMORY;
4775 if (!r_u->rids || !r_u->types)
4778 for (i = 0; i < num_rids; i++) {
4779 r_u->rids[i] = rid[i];
4780 r_u->types[i] = type[i];
4785 r_u->num_types1 = 0;
4787 r_u->num_types2 = 0;
4797 r_u->status = status;
4799 return NT_STATUS_OK;
4802 /*******************************************************************
4803 reads or writes a structure.
4804 ********************************************************************/
4806 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4807 prs_struct *ps, int depth)
4815 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4818 if (UNMARSHALLING(ps))
4824 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4826 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4829 if (r_u->ptr_rids != 0) {
4830 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4833 if (r_u->num_rids2 != r_u->num_rids1) {
4838 if (UNMARSHALLING(ps))
4839 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4842 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4846 for (i = 0; i < r_u->num_rids2; i++) {
4847 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4848 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4853 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4855 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4858 if (r_u->ptr_types != 0) {
4859 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4862 if (r_u->num_types2 != r_u->num_types1) {
4867 if (UNMARSHALLING(ps))
4868 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4871 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4875 for (i = 0; i < r_u->num_types2; i++) {
4876 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4877 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4882 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4888 /*******************************************************************
4889 inits a SAMR_Q_DELETE_DOM_USER structure.
4890 ********************************************************************/
4892 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4895 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4897 q_c->user_pol = *hnd;
4900 /*******************************************************************
4901 reads or writes a structure.
4902 ********************************************************************/
4904 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4905 prs_struct *ps, int depth)
4910 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4916 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4922 /*******************************************************************
4923 reads or writes a structure.
4924 ********************************************************************/
4926 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4927 prs_struct *ps, int depth)
4932 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4938 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4940 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4946 /*******************************************************************
4947 reads or writes a structure.
4948 ********************************************************************/
4950 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4952 uint32 access_mask, uint32 rid)
4954 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4956 q_u->domain_pol = *pol;
4957 q_u->access_mask = access_mask;
4958 q_u->user_rid = rid;
4961 /*******************************************************************
4962 reads or writes a structure.
4963 ********************************************************************/
4965 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4966 prs_struct *ps, int depth)
4971 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4977 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4980 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4982 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4988 /*******************************************************************
4989 reads or writes a structure.
4990 ********************************************************************/
4992 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4993 prs_struct *ps, int depth)
4998 prs_debug(ps, depth, desc, "samr_io_r_open_user");
5004 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5007 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5014 /*******************************************************************
5015 reads or writes a structure.
5016 ********************************************************************/
5018 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5021 uint32 acb_info, uint32 access_mask)
5023 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5025 q_u->domain_pol = *pol;
5027 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5028 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5030 q_u->acb_info = acb_info;
5031 q_u->access_mask = access_mask;
5034 /*******************************************************************
5035 reads or writes a structure.
5036 ********************************************************************/
5038 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5039 prs_struct *ps, int depth)
5044 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5050 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5053 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5055 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5060 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5062 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5068 /*******************************************************************
5069 reads or writes a structure.
5070 ********************************************************************/
5072 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5073 prs_struct *ps, int depth)
5078 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5084 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5087 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5089 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5091 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5097 /*******************************************************************
5098 inits a SAMR_Q_QUERY_USERINFO structure.
5099 ********************************************************************/
5101 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5102 POLICY_HND *hnd, uint16 switch_value)
5104 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5107 q_u->switch_value = switch_value;
5110 /*******************************************************************
5111 reads or writes a structure.
5112 ********************************************************************/
5114 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5115 prs_struct *ps, int depth)
5120 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5126 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5129 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5135 /*******************************************************************
5136 reads or writes a LOGON_HRS structure.
5137 ********************************************************************/
5139 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5140 prs_struct *ps, int depth)
5145 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5151 if(!prs_uint32("len ", ps, depth, &hrs->len))
5154 if (hrs->len > sizeof(hrs->hours)) {
5155 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5156 hrs->len = sizeof(hrs->hours);
5159 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5165 /*******************************************************************
5166 inits a SAM_USER_INFO_12 structure.
5167 ********************************************************************/
5169 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5170 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5172 DEBUG(5, ("init_sam_user_info12\n"));
5174 usr->lm_pwd_active =
5175 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5176 usr->nt_pwd_active =
5177 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5180 /*******************************************************************
5181 reads or writes a structure.
5182 ********************************************************************/
5184 static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u,
5185 prs_struct *ps, int depth)
5190 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5196 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5198 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5201 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5203 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5209 /*******************************************************************
5210 inits a SAM_USER_INFO_7 structure.
5211 ********************************************************************/
5213 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5215 DEBUG(5, ("init_sam_user_info7\n"));
5217 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5218 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5222 /*******************************************************************
5223 reads or writes a structure.
5224 ********************************************************************/
5226 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5227 prs_struct *ps, int depth)
5232 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5238 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5241 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5247 /*******************************************************************
5248 inits a SAM_USER_INFO_10 structure.
5249 ********************************************************************/
5251 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5253 DEBUG(5, ("init_sam_user_info10\n"));
5255 usr->acb_info = acb_info;
5258 /*******************************************************************
5259 reads or writes a structure.
5260 ********************************************************************/
5262 static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr,
5263 prs_struct *ps, int depth)
5268 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5274 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5280 /*******************************************************************
5281 inits a SAM_USER_INFO_11 structure.
5282 ********************************************************************/
5284 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5287 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5289 DEBUG(5, ("init_sam_user_info11\n"));
5291 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5292 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5294 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5296 usr->ptr_1 = 1; /* pointer */
5297 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5298 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5300 usr->ptr_2 = 1; /* pointer */
5301 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5303 usr->ptr_3 = 1; /* pointer */
5304 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5306 usr->rid_user = rid_user;
5307 usr->rid_group = rid_group;
5309 usr->acct_ctrl = acct_ctrl;
5310 usr->unknown_3 = 0x0000;
5312 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5313 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5315 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5316 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5318 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5319 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5322 /*******************************************************************
5323 reads or writes a structure.
5324 ********************************************************************/
5326 static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr,
5327 prs_struct *ps, int depth)
5332 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5338 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5341 if(!smb_io_time("time", &usr->expiry, ps, depth))
5344 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5347 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5350 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5353 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5355 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5358 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5361 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5363 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5366 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5368 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5371 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5373 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5375 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5377 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5379 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5381 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5384 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5387 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5390 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5396 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5402 /*************************************************************************
5404 *************************************************************************/
5406 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5408 DEBUG(10, ("init_sam_user_info24:\n"));
5409 memcpy(usr->pass, newpass, sizeof(usr->pass));
5410 usr->pw_len = pw_len;
5413 /*******************************************************************
5414 reads or writes a structure.
5415 ********************************************************************/
5417 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5418 prs_struct *ps, int depth)
5423 prs_debug(ps, depth, desc, "sam_io_user_info24");
5429 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5433 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5434 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5443 /*************************************************************************
5444 init_sam_user_info23
5446 unknown_6 = 0x0000 04ec
5448 *************************************************************************/
5450 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5451 NTTIME * logoff_time, /* all zeros */
5452 NTTIME * kickoff_time, /* all zeros */
5453 NTTIME * pass_last_set_time, /* all zeros */
5454 NTTIME * pass_can_change_time, /* all zeros */
5455 NTTIME * pass_must_change_time, /* all zeros */
5466 uint32 user_rid, /* 0x0000 0000 */
5469 uint32 fields_present,
5472 uint16 bad_password_count,
5474 char newpass[516], uint32 unknown_6)
5476 usr->logon_time = *logon_time; /* all zeros */
5477 usr->logoff_time = *logoff_time; /* all zeros */
5478 usr->kickoff_time = *kickoff_time; /* all zeros */
5479 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5480 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5481 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5483 ZERO_STRUCT(usr->nt_pwd);
5484 ZERO_STRUCT(usr->lm_pwd);
5486 usr->user_rid = user_rid; /* 0x0000 0000 */
5487 usr->group_rid = group_rid;
5488 usr->acb_info = acb_info;
5489 usr->fields_present = fields_present; /* 09f8 27fa */
5491 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5492 usr->ptr_logon_hrs = hrs ? 1 : 0;
5494 if (nt_time_is_zero(pass_must_change_time)) {
5495 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5497 usr->passmustchange=0;
5500 ZERO_STRUCT(usr->padding1);
5501 ZERO_STRUCT(usr->padding2);
5503 usr->bad_password_count = bad_password_count;
5504 usr->logon_count = logon_count;
5506 memcpy(usr->pass, newpass, sizeof(usr->pass));
5508 copy_unistr2(&usr->uni_user_name, user_name);
5509 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5511 copy_unistr2(&usr->uni_full_name, full_name);
5512 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5514 copy_unistr2(&usr->uni_home_dir, home_dir);
5515 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5517 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5518 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5520 copy_unistr2(&usr->uni_logon_script, log_scr);
5521 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5523 copy_unistr2(&usr->uni_profile_path, prof_path);
5524 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5526 copy_unistr2(&usr->uni_acct_desc, desc);
5527 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5529 copy_unistr2(&usr->uni_workstations, wkstas);
5530 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5532 copy_unistr2(&usr->uni_unknown_str, unk_str);
5533 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5535 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5536 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5538 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5541 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5544 /*************************************************************************
5545 init_sam_user_info23
5547 unknown_6 = 0x0000 04ec
5549 *************************************************************************/
5551 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5552 NTTIME * logoff_time, /* all zeros */
5553 NTTIME * kickoff_time, /* all zeros */
5554 NTTIME * pass_last_set_time, /* all zeros */
5555 NTTIME * pass_can_change_time, /* all zeros */
5556 NTTIME * pass_must_change_time, /* all zeros */
5557 char *user_name, /* NULL */
5559 char *home_dir, char *dir_drive, char *log_scr,
5560 char *prof_path, const char *desc, char *wkstas,
5561 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5562 uint32 group_rid, uint32 acb_info,
5563 uint32 fields_present, uint16 logon_divs,
5564 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5565 char newpass[516], uint32 unknown_6)
5567 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5569 usr->logon_time = *logon_time; /* all zeros */
5570 usr->logoff_time = *logoff_time; /* all zeros */
5571 usr->kickoff_time = *kickoff_time; /* all zeros */
5572 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5573 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5574 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5576 ZERO_STRUCT(usr->nt_pwd);
5577 ZERO_STRUCT(usr->lm_pwd);
5579 usr->user_rid = user_rid; /* 0x0000 0000 */
5580 usr->group_rid = group_rid;
5581 usr->acb_info = acb_info;
5582 usr->fields_present = fields_present; /* 09f8 27fa */
5584 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5585 usr->ptr_logon_hrs = hrs ? 1 : 0;
5587 if (nt_time_is_zero(pass_must_change_time)) {
5588 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5590 usr->passmustchange=0;
5593 ZERO_STRUCT(usr->padding1);
5594 ZERO_STRUCT(usr->padding2);
5596 usr->bad_password_count = bad_password_count;
5597 usr->logon_count = logon_count;
5599 memcpy(usr->pass, newpass, sizeof(usr->pass));
5601 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5602 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5604 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5605 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5607 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5608 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5610 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5611 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5613 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5614 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5616 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5617 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5619 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5620 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5622 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5623 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5625 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5626 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5628 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5629 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5631 data_blob_free(&blob);
5633 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5636 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5639 /*******************************************************************
5640 reads or writes a structure.
5641 ********************************************************************/
5643 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5644 prs_struct *ps, int depth)
5649 prs_debug(ps, depth, desc, "sam_io_user_info23");
5655 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5657 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5659 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5661 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5663 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5665 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5668 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5670 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5672 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5674 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5676 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5678 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5680 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5682 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5684 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5686 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5689 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5691 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5694 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5696 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5698 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5701 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5703 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5707 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5710 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5712 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5715 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5717 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5719 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5723 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5726 /* here begins pointed-to data */
5728 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5731 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5734 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5737 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5740 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5743 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5746 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5749 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5752 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5755 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5758 /* ok, this is only guess-work (as usual) */
5759 if (usr->ptr_logon_hrs) {
5760 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5762 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5764 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5766 } else if (UNMARSHALLING(ps)) {
5774 /*******************************************************************
5775 reads or writes a structure.
5776 NB. This structure is *definately* incorrect. It's my best guess
5777 currently for W2K SP2. The password field is encrypted in a different
5778 way than normal... And there are definately other problems. JRA.
5779 ********************************************************************/
5781 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5786 prs_debug(ps, depth, desc, "sam_io_user_info25");
5792 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5794 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5796 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5798 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5800 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5802 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5805 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5807 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5809 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5811 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5813 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5815 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5817 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5819 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5821 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5823 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5826 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5828 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5831 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5833 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5835 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5838 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5841 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5844 /* here begins pointed-to data */
5846 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5849 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5852 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5855 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5858 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5861 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5864 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5867 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5870 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5873 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5876 #if 0 /* JRA - unknown... */
5877 /* ok, this is only guess-work (as usual) */
5878 if (usr->ptr_logon_hrs) {
5879 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5881 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5883 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5885 } else if (UNMARSHALLING(ps)) {
5895 /*************************************************************************
5896 init_sam_user_info21W
5898 unknown_6 = 0x0000 04ec
5900 *************************************************************************/
5902 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5903 NTTIME * logon_time,
5904 NTTIME * logoff_time,
5905 NTTIME * kickoff_time,
5906 NTTIME * pass_last_set_time,
5907 NTTIME * pass_can_change_time,
5908 NTTIME * pass_must_change_time,
5924 uint32 fields_present,
5927 uint16 bad_password_count,
5931 usr->logon_time = *logon_time;
5932 usr->logoff_time = *logoff_time;
5933 usr->kickoff_time = *kickoff_time;
5934 usr->pass_last_set_time = *pass_last_set_time;
5935 usr->pass_can_change_time = *pass_can_change_time;
5936 usr->pass_must_change_time = *pass_must_change_time;
5938 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5939 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5941 usr->user_rid = user_rid;
5942 usr->group_rid = group_rid;
5943 usr->acb_info = acb_info;
5944 usr->fields_present = fields_present; /* 0x00ff ffff */
5946 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5947 usr->ptr_logon_hrs = hrs ? 1 : 0;
5948 usr->bad_password_count = bad_password_count;
5949 usr->logon_count = logon_count;
5951 if (nt_time_is_zero(pass_must_change_time)) {
5952 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5954 usr->passmustchange=0;
5957 ZERO_STRUCT(usr->padding1);
5958 ZERO_STRUCT(usr->padding2);
5960 copy_unistr2(&usr->uni_user_name, user_name);
5961 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5963 copy_unistr2(&usr->uni_full_name, full_name);
5964 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5966 copy_unistr2(&usr->uni_home_dir, home_dir);
5967 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5969 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5970 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5972 copy_unistr2(&usr->uni_logon_script, log_scr);
5973 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5975 copy_unistr2(&usr->uni_profile_path, prof_path);
5976 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5978 copy_unistr2(&usr->uni_acct_desc, desc);
5979 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5981 copy_unistr2(&usr->uni_workstations, wkstas);
5982 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5984 copy_unistr2(&usr->uni_unknown_str, unk_str);
5985 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5987 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5988 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5990 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5993 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5996 /*************************************************************************
5997 init_sam_user_info21
5999 unknown_6 = 0x0000 04ec
6001 *************************************************************************/
6003 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
6005 NTTIME logon_time, logoff_time, kickoff_time,
6006 pass_last_set_time, pass_can_change_time,
6007 pass_must_change_time;
6009 const char* user_name = pdb_get_username(pw);
6010 const char* full_name = pdb_get_fullname(pw);
6011 const char* home_dir = pdb_get_homedir(pw);
6012 const char* dir_drive = pdb_get_dir_drive(pw);
6013 const char* logon_script = pdb_get_logon_script(pw);
6014 const char* profile_path = pdb_get_profile_path(pw);
6015 const char* description = pdb_get_acct_desc(pw);
6016 const char* workstations = pdb_get_workstations(pw);
6017 const char* munged_dial = pdb_get_munged_dial(pw);
6018 DATA_BLOB munged_dial_blob;
6021 const DOM_SID *user_sid;
6024 const DOM_SID *group_sid;
6027 munged_dial_blob = base64_decode_data_blob(munged_dial);
6029 munged_dial_blob = data_blob(NULL, 0);
6032 /* Create NTTIME structs */
6033 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6034 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6035 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6036 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6037 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6038 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6040 /* structure assignment */
6041 usr->logon_time = logon_time;
6042 usr->logoff_time = logoff_time;
6043 usr->kickoff_time = kickoff_time;
6044 usr->pass_last_set_time = pass_last_set_time;
6045 usr->pass_can_change_time = pass_can_change_time;
6046 usr->pass_must_change_time = pass_must_change_time;
6048 ZERO_STRUCT(usr->nt_pwd);
6049 ZERO_STRUCT(usr->lm_pwd);
6051 user_sid = pdb_get_user_sid(pw);
6053 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6054 fstring user_sid_string;
6055 fstring domain_sid_string;
6056 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6057 "the domain sid %s. Failing operation.\n",
6059 sid_to_string(user_sid_string, user_sid),
6060 sid_to_string(domain_sid_string, domain_sid)));
6061 data_blob_free(&munged_dial_blob);
6062 return NT_STATUS_UNSUCCESSFUL;
6065 group_sid = pdb_get_group_sid(pw);
6067 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6068 fstring group_sid_string;
6069 fstring domain_sid_string;
6070 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6071 "which conflicts with the domain sid %s. Failing operation.\n",
6073 sid_to_string(group_sid_string, group_sid),
6074 sid_to_string(domain_sid_string, domain_sid)));
6075 data_blob_free(&munged_dial_blob);
6076 return NT_STATUS_UNSUCCESSFUL;
6079 usr->user_rid = user_rid;
6080 usr->group_rid = group_rid;
6081 usr->acb_info = pdb_get_acct_ctrl(pw);
6084 Look at a user on a real NT4 PDC with usrmgr, press
6085 'ok'. Then you will see that fields_present is set to
6086 0x08f827fa. Look at the user immediately after that again,
6087 and you will see that 0x00fffff is returned. This solves
6088 the problem that you get access denied after having looked
6092 usr->fields_present = pdb_build_fields_present(pw);
6094 usr->logon_divs = pdb_get_logon_divs(pw);
6095 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6096 usr->bad_password_count = pdb_get_bad_password_count(pw);
6097 usr->logon_count = pdb_get_logon_count(pw);
6099 if (pdb_get_pass_must_change_time(pw) == 0) {
6100 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6102 usr->passmustchange=0;
6105 ZERO_STRUCT(usr->padding1);
6106 ZERO_STRUCT(usr->padding2);
6108 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6109 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6111 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6112 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6114 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6115 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6117 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6118 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6120 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6121 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6123 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6124 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6126 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6127 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6129 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6130 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6132 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6133 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6135 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6136 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6137 data_blob_free(&munged_dial_blob);
6139 usr->unknown_6 = pdb_get_unknown_6(pw);
6142 if (pdb_get_hours(pw)) {
6143 usr->logon_hrs.len = pdb_get_hours_len(pw);
6144 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6146 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6148 return NT_STATUS_OK;
6151 /*******************************************************************
6152 reads or writes a structure.
6153 ********************************************************************/
6155 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6156 prs_struct *ps, int depth)
6161 prs_debug(ps, depth, desc, "sam_io_user_info21");
6167 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6169 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6171 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6173 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6175 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6177 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6180 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6182 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6184 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6186 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6188 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6190 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6192 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6194 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6196 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6198 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6201 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6203 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6206 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6208 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6210 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6213 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6215 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6219 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6222 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6224 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6227 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6229 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6231 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6234 /* here begins pointed-to data */
6236 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6238 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6240 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6242 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6244 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6246 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6248 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6250 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6252 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6254 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6257 /* ok, this is only guess-work (as usual) */
6258 if (usr->ptr_logon_hrs) {
6261 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6263 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6265 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6267 } else if (UNMARSHALLING(ps)) {
6275 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6277 const char *munged_dial = pdb_get_munged_dial(pw);
6278 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6280 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6281 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6282 data_blob_free(&blob);
6285 /*******************************************************************
6286 reads or writes a structure.
6287 ********************************************************************/
6289 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6290 prs_struct *ps, int depth)
6295 prs_debug(ps, depth, desc, "sam_io_user_info20");
6301 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6304 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6310 /*******************************************************************
6311 inits a SAM_USERINFO_CTR structure.
6312 ********************************************************************/
6314 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6315 uint16 switch_value,
6316 SAM_USER_INFO_21 * usr)
6318 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6320 ctr->switch_value = switch_value;
6321 ctr->info.id = NULL;
6323 switch (switch_value) {
6325 ctr->info.id10 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_10);
6326 if (ctr->info.id10 == NULL)
6327 return NT_STATUS_NO_MEMORY;
6329 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6332 /* whoops - got this wrong. i think. or don't understand what's happening. */
6336 info = (void *)&id11;
6338 expire.low = 0xffffffff;
6339 expire.high = 0x7fffffff;
6341 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_11);
6342 init_sam_user_info11(ctr->info.id11, &expire,
6343 "BROOKFIELDS$", /* name */
6344 0x03ef, /* user rid */
6345 0x201, /* group rid */
6346 0x0080); /* acb info */
6352 ctr->info.id12 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_12);
6353 if (ctr->info.id12 == NULL)
6354 return NT_STATUS_NO_MEMORY;
6356 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6360 SAM_USER_INFO_21 *cusr;
6361 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6362 ctr->info.id21 = cusr;
6363 if (ctr->info.id21 == NULL)
6364 return NT_STATUS_NO_MEMORY;
6365 memcpy(cusr, usr, sizeof(*usr));
6366 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6367 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6371 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6372 return NT_STATUS_INVALID_INFO_CLASS;
6375 return NT_STATUS_OK;
6378 /*******************************************************************
6379 inits a SAM_USERINFO_CTR structure.
6380 ********************************************************************/
6382 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6383 uint16 switch_value, void *info)
6385 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6387 ctr->switch_value = switch_value;
6388 ctr->info.id = info;
6390 switch (switch_value) {
6392 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6393 dump_data(100, (char *)sess_key->data, sess_key->length);
6394 dump_data(100, (char *)ctr->info.id24->pass, 516);
6397 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6398 dump_data(100, (char *)sess_key->data, sess_key->length);
6399 dump_data(100, (char *)ctr->info.id23->pass, 516);
6404 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6408 /*******************************************************************
6409 reads or writes a structure.
6410 ********************************************************************/
6412 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6413 prs_struct *ps, int depth)
6416 SAM_USERINFO_CTR *ctr;
6418 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6421 if (UNMARSHALLING(ps)) {
6422 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6430 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6432 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6439 switch (ctr->switch_value) {
6441 if (UNMARSHALLING(ps))
6442 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6443 if (ctr->info.id7 == NULL) {
6444 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6447 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6450 if (UNMARSHALLING(ps))
6451 ctr->info.id10 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_10,1);
6452 if (ctr->info.id10 == NULL) {
6453 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6456 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6459 if (UNMARSHALLING(ps))
6460 ctr->info.id11 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_11,1);
6462 if (ctr->info.id11 == NULL) {
6463 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6466 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6469 if (UNMARSHALLING(ps))
6470 ctr->info.id12 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_12,1);
6472 if (ctr->info.id12 == NULL) {
6473 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6476 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6479 if (UNMARSHALLING(ps))
6480 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6482 if (ctr->info.id20 == NULL) {
6483 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6486 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6489 if (UNMARSHALLING(ps))
6490 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6492 if (ctr->info.id21 == NULL) {
6493 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6496 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6499 if (UNMARSHALLING(ps))
6500 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6502 if (ctr->info.id23 == NULL) {
6503 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6506 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6509 if (UNMARSHALLING(ps))
6510 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6512 if (ctr->info.id24 == NULL) {
6513 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6516 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6519 if (UNMARSHALLING(ps))
6520 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6522 if (ctr->info.id25 == NULL) {
6523 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6526 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6529 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6537 /*******************************************************************
6538 inits a SAMR_R_QUERY_USERINFO structure.
6539 ********************************************************************/
6541 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6542 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6544 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6549 if (NT_STATUS_IS_OK(status)) {
6554 r_u->status = status; /* return status */
6557 /*******************************************************************
6558 reads or writes a structure.
6559 ********************************************************************/
6561 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6562 prs_struct *ps, int depth)
6567 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6573 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6576 if (r_u->ptr != 0) {
6577 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6583 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6589 /*******************************************************************
6590 inits a SAMR_Q_SET_USERINFO structure.
6591 ********************************************************************/
6593 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6594 POLICY_HND *hnd, DATA_BLOB *sess_key,
6595 uint16 switch_value, void *info)
6597 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6600 q_u->switch_value = switch_value;
6601 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6604 /*******************************************************************
6605 reads or writes a structure.
6606 ********************************************************************/
6608 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6609 prs_struct *ps, int depth)
6614 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6620 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6622 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6624 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6630 /*******************************************************************
6631 inits a SAMR_R_SET_USERINFO structure.
6632 ********************************************************************/
6634 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6636 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6638 r_u->status = status; /* return status */
6641 /*******************************************************************
6642 reads or writes a structure.
6643 ********************************************************************/
6645 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6646 prs_struct *ps, int depth)
6651 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6657 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6663 /*******************************************************************
6664 inits a SAMR_Q_SET_USERINFO2 structure.
6665 ********************************************************************/
6667 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6668 POLICY_HND *hnd, DATA_BLOB *sess_key,
6669 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6671 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6674 q_u->switch_value = switch_value;
6677 if (q_u->ctr != NULL)
6678 q_u->ctr->switch_value = switch_value;
6680 switch (switch_value) {
6682 SamOEMhashBlob(ctr->info.id12->lm_pwd, 16, sess_key);
6683 SamOEMhashBlob(ctr->info.id12->nt_pwd, 16, sess_key);
6684 dump_data(100, (char *)sess_key->data, sess_key->length);
6685 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6686 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6691 /*******************************************************************
6692 reads or writes a structure.
6693 ********************************************************************/
6695 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6696 prs_struct *ps, int depth)
6701 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6707 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6710 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6712 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6718 /*******************************************************************
6719 inits a SAMR_R_SET_USERINFO2 structure.
6720 ********************************************************************/
6722 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6724 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6726 r_u->status = status; /* return status */
6729 /*******************************************************************
6730 reads or writes a structure.
6731 ********************************************************************/
6733 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6734 prs_struct *ps, int depth)
6739 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6745 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6751 /*******************************************************************
6752 inits a SAMR_Q_CONNECT structure.
6753 ********************************************************************/
6755 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6756 char *srv_name, uint32 access_mask)
6758 DEBUG(5, ("init_samr_q_connect\n"));
6760 /* make PDC server name \\server */
6761 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6762 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6764 /* example values: 0x0000 0002 */
6765 q_u->access_mask = access_mask;
6768 /*******************************************************************
6769 reads or writes a structure.
6770 ********************************************************************/
6772 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6773 prs_struct *ps, int depth)
6778 prs_debug(ps, depth, desc, "samr_io_q_connect");
6784 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6786 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6791 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6797 /*******************************************************************
6798 reads or writes a structure.
6799 ********************************************************************/
6801 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6802 prs_struct *ps, int depth)
6807 prs_debug(ps, depth, desc, "samr_io_r_connect");
6813 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6816 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6822 /*******************************************************************
6823 inits a SAMR_Q_CONNECT4 structure.
6824 ********************************************************************/
6826 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6827 char *srv_name, uint32 access_mask)
6829 DEBUG(5, ("init_samr_q_connect\n"));
6831 /* make PDC server name \\server */
6832 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6833 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6835 /* Only value we've seen, possibly an address type ? */
6838 /* example values: 0x0000 0002 */
6839 q_u->access_mask = access_mask;
6842 /*******************************************************************
6843 reads or writes a structure.
6844 ********************************************************************/
6846 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6847 prs_struct *ps, int depth)
6852 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6858 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6860 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6865 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6867 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6873 /*******************************************************************
6874 reads or writes a structure.
6875 ********************************************************************/
6877 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6878 prs_struct *ps, int depth)
6883 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6889 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6892 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6898 /*******************************************************************
6899 inits a SAMR_Q_CONNECT_ANON structure.
6900 ********************************************************************/
6902 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6904 DEBUG(5, ("init_samr_q_connect_anon\n"));
6907 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6908 q_u->unknown_1 = 0x01;
6909 q_u->access_mask = 0x20;
6912 /*******************************************************************
6913 reads or writes a structure.
6914 ********************************************************************/
6916 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6917 prs_struct *ps, int depth)
6922 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6928 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6930 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6932 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6934 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6940 /*******************************************************************
6941 reads or writes a structure.
6942 ********************************************************************/
6944 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6945 prs_struct *ps, int depth)
6950 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6956 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6959 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6965 /*******************************************************************
6966 inits a SAMR_Q_GET_DOM_PWINFO structure.
6967 ********************************************************************/
6969 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6972 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6975 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
6976 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
6979 /*******************************************************************
6980 reads or writes a structure.
6981 ********************************************************************/
6983 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6984 prs_struct *ps, int depth)
6989 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6995 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6997 if (q_u->ptr != 0) {
6998 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7000 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7007 /*******************************************************************
7008 reads or writes a structure.
7009 ********************************************************************/
7011 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7012 prs_struct *ps, int depth)
7017 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7024 * see the Samba4 IDL for what these actually are.
7027 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
7031 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
7034 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7040 /*******************************************************************
7041 make a SAMR_ENC_PASSWD structure.
7042 ********************************************************************/
7044 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7052 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7056 /*******************************************************************
7057 reads or writes a SAMR_ENC_PASSWD structure.
7058 ********************************************************************/
7060 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7061 prs_struct *ps, int depth)
7066 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7072 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7075 if (pwd->ptr != 0) {
7076 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7083 /*******************************************************************
7084 inits a SAMR_ENC_HASH structure.
7085 ********************************************************************/
7087 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7095 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7099 /*******************************************************************
7100 reads or writes a SAMR_ENC_HASH structure.
7101 ********************************************************************/
7103 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7104 prs_struct *ps, int depth)
7109 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7115 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7117 if (hsh->ptr != 0) {
7118 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7125 /*******************************************************************
7126 inits a SAMR_R_GET_DOM_PWINFO structure.
7127 ********************************************************************/
7129 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7130 const char *dest_host, const char *user_name,
7131 const char nt_newpass[516],
7132 const uchar nt_oldhash[16],
7133 const char lm_newpass[516],
7134 const uchar lm_oldhash[16])
7136 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7139 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7140 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7142 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7143 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7145 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7146 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7148 q_u->unknown = 0x01;
7150 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7151 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7154 /*******************************************************************
7155 reads or writes a structure.
7156 ********************************************************************/
7158 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7159 prs_struct *ps, int depth)
7164 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7170 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7173 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7175 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7180 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7182 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7185 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7187 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7190 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7193 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7195 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7201 /*******************************************************************
7202 inits a SAMR_R_CHGPASSWD_USER structure.
7203 ********************************************************************/
7205 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7207 DEBUG(5, ("init_r_chgpasswd_user\n"));
7209 r_u->status = status;
7212 /*******************************************************************
7213 reads or writes a structure.
7214 ********************************************************************/
7216 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7217 prs_struct *ps, int depth)
7222 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7228 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7234 /*******************************************************************
7235 reads or writes a structure.
7236 ********************************************************************/
7238 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7239 POLICY_HND *domain_pol, uint16 switch_value)
7241 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7243 q_u->domain_pol = *domain_pol;
7244 q_u->switch_value = switch_value;
7247 /*******************************************************************
7248 reads or writes a structure.
7249 ********************************************************************/
7251 BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7252 prs_struct *ps, int depth)
7257 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7263 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7266 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7272 /*******************************************************************
7273 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7274 ********************************************************************/
7276 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7277 uint16 switch_value, SAM_UNK_CTR * ctr,
7280 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7283 r_u->switch_value = 0;
7284 r_u->status = status; /* return status */
7286 if (NT_STATUS_IS_OK(status)) {
7287 r_u->switch_value = switch_value;
7293 /*******************************************************************
7294 reads or writes a structure.
7295 ********************************************************************/
7297 BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u,
7298 prs_struct *ps, int depth)
7303 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7309 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7312 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7313 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7318 switch (r_u->switch_value) {
7320 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7324 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7328 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7332 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7336 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7340 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7344 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7348 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7349 r_u->switch_value));
7350 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7358 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7365 /*******************************************************************
7366 reads or writes a structure.
7367 ********************************************************************/
7369 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7370 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7372 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7374 q_u->domain_pol = *domain_pol;
7375 q_u->switch_value0 = switch_value;
7377 q_u->switch_value = switch_value;
7382 /*******************************************************************
7383 reads or writes a structure.
7384 ********************************************************************/
7386 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7387 prs_struct *ps, int depth)
7392 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7398 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7401 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7404 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7410 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7413 switch (q_u->switch_value) {
7416 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7420 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7424 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7428 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7432 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7436 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7440 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7444 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7445 q_u->switch_value));
7452 /*******************************************************************
7453 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7454 ********************************************************************/
7456 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7458 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7460 r_u->status = status; /* return status */
7463 /*******************************************************************
7464 reads or writes a structure.
7465 ********************************************************************/
7467 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7468 prs_struct *ps, int depth)
7473 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7479 if(!prs_ntstatus("status", ps, depth, &r_u->status))