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) Anthony Liguori 2002,
11 * Copyright (C) Jim McDonough 2002.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include "rpc_parse.h"
33 #define DBGC_CLASS DBGC_RPC_PARSE
35 /*******************************************************************
36 inits a SAMR_Q_CLOSE_HND structure.
37 ********************************************************************/
39 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
41 DEBUG(5, ("init_samr_q_close_hnd\n"));
46 /*******************************************************************
47 reads or writes a structure.
48 ********************************************************************/
50 BOOL samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND * q_u,
51 prs_struct *ps, int depth)
56 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
62 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
65 /*******************************************************************
66 reads or writes a structure.
67 ********************************************************************/
69 BOOL samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND * r_u,
70 prs_struct *ps, int depth)
75 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
81 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
84 if(!prs_ntstatus("status", ps, depth, &r_u->status))
90 /*******************************************************************
91 inits a SAMR_Q_LOOKUP_DOMAIN structure.
92 ********************************************************************/
94 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
95 POLICY_HND *pol, char *dom_name)
97 int len_name = strlen(dom_name);
99 DEBUG(5, ("init_samr_q_lookup_domain\n"));
101 q_u->connect_pol = *pol;
103 init_uni_hdr(&q_u->hdr_domain, len_name);
104 init_unistr2(&q_u->uni_domain, dom_name, len_name);
107 /*******************************************************************
108 reads or writes a structure.
109 ********************************************************************/
110 BOOL samr_io_q_lookup_domain(char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
111 prs_struct *ps, int depth)
116 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
122 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
125 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
128 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
134 /*******************************************************************
135 inits a SAMR_R_LOOKUP_DOMAIN structure.
136 ********************************************************************/
138 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
139 DOM_SID *dom_sid, NTSTATUS status)
141 DEBUG(5, ("init_samr_r_lookup_domain\n"));
143 r_u->status = status;
145 if (NT_STATUS_IS_OK(status)) {
147 init_dom_sid2(&r_u->dom_sid, dom_sid);
151 /*******************************************************************
152 reads or writes a structure.
153 ********************************************************************/
155 BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
156 prs_struct *ps, int depth)
161 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
167 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
170 if (r_u->ptr_sid != 0) {
171 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
177 if(!prs_ntstatus("status", ps, depth, &r_u->status))
183 /*******************************************************************
184 reads or writes a structure.
185 ********************************************************************/
187 void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
189 DEBUG(5, ("samr_init_samr_q_unknown_2d\n"));
191 q_u->dom_pol = *dom_pol;
192 init_dom_sid2(&q_u->sid, sid);
195 /*******************************************************************
196 reads or writes a structure.
197 ********************************************************************/
199 BOOL samr_io_q_unknown_2d(char *desc, SAMR_Q_UNKNOWN_2D * q_u,
200 prs_struct *ps, int depth)
205 prs_debug(ps, depth, desc, "samr_io_q_unknown_2d");
211 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
214 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
223 /*******************************************************************
224 reads or writes a structure.
225 ********************************************************************/
227 BOOL samr_io_r_unknown_2d(char *desc, SAMR_R_UNKNOWN_2D * r_u,
228 prs_struct *ps, int depth)
233 prs_debug(ps, depth, desc, "samr_io_r_unknown_2d");
239 if(!prs_ntstatus("status", ps, depth, &r_u->status))
245 /*******************************************************************
246 reads or writes a structure.
247 ********************************************************************/
249 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
250 POLICY_HND *pol, uint32 flags,
253 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
257 init_dom_sid2(&q_u->dom_sid, sid);
260 /*******************************************************************
261 reads or writes a structure.
262 ********************************************************************/
264 BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
265 prs_struct *ps, int depth)
270 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
276 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
279 if(!prs_uint32("flags", ps, depth, &q_u->flags))
282 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
288 /*******************************************************************
289 reads or writes a structure.
290 ********************************************************************/
292 BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN * r_u,
293 prs_struct *ps, int depth)
298 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
304 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
307 if(!prs_ntstatus("status", ps, depth, &r_u->status))
313 /*******************************************************************
314 reads or writes a structure.
315 ********************************************************************/
317 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
318 POLICY_HND *user_pol)
320 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
322 q_u->user_pol = *user_pol;
325 /*******************************************************************
326 reads or writes a structure.
327 ********************************************************************/
329 BOOL samr_io_q_get_usrdom_pwinfo(char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
330 prs_struct *ps, int depth)
335 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
341 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
344 /*******************************************************************
346 ********************************************************************/
348 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
350 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
352 r_u->unknown_0 = 0x0000;
356 * r_u->unknown_1 = 0x0015;
359 r_u->unknown_1 = 0x01D1;
360 r_u->unknown_1 = 0x0015;
362 r_u->unknown_2 = 0x00000000;
364 r_u->status = status;
367 /*******************************************************************
368 reads or writes a structure.
369 ********************************************************************/
371 BOOL samr_io_r_get_usrdom_pwinfo(char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
372 prs_struct *ps, int depth)
377 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
383 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
385 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
387 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
389 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
396 /*******************************************************************
397 reads or writes a structure.
398 ********************************************************************/
400 BOOL samr_io_q_set_sec_obj(char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
401 prs_struct *ps, int depth)
406 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
412 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
415 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
418 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
425 /*******************************************************************
426 reads or writes a structure.
427 ********************************************************************/
429 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
430 POLICY_HND *user_pol, uint32 sec_info)
432 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
434 q_u->user_pol = *user_pol;
435 q_u->sec_info = sec_info;
439 /*******************************************************************
440 reads or writes a structure.
441 ********************************************************************/
443 BOOL samr_io_q_query_sec_obj(char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
444 prs_struct *ps, int depth)
449 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
455 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
458 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
464 /*******************************************************************
465 reads or writes a structure.
466 ********************************************************************/
468 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
469 POLICY_HND *domain_pol, uint16 switch_value)
471 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
473 q_u->domain_pol = *domain_pol;
474 q_u->switch_value = switch_value;
477 /*******************************************************************
478 reads or writes a structure.
479 ********************************************************************/
481 BOOL samr_io_q_query_dom_info(char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
482 prs_struct *ps, int depth)
487 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
493 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
496 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
503 /*******************************************************************
505 ********************************************************************/
507 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
509 u_3->logout.low = nt_logout.low;
510 u_3->logout.high = nt_logout.high;
513 /*******************************************************************
514 reads or writes a structure.
515 ********************************************************************/
517 static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 * u_3,
518 prs_struct *ps, int depth)
523 prs_debug(ps, depth, desc, "sam_io_unk_info3");
526 if(!smb_io_time("logout", &u_3->logout, ps, depth))
532 /*******************************************************************
534 ********************************************************************/
536 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
538 u_6->unknown_0 = 0x00000000;
540 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
543 /*******************************************************************
544 reads or writes a structure.
545 ********************************************************************/
547 static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 * u_6,
548 prs_struct *ps, int depth)
553 prs_debug(ps, depth, desc, "sam_io_unk_info6");
556 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
558 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
560 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
566 /*******************************************************************
568 ********************************************************************/
570 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
572 u_7->unknown_0 = 0x0003;
575 /*******************************************************************
576 reads or writes a structure.
577 ********************************************************************/
579 static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 * u_7,
580 prs_struct *ps, int depth)
585 prs_debug(ps, depth, desc, "sam_io_unk_info7");
588 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
594 /*******************************************************************
596 ********************************************************************/
598 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
600 u_12->duration.low = nt_lock_duration.low;
601 u_12->duration.high = nt_lock_duration.high;
602 u_12->reset_count.low = nt_reset_time.low;
603 u_12->reset_count.high = nt_reset_time.high;
605 u_12->bad_attempt_lockout = lockout;
608 /*******************************************************************
609 reads or writes a structure.
610 ********************************************************************/
612 static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
613 prs_struct *ps, int depth)
618 prs_debug(ps, depth, desc, "sam_io_unk_info12");
621 if(!smb_io_time("duration", &u_12->duration, ps, depth))
623 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
625 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
631 /*******************************************************************
633 ********************************************************************/
634 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
636 int len_server = strlen(server);
638 init_uni_hdr(&u_5->hdr_server, len_server);
640 init_unistr2(&u_5->uni_server, server, len_server);
643 /*******************************************************************
644 reads or writes a structure.
645 ********************************************************************/
647 static BOOL sam_io_unk_info5(char *desc, SAM_UNK_INFO_5 * u_5,
648 prs_struct *ps, int depth)
653 prs_debug(ps, depth, desc, "sam_io_unk_info5");
656 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
659 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
665 /*******************************************************************
667 ********************************************************************/
668 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
669 const char *domain, const char *server,
670 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
672 int len_domain = strlen(domain);
673 int len_server = strlen(server);
675 u_2->unknown_0 = 0x00000000;
676 u_2->unknown_1 = 0x80000000;
677 u_2->unknown_2 = 0x00000000;
680 init_uni_hdr(&u_2->hdr_domain, len_domain);
681 init_uni_hdr(&u_2->hdr_server, len_server);
683 u_2->seq_num = seq_num;
684 u_2->unknown_3 = 0x00000000;
686 u_2->unknown_4 = 0x00000001;
687 u_2->unknown_5 = 0x00000003;
688 u_2->unknown_6 = 0x00000001;
689 u_2->num_domain_usrs = num_users;
690 u_2->num_domain_grps = num_groups;
691 u_2->num_local_grps = num_alias;
693 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
695 init_unistr2(&u_2->uni_domain, domain, len_domain);
696 init_unistr2(&u_2->uni_server, server, len_server);
699 /*******************************************************************
700 reads or writes a structure.
701 ********************************************************************/
703 static BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 * u_2,
704 prs_struct *ps, int depth)
709 prs_debug(ps, depth, desc, "sam_io_unk_info2");
712 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
714 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
716 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
719 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
721 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
723 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
726 /* put all the data in here, at the moment, including what the above
727 pointer is referring to
730 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
732 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
735 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
737 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
739 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
741 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
743 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
745 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
748 if(!prs_uint8s(False, "padding", ps, depth, u_2->padding,sizeof(u_2->padding)))
751 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
753 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
759 /*******************************************************************
761 ********************************************************************/
763 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
764 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
766 u_1->min_length_password = min_pass_len;
767 u_1->password_history = pass_hist;
770 /* password never expire */
771 u_1->expire.high = nt_expire.high;
772 u_1->expire.low = nt_expire.low;
774 /* can change the password now */
775 u_1->min_passwordage.high = nt_min_age.high;
776 u_1->min_passwordage.low = nt_min_age.low;
780 /*******************************************************************
781 reads or writes a structure.
782 ********************************************************************/
784 static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 * u_1,
785 prs_struct *ps, int depth)
790 prs_debug(ps, depth, desc, "sam_io_unk_info1");
793 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
795 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
797 if(!prs_uint32("flag", ps, depth, &u_1->flag))
799 if(!smb_io_time("expire", &u_1->expire, ps, depth))
801 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
807 /*******************************************************************
808 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
809 ********************************************************************/
811 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
812 uint16 switch_value, SAM_UNK_CTR * ctr,
815 DEBUG(5, ("init_samr_r_query_dom_info\n"));
818 r_u->switch_value = 0;
819 r_u->status = status; /* return status */
821 if (NT_STATUS_IS_OK(status)) {
822 r_u->switch_value = switch_value;
828 /*******************************************************************
829 reads or writes a structure.
830 ********************************************************************/
832 BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
833 prs_struct *ps, int depth)
838 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
844 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
847 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
848 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
853 switch (r_u->switch_value) {
855 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
859 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
863 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
867 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
871 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
875 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
879 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
883 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
885 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
893 if(!prs_ntstatus("status", ps, depth, &r_u->status))
899 /*******************************************************************
900 reads or writes a SAMR_R_SET_SEC_OBJ structure.
901 ********************************************************************/
903 BOOL samr_io_r_set_sec_obj(char *desc, SAMR_R_SET_SEC_OBJ * r_u,
904 prs_struct *ps, int depth)
909 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
921 /*******************************************************************
922 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
923 ********************************************************************/
925 BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
926 prs_struct *ps, int depth)
931 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
937 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
940 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
944 if(!prs_ntstatus("status", ps, depth, &r_u->status))
950 /*******************************************************************
951 reads or writes a SAM_STR1 structure.
952 ********************************************************************/
954 static BOOL sam_io_sam_str1(char *desc, SAM_STR1 * sam, uint32 acct_buf,
955 uint32 name_buf, uint32 desc_buf,
956 prs_struct *ps, int depth)
961 prs_debug(ps, depth, desc, "sam_io_sam_str1");
966 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
969 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
972 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
978 /*******************************************************************
979 inits a SAM_ENTRY1 structure.
980 ********************************************************************/
982 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
983 uint32 len_sam_name, uint32 len_sam_full,
984 uint32 len_sam_desc, uint32 rid_user,
987 DEBUG(5, ("init_sam_entry1\n"));
991 sam->user_idx = user_idx;
992 sam->rid_user = rid_user;
993 sam->acb_info = acb_info;
995 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
996 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
997 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
1000 /*******************************************************************
1001 reads or writes a SAM_ENTRY1 structure.
1002 ********************************************************************/
1004 static BOOL sam_io_sam_entry1(char *desc, SAM_ENTRY1 * sam,
1005 prs_struct *ps, int depth)
1010 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1016 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1019 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1021 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1027 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1029 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1031 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1037 /*******************************************************************
1038 reads or writes a SAM_STR2 structure.
1039 ********************************************************************/
1041 static BOOL sam_io_sam_str2(char *desc, SAM_STR2 * sam, uint32 acct_buf,
1042 uint32 desc_buf, prs_struct *ps, int depth)
1047 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1053 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1055 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1061 /*******************************************************************
1062 inits a SAM_ENTRY2 structure.
1063 ********************************************************************/
1064 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1065 uint32 len_sam_name, uint32 len_sam_desc,
1066 uint32 rid_user, uint16 acb_info)
1068 DEBUG(5, ("init_sam_entry2\n"));
1070 sam->user_idx = user_idx;
1071 sam->rid_user = rid_user;
1072 sam->acb_info = acb_info;
1074 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
1075 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
1078 /*******************************************************************
1079 reads or writes a SAM_ENTRY2 structure.
1080 ********************************************************************/
1082 static BOOL sam_io_sam_entry2(char *desc, SAM_ENTRY2 * sam,
1083 prs_struct *ps, int depth)
1088 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1094 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1097 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1099 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1105 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1107 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1113 /*******************************************************************
1114 reads or writes a SAM_STR3 structure.
1115 ********************************************************************/
1117 static BOOL sam_io_sam_str3(char *desc, SAM_STR3 * sam, uint32 acct_buf,
1118 uint32 desc_buf, prs_struct *ps, int depth)
1123 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1129 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1131 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1137 /*******************************************************************
1138 inits a SAM_ENTRY3 structure.
1139 ********************************************************************/
1141 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1142 uint32 len_grp_name, uint32 len_grp_desc,
1145 DEBUG(5, ("init_sam_entry3\n"));
1147 sam->grp_idx = grp_idx;
1148 sam->rid_grp = rid_grp;
1149 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1151 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1152 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1155 /*******************************************************************
1156 reads or writes a SAM_ENTRY3 structure.
1157 ********************************************************************/
1159 static BOOL sam_io_sam_entry3(char *desc, SAM_ENTRY3 * sam,
1160 prs_struct *ps, int depth)
1165 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1171 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1174 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1176 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1179 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1181 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1187 /*******************************************************************
1188 inits a SAM_ENTRY4 structure.
1189 ********************************************************************/
1191 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1192 uint32 len_acct_name)
1194 DEBUG(5, ("init_sam_entry4\n"));
1196 sam->user_idx = user_idx;
1197 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1200 /*******************************************************************
1201 reads or writes a SAM_ENTRY4 structure.
1202 ********************************************************************/
1204 static BOOL sam_io_sam_entry4(char *desc, SAM_ENTRY4 * sam,
1205 prs_struct *ps, int depth)
1210 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1216 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1218 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1224 /*******************************************************************
1225 inits a SAM_ENTRY5 structure.
1226 ********************************************************************/
1228 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1229 uint32 len_grp_name)
1231 DEBUG(5, ("init_sam_entry5\n"));
1233 sam->grp_idx = grp_idx;
1234 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1238 /*******************************************************************
1239 reads or writes a SAM_ENTRY5 structure.
1240 ********************************************************************/
1242 static BOOL sam_io_sam_entry5(char *desc, SAM_ENTRY5 * sam,
1243 prs_struct *ps, int depth)
1248 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1254 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1256 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1262 /*******************************************************************
1263 inits a SAM_ENTRY structure.
1264 ********************************************************************/
1266 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1268 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1271 init_uni_hdr(&sam->hdr_name, len_sam_name);
1274 /*******************************************************************
1275 reads or writes a SAM_ENTRY structure.
1276 ********************************************************************/
1278 static BOOL sam_io_sam_entry(char *desc, SAM_ENTRY * sam,
1279 prs_struct *ps, int depth)
1284 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1289 if(!prs_uint32("rid", ps, depth, &sam->rid))
1291 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1297 /*******************************************************************
1298 inits a SAMR_Q_ENUM_DOM_USERS structure.
1299 ********************************************************************/
1301 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1303 uint16 acb_mask, uint16 unk_1, uint32 size)
1305 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1309 q_e->start_idx = start_idx; /* zero indicates lots */
1310 q_e->acb_mask = acb_mask;
1311 q_e->unknown_1 = unk_1;
1312 q_e->max_size = size;
1315 /*******************************************************************
1316 reads or writes a structure.
1317 ********************************************************************/
1319 BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1320 prs_struct *ps, int depth)
1325 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1331 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1334 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1336 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1338 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1341 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1348 /*******************************************************************
1349 inits a SAMR_R_ENUM_DOM_USERS structure.
1350 ********************************************************************/
1352 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1353 uint32 next_idx, uint32 num_sam_entries)
1355 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1357 r_u->next_idx = next_idx;
1359 if (num_sam_entries != 0) {
1360 r_u->ptr_entries1 = 1;
1361 r_u->ptr_entries2 = 1;
1362 r_u->num_entries2 = num_sam_entries;
1363 r_u->num_entries3 = num_sam_entries;
1365 r_u->num_entries4 = num_sam_entries;
1367 r_u->ptr_entries1 = 0;
1368 r_u->num_entries2 = num_sam_entries;
1369 r_u->ptr_entries2 = 1;
1373 /*******************************************************************
1374 reads or writes a structure.
1375 ********************************************************************/
1377 BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1378 prs_struct *ps, int depth)
1385 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1391 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1393 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1396 if (r_u->ptr_entries1 != 0) {
1397 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1399 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1401 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1404 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1405 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1406 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
1409 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1410 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1411 r_u->num_entries4 = 0;
1412 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1416 for (i = 0; i < r_u->num_entries2; i++) {
1417 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1421 for (i = 0; i < r_u->num_entries2; i++) {
1422 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1431 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1433 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1439 /*******************************************************************
1440 inits a SAMR_Q_QUERY_DISPINFO structure.
1441 ********************************************************************/
1443 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1444 uint16 switch_level, uint32 start_idx,
1447 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1449 q_e->domain_pol = *pol;
1451 q_e->switch_level = switch_level;
1453 q_e->start_idx = start_idx;
1454 q_e->max_entries = max_entries;
1455 q_e->max_size = 0xffff; /* Not especially useful */
1458 /*******************************************************************
1459 reads or writes a structure.
1460 ********************************************************************/
1462 BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1463 prs_struct *ps, int depth)
1468 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1474 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1477 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1482 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1484 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1486 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1492 /*******************************************************************
1493 inits a SAM_DISPINFO_1 structure.
1494 ********************************************************************/
1496 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1497 uint32 start_idx, DISP_USER_INFO *disp_user_info,
1498 DOM_SID *domain_sid)
1500 uint32 len_sam_name, len_sam_full, len_sam_desc;
1503 SAM_ACCOUNT *pwd = NULL;
1506 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1509 return NT_STATUS_OK;
1511 sam->sam=(SAM_ENTRY1 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY1));
1513 return NT_STATUS_NO_MEMORY;
1515 sam->str=(SAM_STR1 *)talloc(ctx, num_entries*sizeof(SAM_STR1));
1517 return NT_STATUS_NO_MEMORY;
1519 ZERO_STRUCTP(sam->sam);
1520 ZERO_STRUCTP(sam->str);
1522 for (i = 0; i < num_entries ; i++) {
1523 const char *username;
1524 const char *fullname;
1525 const char *acct_desc;
1527 const DOM_SID *user_sid;
1528 fstring user_sid_string, domain_sid_string;
1530 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1532 pwd=disp_user_info[i+start_idx].sam;
1534 username = pdb_get_username(pwd);
1535 fullname = pdb_get_fullname(pwd);
1536 acct_desc = pdb_get_acct_desc(pwd);
1547 user_sid = pdb_get_user_sid(pwd);
1549 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1550 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1551 "the domain sid %s. Failing operation.\n",
1553 sid_to_string(user_sid_string, user_sid),
1554 sid_to_string(domain_sid_string, domain_sid)));
1555 return NT_STATUS_UNSUCCESSFUL;
1558 len_sam_name = strlen(username);
1559 len_sam_full = strlen(fullname);
1560 len_sam_desc = strlen(acct_desc);
1562 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1563 len_sam_name, len_sam_full, len_sam_desc,
1564 user_rid, pdb_get_acct_ctrl(pwd));
1566 ZERO_STRUCTP(&sam->str[i].uni_acct_name);
1567 ZERO_STRUCTP(&sam->str[i].uni_full_name);
1568 ZERO_STRUCTP(&sam->str[i].uni_acct_desc);
1570 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), len_sam_name);
1571 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), len_sam_full);
1572 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1575 return NT_STATUS_OK;
1578 /*******************************************************************
1579 reads or writes a structure.
1580 ********************************************************************/
1582 static BOOL sam_io_sam_dispinfo_1(char *desc, SAM_DISPINFO_1 * sam,
1584 prs_struct *ps, int depth)
1588 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1594 if (UNMARSHALLING(ps) && num_entries > 0) {
1596 if ((sam->sam = (SAM_ENTRY1 *)
1597 prs_alloc_mem(ps, sizeof(SAM_ENTRY1) *
1598 num_entries)) == NULL) {
1599 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1603 if ((sam->str = (SAM_STR1 *)
1604 prs_alloc_mem(ps, sizeof(SAM_STR1) *
1605 num_entries)) == NULL) {
1606 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1611 for (i = 0; i < num_entries; i++) {
1612 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1616 for (i = 0; i < num_entries; i++) {
1617 if(!sam_io_sam_str1("", &sam->str[i],
1618 sam->sam[i].hdr_acct_name.buffer,
1619 sam->sam[i].hdr_user_name.buffer,
1620 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1627 /*******************************************************************
1628 inits a SAM_DISPINFO_2 structure.
1629 ********************************************************************/
1631 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1632 uint32 start_idx, DISP_USER_INFO *disp_user_info,
1633 DOM_SID *domain_sid )
1635 uint32 len_sam_name, len_sam_desc;
1638 SAM_ACCOUNT *pwd = NULL;
1641 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1644 return NT_STATUS_OK;
1646 if (!(sam->sam=(SAM_ENTRY2 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY2))))
1647 return NT_STATUS_NO_MEMORY;
1649 if (!(sam->str=(SAM_STR2 *)talloc(ctx, num_entries*sizeof(SAM_STR2))))
1650 return NT_STATUS_NO_MEMORY;
1652 ZERO_STRUCTP(sam->sam);
1653 ZERO_STRUCTP(sam->str);
1655 for (i = 0; i < num_entries; i++) {
1657 const DOM_SID *user_sid;
1658 const char *username;
1659 const char *acct_desc;
1660 fstring user_sid_string, domain_sid_string;
1662 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1663 pwd=disp_user_info[i+start_idx].sam;
1665 username = pdb_get_username(pwd);
1666 acct_desc = pdb_get_acct_desc(pwd);
1667 user_sid = pdb_get_user_sid(pwd);
1669 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1670 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1671 "the domain sid %s. Failing operation.\n",
1673 sid_to_string(user_sid_string, user_sid),
1674 sid_to_string(domain_sid_string, domain_sid)));
1675 return NT_STATUS_UNSUCCESSFUL;
1678 len_sam_name = strlen(username);
1679 len_sam_desc = strlen(acct_desc);
1681 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1682 len_sam_name, len_sam_desc,
1683 user_rid, pdb_get_acct_ctrl(pwd));
1685 ZERO_STRUCTP(&sam->str[i].uni_srv_name);
1686 ZERO_STRUCTP(&sam->str[i].uni_srv_desc);
1688 init_unistr2(&sam->str[i].uni_srv_name, username, len_sam_name);
1689 init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1692 return NT_STATUS_OK;
1695 /*******************************************************************
1696 reads or writes a structure.
1697 ********************************************************************/
1699 static BOOL sam_io_sam_dispinfo_2(char *desc, SAM_DISPINFO_2 * sam,
1701 prs_struct *ps, int depth)
1708 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1714 if (UNMARSHALLING(ps) && num_entries > 0) {
1716 if ((sam->sam = (SAM_ENTRY2 *)
1717 prs_alloc_mem(ps, sizeof(SAM_ENTRY2) *
1718 num_entries)) == NULL) {
1719 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1723 if ((sam->str = (SAM_STR2 *)
1724 prs_alloc_mem(ps, sizeof(SAM_STR2) *
1725 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, DISP_GROUP_INFO *disp_group_info)
1753 uint32 len_sam_name, len_sam_desc;
1758 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1761 return NT_STATUS_OK;
1763 if (!(sam->sam=(SAM_ENTRY3 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY3))))
1764 return NT_STATUS_NO_MEMORY;
1766 if (!(sam->str=(SAM_STR3 *)talloc(ctx, num_entries*sizeof(SAM_STR3))))
1767 return NT_STATUS_NO_MEMORY;
1769 ZERO_STRUCTP(sam->sam);
1770 ZERO_STRUCTP(sam->str);
1772 for (i = 0; i < num_entries; i++) {
1773 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1775 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1777 len_sam_name = strlen(grp->name);
1778 len_sam_desc = strlen(grp->comment);
1780 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp->rid);
1782 init_unistr2(&sam->str[i].uni_grp_name, grp->name, len_sam_name);
1783 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, len_sam_desc);
1786 return NT_STATUS_OK;
1789 /*******************************************************************
1790 reads or writes a structure.
1791 ********************************************************************/
1793 static BOOL sam_io_sam_dispinfo_3(char *desc, SAM_DISPINFO_3 * sam,
1795 prs_struct *ps, int depth)
1802 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1808 if (UNMARSHALLING(ps) && num_entries > 0) {
1810 if ((sam->sam = (SAM_ENTRY3 *)
1811 prs_alloc_mem(ps, sizeof(SAM_ENTRY3) *
1812 num_entries)) == NULL) {
1813 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1817 if ((sam->str = (SAM_STR3 *)
1818 prs_alloc_mem(ps, sizeof(SAM_STR3) *
1819 num_entries)) == NULL) {
1820 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1825 for (i = 0; i < num_entries; i++) {
1826 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1830 for (i = 0; i < num_entries; i++) {
1831 if(!sam_io_sam_str3("", &sam->str[i],
1832 sam->sam[i].hdr_grp_name.buffer,
1833 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1840 /*******************************************************************
1841 inits a SAM_DISPINFO_4 structure.
1842 ********************************************************************/
1844 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1845 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1847 uint32 len_sam_name;
1850 SAM_ACCOUNT *pwd = NULL;
1853 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1856 return NT_STATUS_OK;
1858 if (!(sam->sam=(SAM_ENTRY4 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY4))))
1859 return NT_STATUS_NO_MEMORY;
1861 if (!(sam->str=(SAM_STR4 *)talloc(ctx, num_entries*sizeof(SAM_STR4))))
1862 return NT_STATUS_NO_MEMORY;
1864 ZERO_STRUCTP(sam->sam);
1865 ZERO_STRUCTP(sam->str);
1867 for (i = 0; i < num_entries; i++) {
1868 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1869 pwd=disp_user_info[i+start_idx].sam;
1871 len_sam_name = strlen(pdb_get_username(pwd));
1873 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1875 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1878 return NT_STATUS_OK;
1881 /*******************************************************************
1882 reads or writes a structure.
1883 ********************************************************************/
1885 static BOOL sam_io_sam_dispinfo_4(char *desc, SAM_DISPINFO_4 * sam,
1887 prs_struct *ps, int depth)
1894 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1900 if (UNMARSHALLING(ps) && num_entries > 0) {
1902 if ((sam->sam = (SAM_ENTRY4 *)
1903 prs_alloc_mem(ps, sizeof(SAM_ENTRY4) *
1904 num_entries)) == NULL) {
1905 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1909 if ((sam->str = (SAM_STR4 *)
1910 prs_alloc_mem(ps, sizeof(SAM_STR4) *
1911 num_entries)) == NULL) {
1912 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1917 for (i = 0; i < num_entries; i++) {
1918 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1922 for (i = 0; i < num_entries; i++) {
1923 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1924 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1931 /*******************************************************************
1932 inits a SAM_DISPINFO_5 structure.
1933 ********************************************************************/
1935 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1936 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1938 uint32 len_sam_name;
1943 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1946 return NT_STATUS_OK;
1948 if (!(sam->sam=(SAM_ENTRY5 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY5))))
1949 return NT_STATUS_NO_MEMORY;
1951 if (!(sam->str=(SAM_STR5 *)talloc(ctx, num_entries*sizeof(SAM_STR5))))
1952 return NT_STATUS_NO_MEMORY;
1954 ZERO_STRUCTP(sam->sam);
1955 ZERO_STRUCTP(sam->str);
1957 for (i = 0; i < num_entries; i++) {
1958 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1960 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1962 len_sam_name = strlen(grp->name);
1964 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1965 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1968 return NT_STATUS_OK;
1971 /*******************************************************************
1972 reads or writes a structure.
1973 ********************************************************************/
1975 static BOOL sam_io_sam_dispinfo_5(char *desc, SAM_DISPINFO_5 * sam,
1977 prs_struct *ps, int depth)
1984 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1990 if (UNMARSHALLING(ps) && num_entries > 0) {
1992 if ((sam->sam = (SAM_ENTRY5 *)
1993 prs_alloc_mem(ps, sizeof(SAM_ENTRY5) *
1994 num_entries)) == NULL) {
1995 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1999 if ((sam->str = (SAM_STR5 *)
2000 prs_alloc_mem(ps, sizeof(SAM_STR5) *
2001 num_entries)) == NULL) {
2002 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2007 for (i = 0; i < num_entries; i++) {
2008 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2012 for (i = 0; i < num_entries; i++) {
2013 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
2014 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2021 /*******************************************************************
2022 inits a SAMR_R_QUERY_DISPINFO structure.
2023 ********************************************************************/
2025 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2026 uint32 num_entries, uint32 total_size, uint32 data_size,
2027 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2030 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2032 r_u->total_size = total_size;
2034 r_u->data_size = data_size;
2036 r_u->switch_level = switch_level;
2037 r_u->num_entries = num_entries;
2040 r_u->ptr_entries = 0;
2042 r_u->ptr_entries = 1;
2044 r_u->num_entries2 = num_entries;
2047 r_u->status = status;
2050 /*******************************************************************
2051 reads or writes a structure.
2052 ********************************************************************/
2054 BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2055 prs_struct *ps, int depth)
2060 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2066 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2068 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2070 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2075 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2077 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2080 if (r_u->ptr_entries==0) {
2083 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2089 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2092 switch (r_u->switch_level) {
2094 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2095 r_u->num_entries, ps, depth))
2099 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2100 r_u->num_entries, ps, depth))
2104 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2105 r_u->num_entries, ps, depth))
2109 if(!sam_io_sam_dispinfo_4("user list",
2110 r_u->ctr->sam.info4,
2111 r_u->num_entries, ps, depth))
2115 if(!sam_io_sam_dispinfo_5("group list",
2116 r_u->ctr->sam.info5,
2117 r_u->num_entries, ps, depth))
2121 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2127 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2133 /*******************************************************************
2134 inits a SAMR_Q_OPEN_GROUP structure.
2135 ********************************************************************/
2137 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2139 uint32 access_mask, uint32 rid)
2141 DEBUG(5, ("init_samr_q_open_group\n"));
2143 q_c->domain_pol = *hnd;
2144 q_c->access_mask = access_mask;
2145 q_c->rid_group = rid;
2148 /*******************************************************************
2149 reads or writes a structure.
2150 ********************************************************************/
2152 BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
2153 prs_struct *ps, int depth)
2158 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2164 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2167 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2169 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2175 /*******************************************************************
2176 reads or writes a structure.
2177 ********************************************************************/
2179 BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
2180 prs_struct *ps, int depth)
2185 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2191 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2194 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2200 /*******************************************************************
2201 inits a GROUP_INFO1 structure.
2202 ********************************************************************/
2204 void init_samr_group_info1(GROUP_INFO1 * gr1,
2205 char *acct_name, char *acct_desc,
2208 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2209 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
2211 DEBUG(5, ("init_samr_group_info1\n"));
2213 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
2215 gr1->unknown_1 = 0x3;
2216 gr1->num_members = num_members;
2218 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
2220 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
2221 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
2224 /*******************************************************************
2225 reads or writes a structure.
2226 ********************************************************************/
2228 BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
2229 prs_struct *ps, int depth)
2234 prs_debug(ps, depth, desc, "samr_io_group_info1");
2240 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2243 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2245 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2248 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2251 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2252 gr1->hdr_acct_name.buffer, ps, depth))
2255 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2256 gr1->hdr_acct_desc.buffer, ps, depth))
2262 /*******************************************************************
2263 inits a GROUP_INFO3 structure.
2264 ********************************************************************/
2266 void init_samr_group_info3(GROUP_INFO3 *gr3)
2268 DEBUG(5, ("init_samr_group_info3\n"));
2270 gr3->unknown_1 = 0x3;
2273 /*******************************************************************
2274 reads or writes a structure.
2275 ********************************************************************/
2277 BOOL samr_io_group_info3(char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2282 prs_debug(ps, depth, desc, "samr_io_group_info3");
2288 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2294 /*******************************************************************
2295 inits a GROUP_INFO4 structure.
2296 ********************************************************************/
2298 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2300 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2302 DEBUG(5, ("init_samr_group_info4\n"));
2304 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2305 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2308 /*******************************************************************
2309 reads or writes a structure.
2310 ********************************************************************/
2312 BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
2313 prs_struct *ps, int depth)
2318 prs_debug(ps, depth, desc, "samr_io_group_info4");
2324 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2326 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2327 gr4->hdr_acct_desc.buffer, ps, depth))
2333 /*******************************************************************
2334 reads or writes a structure.
2335 ********************************************************************/
2337 static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR **ctr,
2338 prs_struct *ps, int depth)
2340 if (UNMARSHALLING(ps))
2341 *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
2346 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2349 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2352 switch ((*ctr)->switch_value1) {
2354 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2358 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2362 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2366 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2373 /*******************************************************************
2374 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2375 ********************************************************************/
2377 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2378 POLICY_HND *pol, char *acct_desc,
2381 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2383 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2387 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2388 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2390 q_e->access_mask = access_mask;
2393 /*******************************************************************
2394 reads or writes a structure.
2395 ********************************************************************/
2397 BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2398 prs_struct *ps, int depth)
2403 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2409 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2412 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2414 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2415 q_e->hdr_acct_desc.buffer, ps, depth))
2420 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2426 /*******************************************************************
2427 reads or writes a structure.
2428 ********************************************************************/
2430 BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2431 prs_struct *ps, int depth)
2436 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2442 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2445 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2447 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2453 /*******************************************************************
2454 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2455 ********************************************************************/
2457 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2460 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2462 q_c->group_pol = *hnd;
2465 /*******************************************************************
2466 reads or writes a structure.
2467 ********************************************************************/
2469 BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2470 prs_struct *ps, int depth)
2475 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2481 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2487 /*******************************************************************
2488 reads or writes a structure.
2489 ********************************************************************/
2491 BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2492 prs_struct *ps, int depth)
2497 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2503 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2506 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2512 /*******************************************************************
2513 inits a SAMR_Q_DEL_GROUPMEM structure.
2514 ********************************************************************/
2516 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2517 POLICY_HND *pol, uint32 rid)
2519 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2525 /*******************************************************************
2526 reads or writes a structure.
2527 ********************************************************************/
2529 BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2530 prs_struct *ps, int depth)
2535 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2541 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2544 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2550 /*******************************************************************
2551 inits a SAMR_R_DEL_GROUPMEM structure.
2552 ********************************************************************/
2554 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2557 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2559 r_u->status = status;
2562 /*******************************************************************
2563 reads or writes a structure.
2564 ********************************************************************/
2566 BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2567 prs_struct *ps, int depth)
2572 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2578 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2584 /*******************************************************************
2585 inits a SAMR_Q_ADD_GROUPMEM structure.
2586 ********************************************************************/
2588 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2589 POLICY_HND *pol, uint32 rid)
2591 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2595 q_e->unknown = 0x0005;
2598 /*******************************************************************
2599 reads or writes a structure.
2600 ********************************************************************/
2602 BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2603 prs_struct *ps, int depth)
2608 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2614 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2617 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2619 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2625 /*******************************************************************
2626 inits a SAMR_R_ADD_GROUPMEM structure.
2627 ********************************************************************/
2629 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2632 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2634 r_u->status = status;
2637 /*******************************************************************
2638 reads or writes a structure.
2639 ********************************************************************/
2641 BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2642 prs_struct *ps, int depth)
2647 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2653 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2659 /*******************************************************************
2660 inits a SAMR_Q_SET_GROUPINFO structure.
2661 ********************************************************************/
2663 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2664 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2666 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2672 /*******************************************************************
2673 reads or writes a structure.
2674 ********************************************************************/
2676 BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2677 prs_struct *ps, int depth)
2682 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2688 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2691 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2697 /*******************************************************************
2698 inits a SAMR_R_SET_GROUPINFO structure.
2699 ********************************************************************/
2701 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2703 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2705 r_u->status = status;
2708 /*******************************************************************
2709 reads or writes a structure.
2710 ********************************************************************/
2712 BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
2713 prs_struct *ps, int depth)
2718 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2724 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2730 /*******************************************************************
2731 inits a SAMR_Q_QUERY_GROUPINFO structure.
2732 ********************************************************************/
2734 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2735 POLICY_HND *pol, uint16 switch_level)
2737 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2741 q_e->switch_level = switch_level;
2744 /*******************************************************************
2745 reads or writes a structure.
2746 ********************************************************************/
2748 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2749 prs_struct *ps, int depth)
2754 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2760 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2763 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2769 /*******************************************************************
2770 inits a SAMR_R_QUERY_GROUPINFO structure.
2771 ********************************************************************/
2773 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2774 GROUP_INFO_CTR * ctr, NTSTATUS status)
2776 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2778 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2780 r_u->status = status;
2783 /*******************************************************************
2784 reads or writes a structure.
2785 ********************************************************************/
2787 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2788 prs_struct *ps, int depth)
2793 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2799 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2802 if (r_u->ptr != 0) {
2803 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2809 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2815 /*******************************************************************
2816 inits a SAMR_Q_QUERY_GROUPMEM structure.
2817 ********************************************************************/
2819 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2821 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2823 q_c->group_pol = *hnd;
2826 /*******************************************************************
2827 reads or writes a structure.
2828 ********************************************************************/
2830 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2831 prs_struct *ps, int depth)
2836 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2842 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2848 /*******************************************************************
2849 inits a SAMR_R_QUERY_GROUPMEM structure.
2850 ********************************************************************/
2852 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2853 uint32 num_entries, uint32 *rid,
2854 uint32 *attr, NTSTATUS status)
2856 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2858 if (NT_STATUS_IS_OK(status)) {
2860 r_u->num_entries = num_entries;
2862 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2863 r_u->ptr_rids = rid != NULL ? 1 : 0;
2865 r_u->num_rids = num_entries;
2868 r_u->num_attrs = num_entries;
2872 r_u->num_entries = 0;
2875 r_u->status = status;
2878 /*******************************************************************
2879 reads or writes a structure.
2880 ********************************************************************/
2882 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2883 prs_struct *ps, int depth)
2890 if (UNMARSHALLING(ps))
2893 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2899 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2901 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2904 if (r_u->ptr != 0) {
2905 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2907 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2910 if (r_u->ptr_rids != 0) {
2911 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2913 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2914 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2915 if (r_u->rid == NULL)
2919 for (i = 0; i < r_u->num_rids; i++) {
2920 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2925 if (r_u->ptr_attrs != 0) {
2926 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2929 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2930 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2931 if (r_u->attr == NULL)
2935 for (i = 0; i < r_u->num_attrs; i++) {
2936 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2942 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2948 /*******************************************************************
2949 inits a SAMR_Q_QUERY_USERGROUPS structure.
2950 ********************************************************************/
2952 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2955 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2960 /*******************************************************************
2961 reads or writes a structure.
2962 ********************************************************************/
2964 BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2965 prs_struct *ps, int depth)
2970 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2976 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2982 /*******************************************************************
2983 inits a SAMR_R_QUERY_USERGROUPS structure.
2984 ********************************************************************/
2986 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2987 uint32 num_gids, DOM_GID * gid,
2990 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2992 if (NT_STATUS_IS_OK(status)) {
2994 r_u->num_entries = num_gids;
2995 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2996 r_u->num_entries2 = num_gids;
3001 r_u->num_entries = 0;
3006 r_u->status = status;
3009 /*******************************************************************
3010 reads or writes a structure.
3011 ********************************************************************/
3013 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
3014 prs_struct *ps, int depth)
3020 prs_debug(ps, depth, desc, "samr_io_gids");
3026 if(!prs_uint32("num_gids", ps, depth, num_gids))
3029 if ((*num_gids) != 0) {
3030 if (UNMARSHALLING(ps)) {
3031 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
3034 if ((*gid) == NULL) {
3038 for (i = 0; i < (*num_gids); i++) {
3039 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3047 /*******************************************************************
3048 reads or writes a structure.
3049 ********************************************************************/
3051 BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3052 prs_struct *ps, int depth)
3057 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3063 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3066 if (r_u->ptr_0 != 0) {
3067 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3069 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3072 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3073 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3080 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3086 /*******************************************************************
3087 inits a SAMR_Q_ENUM_DOMAINS structure.
3088 ********************************************************************/
3090 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3092 uint32 start_idx, uint32 size)
3094 DEBUG(5, ("init_samr_q_enum_domains\n"));
3098 q_e->start_idx = start_idx;
3099 q_e->max_size = size;
3102 /*******************************************************************
3103 reads or writes a structure.
3104 ********************************************************************/
3106 BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3107 prs_struct *ps, int depth)
3112 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3118 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3121 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3123 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3129 /*******************************************************************
3130 inits a SAMR_R_ENUM_DOMAINS structure.
3131 ********************************************************************/
3133 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3134 uint32 next_idx, uint32 num_sam_entries)
3136 DEBUG(5, ("init_samr_r_enum_domains\n"));
3138 r_u->next_idx = next_idx;
3140 if (num_sam_entries != 0) {
3141 r_u->ptr_entries1 = 1;
3142 r_u->ptr_entries2 = 1;
3143 r_u->num_entries2 = num_sam_entries;
3144 r_u->num_entries3 = num_sam_entries;
3146 r_u->num_entries4 = num_sam_entries;
3148 r_u->ptr_entries1 = 0;
3149 r_u->num_entries2 = num_sam_entries;
3150 r_u->ptr_entries2 = 1;
3154 /*******************************************************************
3155 reads or writes a structure.
3156 ********************************************************************/
3158 BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3159 prs_struct *ps, int depth)
3166 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3172 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3174 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3177 if (r_u->ptr_entries1 != 0) {
3178 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3180 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3182 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3185 if (UNMARSHALLING(ps)) {
3186 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3187 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3190 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3191 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3192 r_u->num_entries4 = 0;
3193 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3197 for (i = 0; i < r_u->num_entries2; i++) {
3199 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3200 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3204 for (i = 0; i < r_u->num_entries2; i++) {
3206 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3207 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3208 r_u->sam[i].hdr_name.buffer, ps,
3217 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3219 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3225 /*******************************************************************
3226 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3227 ********************************************************************/
3229 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3231 uint32 start_idx, uint32 size)
3233 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3237 q_e->start_idx = start_idx;
3238 q_e->max_size = size;
3241 /*******************************************************************
3242 reads or writes a structure.
3243 ********************************************************************/
3245 BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3246 prs_struct *ps, int depth)
3251 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3257 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3260 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3262 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3268 /*******************************************************************
3269 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3270 ********************************************************************/
3272 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3273 uint32 next_idx, uint32 num_sam_entries)
3275 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3277 r_u->next_idx = next_idx;
3279 if (num_sam_entries != 0) {
3280 r_u->ptr_entries1 = 1;
3281 r_u->ptr_entries2 = 1;
3282 r_u->num_entries2 = num_sam_entries;
3283 r_u->num_entries3 = num_sam_entries;
3285 r_u->num_entries4 = num_sam_entries;
3287 r_u->ptr_entries1 = 0;
3288 r_u->num_entries2 = num_sam_entries;
3289 r_u->ptr_entries2 = 1;
3293 /*******************************************************************
3294 reads or writes a structure.
3295 ********************************************************************/
3297 BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3298 prs_struct *ps, int depth)
3305 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3311 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3313 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3316 if (r_u->ptr_entries1 != 0) {
3317 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3319 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3321 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3324 if (UNMARSHALLING(ps)) {
3325 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3326 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3329 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3331 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3332 r_u->num_entries4 = 0;
3333 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3337 for (i = 0; i < r_u->num_entries2; i++) {
3338 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3342 for (i = 0; i < r_u->num_entries2; i++) {
3343 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3344 r_u->sam[i].hdr_name.buffer, ps, depth))
3351 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3353 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3359 /*******************************************************************
3360 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3361 ********************************************************************/
3363 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3364 POLICY_HND *pol, uint32 start_idx,
3367 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3371 q_e->start_idx = start_idx;
3372 q_e->max_size = size;
3376 /*******************************************************************
3377 reads or writes a structure.
3378 ********************************************************************/
3380 BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3381 prs_struct *ps, int depth)
3386 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3392 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3395 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3397 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3403 /*******************************************************************
3404 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3405 ********************************************************************/
3407 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3409 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3411 r_u->next_idx = next_idx;
3413 if (num_sam_entries != 0) {
3414 r_u->ptr_entries1 = 1;
3415 r_u->ptr_entries2 = 1;
3416 r_u->num_entries2 = num_sam_entries;
3417 r_u->num_entries3 = num_sam_entries;
3419 r_u->num_entries4 = num_sam_entries;
3421 r_u->ptr_entries1 = 0;
3422 r_u->num_entries2 = num_sam_entries;
3423 r_u->ptr_entries2 = 1;
3427 /*******************************************************************
3428 reads or writes a structure.
3429 ********************************************************************/
3431 BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3432 prs_struct *ps, int depth)
3439 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3445 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3447 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3450 if (r_u->ptr_entries1 != 0) {
3451 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3453 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3455 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3458 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3459 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3460 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3463 if (r_u->num_entries2 != 0 &&
3464 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3465 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3466 r_u->num_entries4 = 0;
3467 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3471 for (i = 0; i < r_u->num_entries2; i++) {
3472 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3476 for (i = 0; i < r_u->num_entries2; i++) {
3477 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3478 r_u->sam[i].hdr_name.buffer, ps,
3486 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3488 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3494 /*******************************************************************
3495 inits a ALIAS_INFO1 structure.
3496 ********************************************************************/
3498 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3500 int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0;
3501 int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0;
3503 DEBUG(5, ("init_samr_alias_info1\n"));
3505 init_uni_hdr(&al1->hdr_acct_name, acct_len_name);
3506 init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name);
3508 al1->num_member=num_member;
3510 init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc);
3511 init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc);
3514 /*******************************************************************
3515 reads or writes a structure.
3516 ********************************************************************/
3518 BOOL samr_io_alias_info1(char *desc, ALIAS_INFO1 * al1,
3519 prs_struct *ps, int depth)
3524 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3530 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3532 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3534 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3537 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3538 al1->hdr_acct_name.buffer, ps, depth))
3544 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3545 al1->hdr_acct_desc.buffer, ps, depth))
3551 /*******************************************************************
3552 inits a ALIAS_INFO3 structure.
3553 ********************************************************************/
3555 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3557 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3559 DEBUG(5, ("init_samr_alias_info3\n"));
3561 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3562 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3565 /*******************************************************************
3566 reads or writes a structure.
3567 ********************************************************************/
3569 BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
3570 prs_struct *ps, int depth)
3575 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3581 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3583 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3584 al3->hdr_acct_desc.buffer, ps, depth))
3590 /*******************************************************************
3591 reads or writes a structure.
3592 ********************************************************************/
3594 BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
3595 prs_struct *ps, int depth)
3600 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3603 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3605 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3608 switch (ctr->switch_value1) {
3610 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3614 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3618 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3625 /*******************************************************************
3626 inits a SAMR_Q_QUERY_ALIASINFO structure.
3627 ********************************************************************/
3629 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3630 POLICY_HND *pol, uint16 switch_level)
3632 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3635 q_e->switch_level = switch_level;
3638 /*******************************************************************
3639 reads or writes a structure.
3640 ********************************************************************/
3642 BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3643 prs_struct *ps, int depth)
3648 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3654 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3657 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3663 /*******************************************************************
3664 inits a SAMR_R_QUERY_ALIASINFO structure.
3665 ********************************************************************/
3667 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3668 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3670 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3672 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3674 r_u->status = status;
3677 /*******************************************************************
3678 reads or writes a structure.
3679 ********************************************************************/
3681 BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3682 prs_struct *ps, int depth)
3687 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3693 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3696 if (r_u->ptr != 0) {
3697 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3703 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3709 /*******************************************************************
3710 inits a SAMR_Q_SET_ALIASINFO structure.
3711 ********************************************************************/
3713 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3714 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3716 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3718 q_u->alias_pol = *hnd;
3722 /*******************************************************************
3723 reads or writes a structure.
3724 ********************************************************************/
3726 BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3727 prs_struct *ps, int depth)
3732 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3738 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3740 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3746 /*******************************************************************
3747 reads or writes a structure.
3748 ********************************************************************/
3750 BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
3751 prs_struct *ps, int depth)
3756 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3761 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3767 /*******************************************************************
3768 inits a SAMR_Q_QUERY_USERALIASES structure.
3769 ********************************************************************/
3771 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3774 uint32 *ptr_sid, DOM_SID2 * sid)
3776 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3780 q_u->num_sids1 = num_sids;
3782 q_u->num_sids2 = num_sids;
3784 q_u->ptr_sid = ptr_sid;
3788 /*******************************************************************
3789 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3790 ********************************************************************/
3792 BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3793 prs_struct *ps, int depth)
3801 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3807 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3810 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3812 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3818 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3821 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3822 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3823 if (q_u->ptr_sid == NULL)
3826 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3827 if (q_u->sid == NULL)
3831 for (i = 0; i < q_u->num_sids2; i++) {
3832 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3833 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3837 for (i = 0; i < q_u->num_sids2; i++) {
3838 if (q_u->ptr_sid[i] != 0) {
3839 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3840 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3848 /*******************************************************************
3849 inits a SAMR_R_QUERY_USERALIASES structure.
3850 ********************************************************************/
3852 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3853 uint32 num_rids, uint32 *rid,
3856 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3858 if (NT_STATUS_IS_OK(status)) {
3859 r_u->num_entries = num_rids;
3861 r_u->num_entries2 = num_rids;
3865 r_u->num_entries = 0;
3867 r_u->num_entries2 = 0;
3870 r_u->status = status;
3873 /*******************************************************************
3874 reads or writes a structure.
3875 ********************************************************************/
3877 BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
3878 prs_struct *ps, int depth)
3885 prs_debug(ps, depth, desc, "samr_io_rids");
3891 if(!prs_uint32("num_rids", ps, depth, num_rids))
3894 if ((*num_rids) != 0) {
3895 if (UNMARSHALLING(ps)) {
3897 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3902 for (i = 0; i < (*num_rids); i++) {
3903 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3904 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3912 /*******************************************************************
3913 reads or writes a structure.
3914 ********************************************************************/
3916 BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3917 prs_struct *ps, int depth)
3922 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3928 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3930 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3933 if (r_u->ptr != 0) {
3934 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3940 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3946 /*******************************************************************
3947 inits a SAMR_Q_OPEN_ALIAS structure.
3948 ********************************************************************/
3950 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3951 uint32 access_mask, uint32 rid)
3953 DEBUG(5, ("init_samr_q_open_alias\n"));
3955 q_u->dom_pol = *pol;
3956 q_u->access_mask = access_mask;
3957 q_u->rid_alias = rid;
3960 /*******************************************************************
3961 reads or writes a structure.
3962 ********************************************************************/
3964 BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3965 prs_struct *ps, int depth)
3970 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3976 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3979 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3981 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3987 /*******************************************************************
3988 reads or writes a structure.
3989 ********************************************************************/
3991 BOOL samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS * r_u,
3992 prs_struct *ps, int depth)
3997 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4003 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4006 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4012 /*******************************************************************
4013 inits a SAMR_Q_LOOKUP_RIDS structure.
4014 ********************************************************************/
4016 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4017 POLICY_HND *pol, uint32 flags,
4018 uint32 num_rids, uint32 *rid)
4020 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4024 q_u->num_rids1 = num_rids;
4027 q_u->num_rids2 = num_rids;
4028 q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0]));
4029 if (q_u->rid == NULL) {
4033 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4037 /*******************************************************************
4038 reads or writes a structure.
4039 ********************************************************************/
4041 BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4042 prs_struct *ps, int depth)
4050 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4053 if (UNMARSHALLING(ps))
4059 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4062 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4064 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4066 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4068 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4071 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4072 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
4073 if (q_u->rid == NULL)
4077 for (i = 0; i < q_u->num_rids2; i++) {
4078 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4079 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4086 /*******************************************************************
4087 inits a SAMR_R_LOOKUP_RIDS structure.
4088 ********************************************************************/
4090 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4091 uint32 num_names, UNIHDR * hdr_name,
4092 UNISTR2 *uni_name, uint32 *type)
4094 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4096 r_u->hdr_name = NULL;
4097 r_u->uni_name = NULL;
4100 if (num_names != 0) {
4101 r_u->num_names1 = num_names;
4103 r_u->num_names2 = num_names;
4105 r_u->num_types1 = num_names;
4107 r_u->num_types2 = num_names;
4109 r_u->hdr_name = hdr_name;
4110 r_u->uni_name = uni_name;
4113 r_u->num_names1 = num_names;
4115 r_u->num_names2 = num_names;
4117 r_u->num_types1 = num_names;
4119 r_u->num_types2 = num_names;
4123 /*******************************************************************
4124 reads or writes a structure.
4125 ********************************************************************/
4127 BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4128 prs_struct *ps, int depth)
4135 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4141 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4143 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4146 if (r_u->ptr_names != 0) {
4148 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4152 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4153 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
4154 if (r_u->hdr_name == NULL)
4157 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
4158 if (r_u->uni_name == NULL)
4162 for (i = 0; i < r_u->num_names2; i++) {
4163 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4164 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4167 for (i = 0; i < r_u->num_names2; i++) {
4168 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4169 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4177 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4179 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4182 if (r_u->ptr_types != 0) {
4184 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4187 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4188 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
4189 if (r_u->type == NULL)
4193 for (i = 0; i < r_u->num_types2; i++) {
4194 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4195 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4200 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4206 /*******************************************************************
4207 inits a SAMR_Q_OPEN_ALIAS structure.
4208 ********************************************************************/
4210 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4212 DEBUG(5, ("init_samr_q_delete_alias\n"));
4214 q_u->alias_pol = *hnd;
4217 /*******************************************************************
4218 reads or writes a structure.
4219 ********************************************************************/
4221 BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4222 prs_struct *ps, int depth)
4227 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4233 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4239 /*******************************************************************
4240 reads or writes a structure.
4241 ********************************************************************/
4243 BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4244 prs_struct *ps, int depth)
4249 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4255 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4257 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4263 /*******************************************************************
4264 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4265 ********************************************************************/
4267 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4268 POLICY_HND *hnd, char *acct_desc)
4270 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
4272 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4274 q_u->dom_pol = *hnd;
4276 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
4277 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
4279 q_u->access_mask = 0x001f000f;
4282 /*******************************************************************
4283 reads or writes a structure.
4284 ********************************************************************/
4286 BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4287 prs_struct *ps, int depth)
4292 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4298 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4301 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4303 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4304 q_u->hdr_acct_desc.buffer, ps, depth))
4309 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4315 /*******************************************************************
4316 reads or writes a structure.
4317 ********************************************************************/
4319 BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4320 prs_struct *ps, int depth)
4325 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4331 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4334 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4337 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4343 /*******************************************************************
4344 inits a SAMR_Q_ADD_ALIASMEM structure.
4345 ********************************************************************/
4347 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4350 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4352 q_u->alias_pol = *hnd;
4353 init_dom_sid2(&q_u->sid, sid);
4356 /*******************************************************************
4357 reads or writes a structure.
4358 ********************************************************************/
4360 BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4361 prs_struct *ps, int depth)
4366 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4372 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4374 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4380 /*******************************************************************
4381 reads or writes a structure.
4382 ********************************************************************/
4384 BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4385 prs_struct *ps, int depth)
4390 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4396 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4402 /*******************************************************************
4403 inits a SAMR_Q_DEL_ALIASMEM structure.
4404 ********************************************************************/
4406 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4409 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4411 q_u->alias_pol = *hnd;
4412 init_dom_sid2(&q_u->sid, sid);
4415 /*******************************************************************
4416 reads or writes a structure.
4417 ********************************************************************/
4419 BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4420 prs_struct *ps, int depth)
4425 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4431 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4433 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4439 /*******************************************************************
4440 reads or writes a structure.
4441 ********************************************************************/
4443 BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4444 prs_struct *ps, int depth)
4449 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4455 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4461 /*******************************************************************
4462 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4463 ********************************************************************/
4465 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4468 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4470 q_c->alias_pol = *hnd;
4473 /*******************************************************************
4474 reads or writes a structure.
4475 ********************************************************************/
4477 BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4478 prs_struct *ps, int depth)
4483 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4489 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4495 /*******************************************************************
4496 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4497 ********************************************************************/
4499 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4502 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4504 r_u->status = status;
4507 /*******************************************************************
4508 reads or writes a structure.
4509 ********************************************************************/
4511 BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4512 prs_struct *ps, int depth)
4517 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4523 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4529 /*******************************************************************
4530 inits a SAMR_Q_QUERY_ALIASMEM structure.
4531 ********************************************************************/
4533 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4536 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4538 q_c->alias_pol = *hnd;
4541 /*******************************************************************
4542 reads or writes a structure.
4543 ********************************************************************/
4545 BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4546 prs_struct *ps, int depth)
4551 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4557 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4563 /*******************************************************************
4564 inits a SAMR_R_QUERY_ALIASMEM structure.
4565 ********************************************************************/
4567 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4568 uint32 num_sids, DOM_SID2 * sid,
4571 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4573 if (NT_STATUS_IS_OK(status)) {
4574 r_u->num_sids = num_sids;
4575 r_u->ptr = (num_sids != 0) ? 1 : 0;
4576 r_u->num_sids1 = num_sids;
4584 r_u->status = status;
4587 /*******************************************************************
4588 reads or writes a structure.
4589 ********************************************************************/
4591 BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4592 prs_struct *ps, int depth)
4595 uint32 ptr_sid[MAX_LOOKUP_SIDS];
4600 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4606 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4608 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4611 if (r_u->ptr != 0) {
4612 SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids);
4614 if (r_u->num_sids != 0) {
4615 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4618 for (i = 0; i < r_u->num_sids1; i++) {
4620 if(!prs_uint32("", ps, depth, &ptr_sid[i]))
4624 for (i = 0; i < r_u->num_sids1; i++) {
4625 if (ptr_sid[i] != 0) {
4626 if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth))
4635 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4641 /*******************************************************************
4642 inits a SAMR_Q_LOOKUP_NAMES structure.
4643 ********************************************************************/
4645 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4646 POLICY_HND *pol, uint32 flags,
4647 uint32 num_names, const char **name)
4651 DEBUG(5, ("init_samr_q_lookup_names\n"));
4655 q_u->num_names1 = num_names;
4658 q_u->num_names2 = num_names;
4660 if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR))))
4661 return NT_STATUS_NO_MEMORY;
4663 if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2))))
4664 return NT_STATUS_NO_MEMORY;
4666 for (i = 0; i < num_names; i++) {
4667 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4668 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4669 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4672 return NT_STATUS_OK;
4675 /*******************************************************************
4676 reads or writes a structure.
4677 ********************************************************************/
4679 BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4680 prs_struct *ps, int depth)
4687 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4690 if (UNMARSHALLING(ps))
4696 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4699 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4701 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4703 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4705 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4708 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4709 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4711 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4713 if (!q_u->hdr_name || !q_u->uni_name)
4717 for (i = 0; i < q_u->num_names2; i++) {
4718 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4722 for (i = 0; i < q_u->num_names2; i++) {
4723 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4730 /*******************************************************************
4731 inits a SAMR_R_LOOKUP_NAMES structure.
4732 ********************************************************************/
4734 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4736 uint32 *rid, uint32 *type,
4739 DEBUG(5, ("init_samr_r_lookup_names\n"));
4741 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4744 r_u->num_types1 = num_rids;
4746 r_u->num_types2 = num_rids;
4748 r_u->num_rids1 = num_rids;
4750 r_u->num_rids2 = num_rids;
4752 if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4753 return NT_STATUS_NO_MEMORY;
4754 if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4755 return NT_STATUS_NO_MEMORY;
4757 if (!r_u->rids || !r_u->types)
4760 for (i = 0; i < num_rids; i++) {
4761 r_u->rids[i] = rid[i];
4762 r_u->types[i] = type[i];
4767 r_u->num_types1 = 0;
4769 r_u->num_types2 = 0;
4779 r_u->status = status;
4781 return NT_STATUS_OK;
4784 /*******************************************************************
4785 reads or writes a structure.
4786 ********************************************************************/
4788 BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4789 prs_struct *ps, int depth)
4797 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4800 if (UNMARSHALLING(ps))
4806 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4808 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4811 if (r_u->ptr_rids != 0) {
4812 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4815 if (r_u->num_rids2 != r_u->num_rids1) {
4820 if (UNMARSHALLING(ps))
4821 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4824 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4828 for (i = 0; i < r_u->num_rids2; i++) {
4829 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4830 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4835 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4837 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4840 if (r_u->ptr_types != 0) {
4841 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4844 if (r_u->num_types2 != r_u->num_types1) {
4849 if (UNMARSHALLING(ps))
4850 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4853 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4857 for (i = 0; i < r_u->num_types2; i++) {
4858 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4859 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4864 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4870 /*******************************************************************
4871 inits a SAMR_Q_DELETE_DOM_USER structure.
4872 ********************************************************************/
4874 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4877 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4879 q_c->user_pol = *hnd;
4882 /*******************************************************************
4883 reads or writes a structure.
4884 ********************************************************************/
4886 BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4887 prs_struct *ps, int depth)
4892 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4898 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4904 /*******************************************************************
4905 reads or writes a structure.
4906 ********************************************************************/
4908 BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4909 prs_struct *ps, int depth)
4914 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4920 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4922 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4928 /*******************************************************************
4929 reads or writes a structure.
4930 ********************************************************************/
4932 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4934 uint32 access_mask, uint32 rid)
4936 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4938 q_u->domain_pol = *pol;
4939 q_u->access_mask = access_mask;
4940 q_u->user_rid = rid;
4943 /*******************************************************************
4944 reads or writes a structure.
4945 ********************************************************************/
4947 BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
4948 prs_struct *ps, int depth)
4953 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4959 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4962 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4964 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4970 /*******************************************************************
4971 reads or writes a structure.
4972 ********************************************************************/
4974 BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
4975 prs_struct *ps, int depth)
4980 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4986 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4989 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4996 /*******************************************************************
4997 reads or writes a structure.
4998 ********************************************************************/
5000 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5003 uint32 acb_info, uint32 access_mask)
5006 len_name = strlen(name);
5008 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5010 q_u->domain_pol = *pol;
5012 init_uni_hdr(&q_u->hdr_name, len_name);
5013 init_unistr2(&q_u->uni_name, name, len_name);
5015 q_u->acb_info = acb_info;
5016 q_u->access_mask = access_mask;
5019 /*******************************************************************
5020 reads or writes a structure.
5021 ********************************************************************/
5023 BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
5024 prs_struct *ps, int depth)
5029 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5035 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5038 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5040 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5045 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5047 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5053 /*******************************************************************
5054 reads or writes a structure.
5055 ********************************************************************/
5057 BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
5058 prs_struct *ps, int depth)
5063 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5069 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5072 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5074 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5076 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5082 /*******************************************************************
5083 inits a SAMR_Q_QUERY_USERINFO structure.
5084 ********************************************************************/
5086 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5087 POLICY_HND *hnd, uint16 switch_value)
5089 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5092 q_u->switch_value = switch_value;
5095 /*******************************************************************
5096 reads or writes a structure.
5097 ********************************************************************/
5099 BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5100 prs_struct *ps, int depth)
5105 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5111 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5114 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5120 /*******************************************************************
5121 reads or writes a LOGON_HRS structure.
5122 ********************************************************************/
5124 static BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs,
5125 prs_struct *ps, int depth)
5130 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5136 if(!prs_uint32("len ", ps, depth, &hrs->len))
5139 if (hrs->len > sizeof(hrs->hours)) {
5140 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5141 hrs->len = sizeof(hrs->hours);
5144 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5150 /*******************************************************************
5151 inits a SAM_USER_INFO_12 structure.
5152 ********************************************************************/
5154 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5155 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5157 DEBUG(5, ("init_sam_user_info12\n"));
5159 usr->lm_pwd_active =
5160 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5161 usr->nt_pwd_active =
5162 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5165 /*******************************************************************
5166 reads or writes a structure.
5167 ********************************************************************/
5169 static BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
5170 prs_struct *ps, int depth)
5175 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5181 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5183 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5186 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5188 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5194 /*******************************************************************
5195 inits a SAM_USER_INFO_10 structure.
5196 ********************************************************************/
5198 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5200 DEBUG(5, ("init_sam_user_info10\n"));
5202 usr->acb_info = acb_info;
5205 /*******************************************************************
5206 reads or writes a structure.
5207 ********************************************************************/
5209 static BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
5210 prs_struct *ps, int depth)
5215 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5221 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5227 /*******************************************************************
5228 inits a SAM_USER_INFO_11 structure.
5229 ********************************************************************/
5231 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5234 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5238 DEBUG(5, ("init_sam_user_info11\n"));
5240 len_mach_acct = strlen(mach_acct);
5242 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
5243 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5245 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
5246 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5248 usr->ptr_1 = 1; /* pointer */
5249 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5250 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5252 usr->ptr_2 = 1; /* pointer */
5253 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5255 usr->ptr_3 = 1; /* pointer */
5256 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5258 usr->rid_user = rid_user;
5259 usr->rid_group = rid_group;
5261 usr->acct_ctrl = acct_ctrl;
5262 usr->unknown_3 = 0x0000;
5264 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5265 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5267 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5268 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5270 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
5273 /*******************************************************************
5274 reads or writes a structure.
5275 ********************************************************************/
5277 static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
5278 prs_struct *ps, int depth)
5283 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5289 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5292 if(!smb_io_time("time", &usr->expiry, ps, depth))
5295 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5298 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5301 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5304 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5306 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5309 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5312 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5314 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5317 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5319 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5322 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5324 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5326 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5328 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5330 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5332 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5335 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5338 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5341 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5347 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5353 /*************************************************************************
5356 unknown_3 = 0x09f8 27fa
5357 unknown_5 = 0x0001 0000
5358 unknown_6 = 0x0000 04ec
5360 *************************************************************************/
5362 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5364 DEBUG(10, ("init_sam_user_info24:\n"));
5365 memcpy(usr->pass, newpass, sizeof(usr->pass));
5366 usr->pw_len = pw_len;
5369 /*******************************************************************
5370 reads or writes a structure.
5371 ********************************************************************/
5373 static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
5374 prs_struct *ps, int depth)
5379 prs_debug(ps, depth, desc, "sam_io_user_info24");
5385 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5389 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5390 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5399 /*************************************************************************
5400 init_sam_user_info23
5402 unknown_3 = 0x09f8 27fa
5403 unknown_5 = 0x0001 0000
5404 unknown_6 = 0x0000 04ec
5406 *************************************************************************/
5408 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5409 NTTIME * logoff_time, /* all zeros */
5410 NTTIME * kickoff_time, /* all zeros */
5411 NTTIME * pass_last_set_time, /* all zeros */
5412 NTTIME * pass_can_change_time, /* all zeros */
5413 NTTIME * pass_must_change_time, /* all zeros */
5424 uint32 user_rid, /* 0x0000 0000 */
5431 char newpass[516], uint32 unknown_6)
5433 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5434 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5435 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5436 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5437 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5438 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5439 int len_description = desc != NULL ? desc->uni_str_len : 0;
5440 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5441 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5442 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5444 usr->logon_time = *logon_time; /* all zeros */
5445 usr->logoff_time = *logoff_time; /* all zeros */
5446 usr->kickoff_time = *kickoff_time; /* all zeros */
5447 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5448 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5449 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5451 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5452 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5453 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5454 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5455 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5456 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5457 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5458 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5459 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5460 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5462 ZERO_STRUCT(usr->nt_pwd);
5463 ZERO_STRUCT(usr->lm_pwd);
5465 usr->user_rid = user_rid; /* 0x0000 0000 */
5466 usr->group_rid = group_rid;
5467 usr->acb_info = acb_info;
5468 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5470 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5471 usr->ptr_logon_hrs = hrs ? 1 : 0;
5473 if (nt_time_is_zero(pass_must_change_time)) {
5474 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5476 usr->passmustchange=0;
5480 ZERO_STRUCT(usr->padding1);
5481 ZERO_STRUCT(usr->padding2);
5483 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5485 memcpy(usr->pass, newpass, sizeof(usr->pass));
5487 copy_unistr2(&usr->uni_user_name, user_name);
5488 copy_unistr2(&usr->uni_full_name, full_name);
5489 copy_unistr2(&usr->uni_home_dir, home_dir);
5490 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5491 copy_unistr2(&usr->uni_logon_script, log_scr);
5492 copy_unistr2(&usr->uni_profile_path, prof_path);
5493 copy_unistr2(&usr->uni_acct_desc, desc);
5494 copy_unistr2(&usr->uni_workstations, wkstas);
5495 copy_unistr2(&usr->uni_unknown_str, unk_str);
5496 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5498 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5501 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5504 /*************************************************************************
5505 init_sam_user_info23
5507 unknown_3 = 0x09f8 27fa
5508 unknown_5 = 0x0001 0000
5509 unknown_6 = 0x0000 04ec
5511 *************************************************************************/
5513 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5514 NTTIME * logoff_time, /* all zeros */
5515 NTTIME * kickoff_time, /* all zeros */
5516 NTTIME * pass_last_set_time, /* all zeros */
5517 NTTIME * pass_can_change_time, /* all zeros */
5518 NTTIME * pass_must_change_time, /* all zeros */
5519 char *user_name, /* NULL */
5521 char *home_dir, char *dir_drive, char *log_scr,
5522 char *prof_path, char *desc, char *wkstas,
5523 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5524 uint32 group_rid, uint32 acb_info,
5525 uint32 unknown_3, uint16 logon_divs,
5526 LOGON_HRS * hrs, uint32 unknown_5,
5527 char newpass[516], uint32 unknown_6)
5529 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5530 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5531 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5532 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5533 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5534 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5535 int len_description = desc != NULL ? strlen(desc) : 0;
5536 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5537 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5538 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5540 usr->logon_time = *logon_time; /* all zeros */
5541 usr->logoff_time = *logoff_time; /* all zeros */
5542 usr->kickoff_time = *kickoff_time; /* all zeros */
5543 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5544 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5545 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5547 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5548 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5549 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5550 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5551 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5552 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5553 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5554 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5555 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5556 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5558 ZERO_STRUCT(usr->nt_pwd);
5559 ZERO_STRUCT(usr->lm_pwd);
5561 usr->user_rid = user_rid; /* 0x0000 0000 */
5562 usr->group_rid = group_rid;
5563 usr->acb_info = acb_info;
5564 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5566 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5567 usr->ptr_logon_hrs = hrs ? 1 : 0;
5569 if (nt_time_is_zero(pass_must_change_time)) {
5570 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5572 usr->passmustchange=0;
5575 ZERO_STRUCT(usr->padding1);
5576 ZERO_STRUCT(usr->padding2);
5578 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5580 memcpy(usr->pass, newpass, sizeof(usr->pass));
5582 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5583 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5584 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5585 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5586 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5587 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5588 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5589 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5590 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5591 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5593 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5596 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5599 /*******************************************************************
5600 reads or writes a structure.
5601 ********************************************************************/
5603 static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
5604 prs_struct *ps, int depth)
5609 prs_debug(ps, depth, desc, "sam_io_user_info23");
5615 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5617 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5619 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5621 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5623 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5625 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5628 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5630 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5632 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5634 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5636 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5638 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5640 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5642 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5644 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5646 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5649 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5651 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5654 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5656 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5658 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5661 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5663 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5667 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5670 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5673 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5675 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5677 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5681 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5684 /* here begins pointed-to data */
5686 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5689 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5692 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5695 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5698 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5701 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5704 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5707 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5710 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5713 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5716 /* ok, this is only guess-work (as usual) */
5717 if (usr->ptr_logon_hrs) {
5718 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5720 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5722 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5724 } else if (UNMARSHALLING(ps)) {
5732 /*******************************************************************
5733 reads or writes a structure.
5734 NB. This structure is *definately* incorrect. It's my best guess
5735 currently for W2K SP2. The password field is encrypted in a different
5736 way than normal... And there are definately other problems. JRA.
5737 ********************************************************************/
5739 static BOOL sam_io_user_info25(char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5744 prs_debug(ps, depth, desc, "sam_io_user_info25");
5750 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5752 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5754 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5756 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5758 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5760 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5763 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5765 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5767 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5769 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5771 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5773 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5775 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5777 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5779 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5781 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5784 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5786 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5789 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5791 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5793 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5796 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5799 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5802 /* here begins pointed-to data */
5804 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5807 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5810 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5813 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5816 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5819 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5822 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5825 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5828 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5831 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5834 #if 0 /* JRA - unknown... */
5835 /* ok, this is only guess-work (as usual) */
5836 if (usr->ptr_logon_hrs) {
5837 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5839 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5841 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5843 } else if (UNMARSHALLING(ps)) {
5853 /*************************************************************************
5854 init_sam_user_info21W
5856 unknown_3 = 0x00ff ffff
5857 unknown_5 = 0x0002 0000
5858 unknown_6 = 0x0000 04ec
5860 *************************************************************************/
5862 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5863 NTTIME * logon_time,
5864 NTTIME * logoff_time,
5865 NTTIME * kickoff_time,
5866 NTTIME * pass_last_set_time,
5867 NTTIME * pass_can_change_time,
5868 NTTIME * pass_must_change_time,
5887 uint32 unknown_5, uint32 unknown_6)
5889 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5890 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5891 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5892 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5893 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5894 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5895 int len_description = desc != NULL ? desc->uni_str_len : 0;
5896 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5897 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5898 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5900 usr->logon_time = *logon_time;
5901 usr->logoff_time = *logoff_time;
5902 usr->kickoff_time = *kickoff_time;
5903 usr->pass_last_set_time = *pass_last_set_time;
5904 usr->pass_can_change_time = *pass_can_change_time;
5905 usr->pass_must_change_time = *pass_must_change_time;
5907 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5908 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5909 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5910 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5911 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5912 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5913 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5914 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5915 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5916 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5918 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5919 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5921 usr->user_rid = user_rid;
5922 usr->group_rid = group_rid;
5923 usr->acb_info = acb_info;
5924 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5926 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5927 usr->ptr_logon_hrs = hrs ? 1 : 0;
5928 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5930 if (nt_time_is_zero(pass_must_change_time)) {
5931 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5933 usr->passmustchange=0;
5937 ZERO_STRUCT(usr->padding1);
5938 ZERO_STRUCT(usr->padding2);
5940 copy_unistr2(&usr->uni_user_name, user_name);
5941 copy_unistr2(&usr->uni_full_name, full_name);
5942 copy_unistr2(&usr->uni_home_dir, home_dir);
5943 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5944 copy_unistr2(&usr->uni_logon_script, log_scr);
5945 copy_unistr2(&usr->uni_profile_path, prof_path);
5946 copy_unistr2(&usr->uni_acct_desc, desc);
5947 copy_unistr2(&usr->uni_workstations, wkstas);
5948 copy_unistr2(&usr->uni_unknown_str, unk_str);
5949 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5951 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5954 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5957 /*************************************************************************
5958 init_sam_user_info21
5960 unknown_3 = 0x00ff ffff
5961 unknown_5 = 0x0002 0000
5962 unknown_6 = 0x0000 04ec
5964 *************************************************************************/
5966 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5968 NTTIME logon_time, logoff_time, kickoff_time,
5969 pass_last_set_time, pass_can_change_time,
5970 pass_must_change_time;
5972 int len_user_name, len_full_name, len_home_dir,
5973 len_dir_drive, len_logon_script, len_profile_path,
5974 len_description, len_workstations, len_unknown_str,
5977 const char* user_name = pdb_get_username(pw);
5978 const char* full_name = pdb_get_fullname(pw);
5979 const char* home_dir = pdb_get_homedir(pw);
5980 const char* dir_drive = pdb_get_dir_drive(pw);
5981 const char* logon_script = pdb_get_logon_script(pw);
5982 const char* profile_path = pdb_get_profile_path(pw);
5983 const char* description = pdb_get_acct_desc(pw);
5984 const char* workstations = pdb_get_workstations(pw);
5985 const char* munged_dial = pdb_get_munged_dial(pw);
5988 const DOM_SID *user_sid;
5991 const DOM_SID *group_sid;
5993 len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
5994 len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
5995 len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
5996 len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
5997 len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
5998 len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
5999 len_description = description != NULL ? strlen(description )+1 : 0;
6000 len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
6001 len_unknown_str = 0;
6002 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6005 /* Create NTTIME structs */
6006 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6007 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6008 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6009 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6010 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6011 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6013 /* structure assignment */
6014 usr->logon_time = logon_time;
6015 usr->logoff_time = logoff_time;
6016 usr->kickoff_time = kickoff_time;
6017 usr->pass_last_set_time = pass_last_set_time;
6018 usr->pass_can_change_time = pass_can_change_time;
6019 usr->pass_must_change_time = pass_must_change_time;
6021 init_uni_hdr(&usr->hdr_user_name, len_user_name);
6022 init_uni_hdr(&usr->hdr_full_name, len_full_name);
6023 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
6024 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
6025 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
6026 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
6027 init_uni_hdr(&usr->hdr_acct_desc, len_description);
6028 init_uni_hdr(&usr->hdr_workstations, len_workstations);
6029 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
6030 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6032 ZERO_STRUCT(usr->nt_pwd);
6033 ZERO_STRUCT(usr->lm_pwd);
6035 user_sid = pdb_get_user_sid(pw);
6037 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6038 fstring user_sid_string;
6039 fstring domain_sid_string;
6040 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6041 "the domain sid %s. Failing operation.\n",
6043 sid_to_string(user_sid_string, user_sid),
6044 sid_to_string(domain_sid_string, domain_sid)));
6045 return NT_STATUS_UNSUCCESSFUL;
6048 group_sid = pdb_get_group_sid(pw);
6050 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6051 fstring group_sid_string;
6052 fstring domain_sid_string;
6053 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6054 "which conflicts with the domain sid %s. Failing operation.\n",
6056 sid_to_string(group_sid_string, group_sid),
6057 sid_to_string(domain_sid_string, domain_sid)));
6058 return NT_STATUS_UNSUCCESSFUL;
6061 usr->user_rid = user_rid;
6062 usr->group_rid = group_rid;
6063 usr->acb_info = pdb_get_acct_ctrl(pw);
6066 Look at a user on a real NT4 PDC with usrmgr, press
6067 'ok'. Then you will see that unknown_3 is set to
6068 0x08f827fa. Look at the user immediately after that again,
6069 and you will see that 0x00fffff is returned. This solves
6070 the problem that you get access denied after having looked
6074 usr->unknown_3 = 0x00ffffff;
6076 usr->logon_divs = pdb_get_logon_divs(pw);
6077 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6078 usr->unknown_5 = pdb_get_unknown_5(pw); /* 0x0002 0000 */
6080 if (pdb_get_pass_must_change_time(pw) == 0) {
6081 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6083 usr->passmustchange=0;
6087 ZERO_STRUCT(usr->padding1);
6088 ZERO_STRUCT(usr->padding2);
6090 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
6091 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
6092 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
6093 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
6094 init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
6095 init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
6096 init_unistr2(&usr->uni_acct_desc, description, len_description);
6097 init_unistr2(&usr->uni_workstations, workstations, len_workstations);
6098 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
6099 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6101 usr->unknown_6 = pdb_get_unknown_6(pw);
6104 if (pdb_get_hours(pw)) {
6105 usr->logon_hrs.len = pdb_get_hours_len(pw);
6106 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6108 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6110 return NT_STATUS_OK;
6113 /*******************************************************************
6114 reads or writes a structure.
6115 ********************************************************************/
6117 static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
6118 prs_struct *ps, int depth)
6123 prs_debug(ps, depth, desc, "sam_io_user_info21");
6129 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6131 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6133 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6135 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6137 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6139 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6142 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6144 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6146 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6148 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6150 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6152 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6154 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6156 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6158 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6160 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6163 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6165 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6168 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6170 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6172 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6175 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
6177 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6181 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6184 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
6187 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6189 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6191 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6194 /* here begins pointed-to data */
6196 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6198 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6200 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6202 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6204 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6206 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6208 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6210 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6212 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6214 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6217 /* ok, this is only guess-work (as usual) */
6218 if (usr->ptr_logon_hrs) {
6221 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6223 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6225 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6227 } else if (UNMARSHALLING(ps)) {
6235 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6237 int len_munged_dial;
6238 const char* munged_dial = pdb_get_munged_dial(pw);
6240 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6241 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6242 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6246 /*******************************************************************
6247 reads or writes a structure.
6248 ********************************************************************/
6250 static BOOL sam_io_user_info20(char *desc, SAM_USER_INFO_20 *usr,
6251 prs_struct *ps, int depth)
6256 prs_debug(ps, depth, desc, "sam_io_user_info20");
6262 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6265 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6271 /*******************************************************************
6272 inits a SAM_USERINFO_CTR structure.
6273 ********************************************************************/
6275 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6276 uint16 switch_value,
6277 SAM_USER_INFO_21 * usr)
6279 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6281 ctr->switch_value = switch_value;
6282 ctr->info.id = NULL;
6284 switch (switch_value) {
6286 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
6287 if (ctr->info.id10 == NULL)
6288 return NT_STATUS_NO_MEMORY;
6290 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6293 /* whoops - got this wrong. i think. or don't understand what's happening. */
6297 info = (void *)&id11;
6299 expire.low = 0xffffffff;
6300 expire.high = 0x7fffffff;
6302 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
6303 init_sam_user_info11(ctr->info.id11, &expire,
6304 "BROOKFIELDS$", /* name */
6305 0x03ef, /* user rid */
6306 0x201, /* group rid */
6307 0x0080); /* acb info */
6313 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
6314 if (ctr->info.id12 == NULL)
6315 return NT_STATUS_NO_MEMORY;
6317 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6321 SAM_USER_INFO_21 *cusr;
6322 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
6323 ctr->info.id21 = cusr;
6324 if (ctr->info.id21 == NULL)
6325 return NT_STATUS_NO_MEMORY;
6326 memcpy(cusr, usr, sizeof(*usr));
6327 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6328 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6332 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6333 return NT_STATUS_INVALID_INFO_CLASS;
6336 return NT_STATUS_OK;
6339 /*******************************************************************
6340 inits a SAM_USERINFO_CTR structure.
6341 ********************************************************************/
6343 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
6344 uint16 switch_value, void *info)
6346 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6348 ctr->switch_value = switch_value;
6349 ctr->info.id = info;
6351 switch (switch_value) {
6353 SamOEMhash(ctr->info.id24->pass, sess_key, 516);
6354 dump_data(100, (char *)sess_key, 16);
6355 dump_data(100, (char *)ctr->info.id24->pass, 516);
6358 SamOEMhash(ctr->info.id23->pass, sess_key, 516);
6359 dump_data(100, (char *)sess_key, 16);
6360 dump_data(100, (char *)ctr->info.id23->pass, 516);
6363 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6367 /*******************************************************************
6368 reads or writes a structure.
6369 ********************************************************************/
6371 static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR **ppctr,
6372 prs_struct *ps, int depth)
6375 SAM_USERINFO_CTR *ctr;
6377 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6380 if (UNMARSHALLING(ps)) {
6381 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
6389 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6391 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6398 switch (ctr->switch_value) {
6400 if (UNMARSHALLING(ps))
6401 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
6402 if (ctr->info.id10 == NULL) {
6403 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6406 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6409 if (UNMARSHALLING(ps))
6410 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
6412 if (ctr->info.id11 == NULL) {
6413 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6416 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6419 if (UNMARSHALLING(ps))
6420 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
6422 if (ctr->info.id12 == NULL) {
6423 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6426 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6429 if (UNMARSHALLING(ps))
6430 ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20));
6432 if (ctr->info.id20 == NULL) {
6433 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6436 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6439 if (UNMARSHALLING(ps))
6440 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
6442 if (ctr->info.id21 == NULL) {
6443 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6446 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6449 if (UNMARSHALLING(ps))
6450 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
6452 if (ctr->info.id23 == NULL) {
6453 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6456 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6459 if (UNMARSHALLING(ps))
6460 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
6462 if (ctr->info.id24 == NULL) {
6463 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6466 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6469 if (UNMARSHALLING(ps))
6470 ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25));
6472 if (ctr->info.id25 == NULL) {
6473 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6476 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6479 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6487 /*******************************************************************
6488 inits a SAMR_R_QUERY_USERINFO structure.
6489 ********************************************************************/
6491 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6492 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6494 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6499 if (NT_STATUS_IS_OK(status)) {
6504 r_u->status = status; /* return status */
6507 /*******************************************************************
6508 reads or writes a structure.
6509 ********************************************************************/
6511 BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
6512 prs_struct *ps, int depth)
6517 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6523 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6526 if (r_u->ptr != 0) {
6527 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6533 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6539 /*******************************************************************
6540 inits a SAMR_Q_SET_USERINFO structure.
6541 ********************************************************************/
6543 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6544 POLICY_HND *hnd, unsigned char sess_key[16],
6545 uint16 switch_value, void *info)
6547 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6550 q_u->switch_value = switch_value;
6551 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6554 /*******************************************************************
6555 reads or writes a structure.
6556 ********************************************************************/
6558 BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
6559 prs_struct *ps, int depth)
6564 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6570 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6572 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6574 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6580 /*******************************************************************
6581 inits a SAMR_R_SET_USERINFO structure.
6582 ********************************************************************/
6584 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6586 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6588 r_u->status = status; /* return status */
6591 /*******************************************************************
6592 reads or writes a structure.
6593 ********************************************************************/
6595 BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
6596 prs_struct *ps, int depth)
6601 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6607 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6613 /*******************************************************************
6614 inits a SAMR_Q_SET_USERINFO2 structure.
6615 ********************************************************************/
6617 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6618 POLICY_HND *hnd, unsigned char sess_key[16],
6619 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6621 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6624 q_u->switch_value = switch_value;
6627 if (q_u->ctr != NULL)
6628 q_u->ctr->switch_value = switch_value;
6630 switch (switch_value) {
6632 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16);
6633 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16);
6634 dump_data(100, (char *)sess_key, 16);
6635 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6636 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6641 /*******************************************************************
6642 reads or writes a structure.
6643 ********************************************************************/
6645 BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6646 prs_struct *ps, int depth)
6651 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6657 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6660 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6662 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6668 /*******************************************************************
6669 inits a SAMR_R_SET_USERINFO2 structure.
6670 ********************************************************************/
6672 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6674 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6676 r_u->status = status; /* return status */
6679 /*******************************************************************
6680 reads or writes a structure.
6681 ********************************************************************/
6683 BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
6684 prs_struct *ps, int depth)
6689 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6695 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6701 /*******************************************************************
6702 inits a SAMR_Q_CONNECT structure.
6703 ********************************************************************/
6705 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6706 char *srv_name, uint32 access_mask)
6708 int len_srv_name = strlen(srv_name);
6710 DEBUG(5, ("init_samr_q_connect\n"));
6712 /* make PDC server name \\server */
6713 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6714 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6716 /* example values: 0x0000 0002 */
6717 q_u->access_mask = access_mask;
6720 /*******************************************************************
6721 reads or writes a structure.
6722 ********************************************************************/
6724 BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
6725 prs_struct *ps, int depth)
6730 prs_debug(ps, depth, desc, "samr_io_q_connect");
6736 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6738 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6743 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6749 /*******************************************************************
6750 reads or writes a structure.
6751 ********************************************************************/
6753 BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
6754 prs_struct *ps, int depth)
6759 prs_debug(ps, depth, desc, "samr_io_r_connect");
6765 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6768 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6774 /*******************************************************************
6775 inits a SAMR_Q_CONNECT4 structure.
6776 ********************************************************************/
6778 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6779 char *srv_name, uint32 access_mask)
6781 int len_srv_name = strlen(srv_name);
6783 DEBUG(5, ("init_samr_q_connect\n"));
6785 /* make PDC server name \\server */
6786 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6787 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6789 /* Only value we've seen, possibly an address type ? */
6792 /* example values: 0x0000 0002 */
6793 q_u->access_mask = access_mask;
6796 /*******************************************************************
6797 reads or writes a structure.
6798 ********************************************************************/
6800 BOOL samr_io_q_connect4(char *desc, SAMR_Q_CONNECT4 * q_u,
6801 prs_struct *ps, int depth)
6806 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6812 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6814 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6819 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6821 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6827 /*******************************************************************
6828 reads or writes a structure.
6829 ********************************************************************/
6831 BOOL samr_io_r_connect4(char *desc, SAMR_R_CONNECT4 * r_u,
6832 prs_struct *ps, int depth)
6837 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6843 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6846 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6852 /*******************************************************************
6853 inits a SAMR_Q_CONNECT_ANON structure.
6854 ********************************************************************/
6856 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6858 DEBUG(5, ("init_samr_q_connect_anon\n"));
6861 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6862 q_u->unknown_1 = 0x01;
6863 q_u->access_mask = 0x20;
6866 /*******************************************************************
6867 reads or writes a structure.
6868 ********************************************************************/
6870 BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
6871 prs_struct *ps, int depth)
6876 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6882 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6884 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6886 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6888 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6894 /*******************************************************************
6895 reads or writes a structure.
6896 ********************************************************************/
6898 BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
6899 prs_struct *ps, int depth)
6904 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6910 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6913 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6919 /*******************************************************************
6920 inits a SAMR_Q_GET_DOM_PWINFO structure.
6921 ********************************************************************/
6923 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6926 int len_srv_name = strlen(srv_name);
6928 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6931 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6932 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6935 /*******************************************************************
6936 reads or writes a structure.
6937 ********************************************************************/
6939 BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6940 prs_struct *ps, int depth)
6945 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6951 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6953 if (q_u->ptr != 0) {
6954 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6956 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6963 /*******************************************************************
6964 reads or writes a structure.
6965 ********************************************************************/
6967 BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6968 prs_struct *ps, int depth)
6973 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6980 * We need 16 bytes here according to tests. Don't know
6981 * what they are, but the length is important for the singing
6984 if(!prs_uint32("unk_0", ps, depth, &r_u->unk_0))
6986 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
6988 if(!prs_uint32("unk_2", ps, depth, &r_u->unk_2))
6991 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6997 /*******************************************************************
6998 make a SAMR_ENC_PASSWD structure.
6999 ********************************************************************/
7001 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
7009 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7013 /*******************************************************************
7014 reads or writes a SAMR_ENC_PASSWD structure.
7015 ********************************************************************/
7017 BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
7018 prs_struct *ps, int depth)
7023 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7029 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7032 if (pwd->ptr != 0) {
7033 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7040 /*******************************************************************
7041 inits a SAMR_ENC_HASH structure.
7042 ********************************************************************/
7044 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
7052 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7056 /*******************************************************************
7057 reads or writes a SAMR_ENC_HASH structure.
7058 ********************************************************************/
7060 BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
7061 prs_struct *ps, int depth)
7066 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7072 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7074 if (hsh->ptr != 0) {
7075 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7082 /*******************************************************************
7083 inits a SAMR_R_GET_DOM_PWINFO structure.
7084 ********************************************************************/
7086 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7087 char *dest_host, char *user_name,
7088 char nt_newpass[516],
7089 uchar nt_oldhash[16],
7090 char lm_newpass[516],
7091 uchar lm_oldhash[16])
7093 int len_dest_host = strlen(dest_host);
7094 int len_user_name = strlen(user_name);
7096 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7099 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
7100 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
7101 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
7102 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
7104 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7105 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7107 q_u->unknown = 0x01;
7109 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7110 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7113 /*******************************************************************
7114 reads or writes a structure.
7115 ********************************************************************/
7117 BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7118 prs_struct *ps, int depth)
7123 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7129 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7132 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7134 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7139 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7141 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7144 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7146 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7149 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7152 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7154 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7160 /*******************************************************************
7161 inits a SAMR_R_CHGPASSWD_USER structure.
7162 ********************************************************************/
7164 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7166 DEBUG(5, ("init_r_chgpasswd_user\n"));
7168 r_u->status = status;
7171 /*******************************************************************
7172 reads or writes a structure.
7173 ********************************************************************/
7175 BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7176 prs_struct *ps, int depth)
7181 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7187 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7193 /*******************************************************************
7194 reads or writes a structure.
7195 ********************************************************************/
7197 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7198 POLICY_HND *domain_pol, uint16 switch_value)
7200 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7202 q_u->domain_pol = *domain_pol;
7203 q_u->switch_value = switch_value;
7206 /*******************************************************************
7207 reads or writes a structure.
7208 ********************************************************************/
7210 BOOL samr_io_q_unknown_2e(char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7211 prs_struct *ps, int depth)
7216 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7222 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7225 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7231 /*******************************************************************
7232 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7233 ********************************************************************/
7235 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7236 uint16 switch_value, SAM_UNK_CTR * ctr,
7239 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7242 r_u->switch_value = 0;
7243 r_u->status = status; /* return status */
7245 if (NT_STATUS_IS_OK(status)) {
7246 r_u->switch_value = switch_value;
7252 /*******************************************************************
7253 reads or writes a structure.
7254 ********************************************************************/
7256 BOOL samr_io_r_samr_unknown_2e(char *desc, SAMR_R_UNKNOWN_2E * r_u,
7257 prs_struct *ps, int depth)
7262 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7268 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7271 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7272 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7277 switch (r_u->switch_value) {
7279 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7283 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7287 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7291 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7295 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7299 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7303 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7307 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7308 r_u->switch_value));
7309 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7317 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7324 /*******************************************************************
7325 reads or writes a structure.
7326 ********************************************************************/
7328 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7329 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7331 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7333 q_u->domain_pol = *domain_pol;
7334 q_u->switch_value0 = switch_value;
7336 q_u->switch_value = switch_value;
7341 /*******************************************************************
7342 reads or writes a structure.
7343 ********************************************************************/
7345 BOOL samr_io_q_set_domain_info(char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7346 prs_struct *ps, int depth)
7351 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7357 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7360 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7363 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7369 if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL)
7372 switch (q_u->switch_value) {
7375 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7379 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7383 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7387 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7391 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7395 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7399 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7403 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7404 q_u->switch_value));
7411 /*******************************************************************
7412 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7413 ********************************************************************/
7415 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7417 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7419 r_u->status = status; /* return status */
7422 /*******************************************************************
7423 reads or writes a structure.
7424 ********************************************************************/
7426 BOOL samr_io_r_set_domain_info(char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7427 prs_struct *ps, int depth)
7432 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7438 if(!prs_ntstatus("status", ps, depth, &r_u->status))