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))
749 /* this was originally marked as 'padding'. It isn't
750 padding, it is some sort of optional 12 byte
751 structure. When it is present it contains zeros
753 if(!prs_uint8s(False, "unknown", ps, depth, u_2->padding,sizeof(u_2->padding)))
757 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
759 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
765 /*******************************************************************
767 ********************************************************************/
769 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
770 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
772 u_1->min_length_password = min_pass_len;
773 u_1->password_history = pass_hist;
776 /* password never expire */
777 u_1->expire.high = nt_expire.high;
778 u_1->expire.low = nt_expire.low;
780 /* can change the password now */
781 u_1->min_passwordage.high = nt_min_age.high;
782 u_1->min_passwordage.low = nt_min_age.low;
786 /*******************************************************************
787 reads or writes a structure.
788 ********************************************************************/
790 static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 * u_1,
791 prs_struct *ps, int depth)
796 prs_debug(ps, depth, desc, "sam_io_unk_info1");
799 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
801 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
803 if(!prs_uint32("flag", ps, depth, &u_1->flag))
805 if(!smb_io_time("expire", &u_1->expire, ps, depth))
807 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
813 /*******************************************************************
814 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
815 ********************************************************************/
817 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
818 uint16 switch_value, SAM_UNK_CTR * ctr,
821 DEBUG(5, ("init_samr_r_query_dom_info\n"));
824 r_u->switch_value = 0;
825 r_u->status = status; /* return status */
827 if (NT_STATUS_IS_OK(status)) {
828 r_u->switch_value = switch_value;
834 /*******************************************************************
835 reads or writes a structure.
836 ********************************************************************/
838 BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
839 prs_struct *ps, int depth)
844 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
850 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
853 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
854 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
859 switch (r_u->switch_value) {
861 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
865 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
869 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
873 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
877 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
881 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
885 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
889 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
891 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
899 if(!prs_ntstatus("status", ps, depth, &r_u->status))
905 /*******************************************************************
906 reads or writes a SAMR_R_SET_SEC_OBJ structure.
907 ********************************************************************/
909 BOOL samr_io_r_set_sec_obj(char *desc, SAMR_R_SET_SEC_OBJ * r_u,
910 prs_struct *ps, int depth)
915 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
921 if(!prs_ntstatus("status", ps, depth, &r_u->status))
927 /*******************************************************************
928 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
929 ********************************************************************/
931 BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
932 prs_struct *ps, int depth)
937 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
943 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
946 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
950 if(!prs_ntstatus("status", ps, depth, &r_u->status))
956 /*******************************************************************
957 reads or writes a SAM_STR1 structure.
958 ********************************************************************/
960 static BOOL sam_io_sam_str1(char *desc, SAM_STR1 * sam, uint32 acct_buf,
961 uint32 name_buf, uint32 desc_buf,
962 prs_struct *ps, int depth)
967 prs_debug(ps, depth, desc, "sam_io_sam_str1");
972 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
975 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
978 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
984 /*******************************************************************
985 inits a SAM_ENTRY1 structure.
986 ********************************************************************/
988 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
989 uint32 len_sam_name, uint32 len_sam_full,
990 uint32 len_sam_desc, uint32 rid_user,
993 DEBUG(5, ("init_sam_entry1\n"));
997 sam->user_idx = user_idx;
998 sam->rid_user = rid_user;
999 sam->acb_info = acb_info;
1001 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
1002 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
1003 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
1006 /*******************************************************************
1007 reads or writes a SAM_ENTRY1 structure.
1008 ********************************************************************/
1010 static BOOL sam_io_sam_entry1(char *desc, SAM_ENTRY1 * sam,
1011 prs_struct *ps, int depth)
1016 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1022 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1025 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1027 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1033 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1035 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1037 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1043 /*******************************************************************
1044 reads or writes a SAM_STR2 structure.
1045 ********************************************************************/
1047 static BOOL sam_io_sam_str2(char *desc, SAM_STR2 * sam, uint32 acct_buf,
1048 uint32 desc_buf, prs_struct *ps, int depth)
1053 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1059 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1061 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1067 /*******************************************************************
1068 inits a SAM_ENTRY2 structure.
1069 ********************************************************************/
1070 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1071 uint32 len_sam_name, uint32 len_sam_desc,
1072 uint32 rid_user, uint16 acb_info)
1074 DEBUG(5, ("init_sam_entry2\n"));
1076 sam->user_idx = user_idx;
1077 sam->rid_user = rid_user;
1078 sam->acb_info = acb_info;
1080 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
1081 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
1084 /*******************************************************************
1085 reads or writes a SAM_ENTRY2 structure.
1086 ********************************************************************/
1088 static BOOL sam_io_sam_entry2(char *desc, SAM_ENTRY2 * sam,
1089 prs_struct *ps, int depth)
1094 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1100 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1103 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1105 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1111 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1113 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1119 /*******************************************************************
1120 reads or writes a SAM_STR3 structure.
1121 ********************************************************************/
1123 static BOOL sam_io_sam_str3(char *desc, SAM_STR3 * sam, uint32 acct_buf,
1124 uint32 desc_buf, prs_struct *ps, int depth)
1129 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1135 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1137 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1143 /*******************************************************************
1144 inits a SAM_ENTRY3 structure.
1145 ********************************************************************/
1147 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1148 uint32 len_grp_name, uint32 len_grp_desc,
1151 DEBUG(5, ("init_sam_entry3\n"));
1153 sam->grp_idx = grp_idx;
1154 sam->rid_grp = rid_grp;
1155 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1157 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1158 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1161 /*******************************************************************
1162 reads or writes a SAM_ENTRY3 structure.
1163 ********************************************************************/
1165 static BOOL sam_io_sam_entry3(char *desc, SAM_ENTRY3 * sam,
1166 prs_struct *ps, int depth)
1171 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1177 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1180 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1182 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1185 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1187 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1193 /*******************************************************************
1194 inits a SAM_ENTRY4 structure.
1195 ********************************************************************/
1197 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1198 uint32 len_acct_name)
1200 DEBUG(5, ("init_sam_entry4\n"));
1202 sam->user_idx = user_idx;
1203 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1206 /*******************************************************************
1207 reads or writes a SAM_ENTRY4 structure.
1208 ********************************************************************/
1210 static BOOL sam_io_sam_entry4(char *desc, SAM_ENTRY4 * sam,
1211 prs_struct *ps, int depth)
1216 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1222 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1224 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1230 /*******************************************************************
1231 inits a SAM_ENTRY5 structure.
1232 ********************************************************************/
1234 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1235 uint32 len_grp_name)
1237 DEBUG(5, ("init_sam_entry5\n"));
1239 sam->grp_idx = grp_idx;
1240 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1244 /*******************************************************************
1245 reads or writes a SAM_ENTRY5 structure.
1246 ********************************************************************/
1248 static BOOL sam_io_sam_entry5(char *desc, SAM_ENTRY5 * sam,
1249 prs_struct *ps, int depth)
1254 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1260 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1262 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1268 /*******************************************************************
1269 inits a SAM_ENTRY structure.
1270 ********************************************************************/
1272 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1274 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1277 init_uni_hdr(&sam->hdr_name, len_sam_name);
1280 /*******************************************************************
1281 reads or writes a SAM_ENTRY structure.
1282 ********************************************************************/
1284 static BOOL sam_io_sam_entry(char *desc, SAM_ENTRY * sam,
1285 prs_struct *ps, int depth)
1290 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1295 if(!prs_uint32("rid", ps, depth, &sam->rid))
1297 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1303 /*******************************************************************
1304 inits a SAMR_Q_ENUM_DOM_USERS structure.
1305 ********************************************************************/
1307 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1309 uint16 acb_mask, uint16 unk_1, uint32 size)
1311 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1315 q_e->start_idx = start_idx; /* zero indicates lots */
1316 q_e->acb_mask = acb_mask;
1317 q_e->unknown_1 = unk_1;
1318 q_e->max_size = size;
1321 /*******************************************************************
1322 reads or writes a structure.
1323 ********************************************************************/
1325 BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1326 prs_struct *ps, int depth)
1331 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1337 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1340 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1342 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1344 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1347 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1354 /*******************************************************************
1355 inits a SAMR_R_ENUM_DOM_USERS structure.
1356 ********************************************************************/
1358 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1359 uint32 next_idx, uint32 num_sam_entries)
1361 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1363 r_u->next_idx = next_idx;
1365 if (num_sam_entries != 0) {
1366 r_u->ptr_entries1 = 1;
1367 r_u->ptr_entries2 = 1;
1368 r_u->num_entries2 = num_sam_entries;
1369 r_u->num_entries3 = num_sam_entries;
1371 r_u->num_entries4 = num_sam_entries;
1373 r_u->ptr_entries1 = 0;
1374 r_u->num_entries2 = num_sam_entries;
1375 r_u->ptr_entries2 = 1;
1379 /*******************************************************************
1380 reads or writes a structure.
1381 ********************************************************************/
1383 BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1384 prs_struct *ps, int depth)
1391 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1397 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1399 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1402 if (r_u->ptr_entries1 != 0) {
1403 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1405 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1407 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1410 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1411 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1412 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
1415 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1416 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1417 r_u->num_entries4 = 0;
1418 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1422 for (i = 0; i < r_u->num_entries2; i++) {
1423 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1427 for (i = 0; i < r_u->num_entries2; i++) {
1428 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1437 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1439 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1445 /*******************************************************************
1446 inits a SAMR_Q_QUERY_DISPINFO structure.
1447 ********************************************************************/
1449 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1450 uint16 switch_level, uint32 start_idx,
1453 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1455 q_e->domain_pol = *pol;
1457 q_e->switch_level = switch_level;
1459 q_e->start_idx = start_idx;
1460 q_e->max_entries = max_entries;
1461 q_e->max_size = 0xffff; /* Not especially useful */
1464 /*******************************************************************
1465 reads or writes a structure.
1466 ********************************************************************/
1468 BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1469 prs_struct *ps, int depth)
1474 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1480 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1483 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1488 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1490 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1492 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1498 /*******************************************************************
1499 inits a SAM_DISPINFO_1 structure.
1500 ********************************************************************/
1502 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1503 uint32 start_idx, DISP_USER_INFO *disp_user_info,
1504 DOM_SID *domain_sid)
1506 uint32 len_sam_name, len_sam_full, len_sam_desc;
1509 SAM_ACCOUNT *pwd = NULL;
1512 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1515 return NT_STATUS_OK;
1517 sam->sam=(SAM_ENTRY1 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY1));
1519 return NT_STATUS_NO_MEMORY;
1521 sam->str=(SAM_STR1 *)talloc(ctx, num_entries*sizeof(SAM_STR1));
1523 return NT_STATUS_NO_MEMORY;
1525 ZERO_STRUCTP(sam->sam);
1526 ZERO_STRUCTP(sam->str);
1528 for (i = 0; i < num_entries ; i++) {
1529 const char *username;
1530 const char *fullname;
1531 const char *acct_desc;
1533 const DOM_SID *user_sid;
1534 fstring user_sid_string, domain_sid_string;
1536 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1538 pwd=disp_user_info[i+start_idx].sam;
1540 username = pdb_get_username(pwd);
1541 fullname = pdb_get_fullname(pwd);
1542 acct_desc = pdb_get_acct_desc(pwd);
1553 user_sid = pdb_get_user_sid(pwd);
1555 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1556 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1557 "the domain sid %s. Failing operation.\n",
1559 sid_to_string(user_sid_string, user_sid),
1560 sid_to_string(domain_sid_string, domain_sid)));
1561 return NT_STATUS_UNSUCCESSFUL;
1564 len_sam_name = strlen(username);
1565 len_sam_full = strlen(fullname);
1566 len_sam_desc = strlen(acct_desc);
1568 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1569 len_sam_name, len_sam_full, len_sam_desc,
1570 user_rid, pdb_get_acct_ctrl(pwd));
1572 ZERO_STRUCTP(&sam->str[i].uni_acct_name);
1573 ZERO_STRUCTP(&sam->str[i].uni_full_name);
1574 ZERO_STRUCTP(&sam->str[i].uni_acct_desc);
1576 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), len_sam_name);
1577 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), len_sam_full);
1578 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1581 return NT_STATUS_OK;
1584 /*******************************************************************
1585 reads or writes a structure.
1586 ********************************************************************/
1588 static BOOL sam_io_sam_dispinfo_1(char *desc, SAM_DISPINFO_1 * sam,
1590 prs_struct *ps, int depth)
1594 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1600 if (UNMARSHALLING(ps) && num_entries > 0) {
1602 if ((sam->sam = (SAM_ENTRY1 *)
1603 prs_alloc_mem(ps, sizeof(SAM_ENTRY1) *
1604 num_entries)) == NULL) {
1605 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1609 if ((sam->str = (SAM_STR1 *)
1610 prs_alloc_mem(ps, sizeof(SAM_STR1) *
1611 num_entries)) == NULL) {
1612 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1617 for (i = 0; i < num_entries; i++) {
1618 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1622 for (i = 0; i < num_entries; i++) {
1623 if(!sam_io_sam_str1("", &sam->str[i],
1624 sam->sam[i].hdr_acct_name.buffer,
1625 sam->sam[i].hdr_user_name.buffer,
1626 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1633 /*******************************************************************
1634 inits a SAM_DISPINFO_2 structure.
1635 ********************************************************************/
1637 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1638 uint32 start_idx, DISP_USER_INFO *disp_user_info,
1639 DOM_SID *domain_sid )
1641 uint32 len_sam_name, len_sam_desc;
1644 SAM_ACCOUNT *pwd = NULL;
1647 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1650 return NT_STATUS_OK;
1652 if (!(sam->sam=(SAM_ENTRY2 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY2))))
1653 return NT_STATUS_NO_MEMORY;
1655 if (!(sam->str=(SAM_STR2 *)talloc(ctx, num_entries*sizeof(SAM_STR2))))
1656 return NT_STATUS_NO_MEMORY;
1658 ZERO_STRUCTP(sam->sam);
1659 ZERO_STRUCTP(sam->str);
1661 for (i = 0; i < num_entries; i++) {
1663 const DOM_SID *user_sid;
1664 const char *username;
1665 const char *acct_desc;
1666 fstring user_sid_string, domain_sid_string;
1668 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1669 pwd=disp_user_info[i+start_idx].sam;
1671 username = pdb_get_username(pwd);
1672 acct_desc = pdb_get_acct_desc(pwd);
1673 user_sid = pdb_get_user_sid(pwd);
1675 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1676 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1677 "the domain sid %s. Failing operation.\n",
1679 sid_to_string(user_sid_string, user_sid),
1680 sid_to_string(domain_sid_string, domain_sid)));
1681 return NT_STATUS_UNSUCCESSFUL;
1684 len_sam_name = strlen(username);
1685 len_sam_desc = strlen(acct_desc);
1687 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1688 len_sam_name, len_sam_desc,
1689 user_rid, pdb_get_acct_ctrl(pwd));
1691 ZERO_STRUCTP(&sam->str[i].uni_srv_name);
1692 ZERO_STRUCTP(&sam->str[i].uni_srv_desc);
1694 init_unistr2(&sam->str[i].uni_srv_name, username, len_sam_name);
1695 init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1698 return NT_STATUS_OK;
1701 /*******************************************************************
1702 reads or writes a structure.
1703 ********************************************************************/
1705 static BOOL sam_io_sam_dispinfo_2(char *desc, SAM_DISPINFO_2 * sam,
1707 prs_struct *ps, int depth)
1714 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1720 if (UNMARSHALLING(ps) && num_entries > 0) {
1722 if ((sam->sam = (SAM_ENTRY2 *)
1723 prs_alloc_mem(ps, sizeof(SAM_ENTRY2) *
1724 num_entries)) == NULL) {
1725 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1729 if ((sam->str = (SAM_STR2 *)
1730 prs_alloc_mem(ps, sizeof(SAM_STR2) *
1731 num_entries)) == NULL) {
1732 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1737 for (i = 0; i < num_entries; i++) {
1738 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1742 for (i = 0; i < num_entries; i++) {
1743 if(!sam_io_sam_str2("", &sam->str[i],
1744 sam->sam[i].hdr_srv_name.buffer,
1745 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1752 /*******************************************************************
1753 inits a SAM_DISPINFO_3 structure.
1754 ********************************************************************/
1756 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1757 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1759 uint32 len_sam_name, len_sam_desc;
1764 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1767 return NT_STATUS_OK;
1769 if (!(sam->sam=(SAM_ENTRY3 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY3))))
1770 return NT_STATUS_NO_MEMORY;
1772 if (!(sam->str=(SAM_STR3 *)talloc(ctx, num_entries*sizeof(SAM_STR3))))
1773 return NT_STATUS_NO_MEMORY;
1775 ZERO_STRUCTP(sam->sam);
1776 ZERO_STRUCTP(sam->str);
1778 for (i = 0; i < num_entries; i++) {
1779 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1781 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1783 len_sam_name = strlen(grp->name);
1784 len_sam_desc = strlen(grp->comment);
1786 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp->rid);
1788 init_unistr2(&sam->str[i].uni_grp_name, grp->name, len_sam_name);
1789 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, len_sam_desc);
1792 return NT_STATUS_OK;
1795 /*******************************************************************
1796 reads or writes a structure.
1797 ********************************************************************/
1799 static BOOL sam_io_sam_dispinfo_3(char *desc, SAM_DISPINFO_3 * sam,
1801 prs_struct *ps, int depth)
1808 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1814 if (UNMARSHALLING(ps) && num_entries > 0) {
1816 if ((sam->sam = (SAM_ENTRY3 *)
1817 prs_alloc_mem(ps, sizeof(SAM_ENTRY3) *
1818 num_entries)) == NULL) {
1819 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1823 if ((sam->str = (SAM_STR3 *)
1824 prs_alloc_mem(ps, sizeof(SAM_STR3) *
1825 num_entries)) == NULL) {
1826 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1831 for (i = 0; i < num_entries; i++) {
1832 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1836 for (i = 0; i < num_entries; i++) {
1837 if(!sam_io_sam_str3("", &sam->str[i],
1838 sam->sam[i].hdr_grp_name.buffer,
1839 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1846 /*******************************************************************
1847 inits a SAM_DISPINFO_4 structure.
1848 ********************************************************************/
1850 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1851 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1853 uint32 len_sam_name;
1856 SAM_ACCOUNT *pwd = NULL;
1859 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1862 return NT_STATUS_OK;
1864 if (!(sam->sam=(SAM_ENTRY4 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY4))))
1865 return NT_STATUS_NO_MEMORY;
1867 if (!(sam->str=(SAM_STR4 *)talloc(ctx, num_entries*sizeof(SAM_STR4))))
1868 return NT_STATUS_NO_MEMORY;
1870 ZERO_STRUCTP(sam->sam);
1871 ZERO_STRUCTP(sam->str);
1873 for (i = 0; i < num_entries; i++) {
1874 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1875 pwd=disp_user_info[i+start_idx].sam;
1877 len_sam_name = strlen(pdb_get_username(pwd));
1879 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1881 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1884 return NT_STATUS_OK;
1887 /*******************************************************************
1888 reads or writes a structure.
1889 ********************************************************************/
1891 static BOOL sam_io_sam_dispinfo_4(char *desc, SAM_DISPINFO_4 * sam,
1893 prs_struct *ps, int depth)
1900 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1906 if (UNMARSHALLING(ps) && num_entries > 0) {
1908 if ((sam->sam = (SAM_ENTRY4 *)
1909 prs_alloc_mem(ps, sizeof(SAM_ENTRY4) *
1910 num_entries)) == NULL) {
1911 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1915 if ((sam->str = (SAM_STR4 *)
1916 prs_alloc_mem(ps, sizeof(SAM_STR4) *
1917 num_entries)) == NULL) {
1918 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1923 for (i = 0; i < num_entries; i++) {
1924 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1928 for (i = 0; i < num_entries; i++) {
1929 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1930 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1937 /*******************************************************************
1938 inits a SAM_DISPINFO_5 structure.
1939 ********************************************************************/
1941 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1942 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1944 uint32 len_sam_name;
1949 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1952 return NT_STATUS_OK;
1954 if (!(sam->sam=(SAM_ENTRY5 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY5))))
1955 return NT_STATUS_NO_MEMORY;
1957 if (!(sam->str=(SAM_STR5 *)talloc(ctx, num_entries*sizeof(SAM_STR5))))
1958 return NT_STATUS_NO_MEMORY;
1960 ZERO_STRUCTP(sam->sam);
1961 ZERO_STRUCTP(sam->str);
1963 for (i = 0; i < num_entries; i++) {
1964 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1966 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1968 len_sam_name = strlen(grp->name);
1970 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1971 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1974 return NT_STATUS_OK;
1977 /*******************************************************************
1978 reads or writes a structure.
1979 ********************************************************************/
1981 static BOOL sam_io_sam_dispinfo_5(char *desc, SAM_DISPINFO_5 * sam,
1983 prs_struct *ps, int depth)
1990 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1996 if (UNMARSHALLING(ps) && num_entries > 0) {
1998 if ((sam->sam = (SAM_ENTRY5 *)
1999 prs_alloc_mem(ps, sizeof(SAM_ENTRY5) *
2000 num_entries)) == NULL) {
2001 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
2005 if ((sam->str = (SAM_STR5 *)
2006 prs_alloc_mem(ps, sizeof(SAM_STR5) *
2007 num_entries)) == NULL) {
2008 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2013 for (i = 0; i < num_entries; i++) {
2014 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2018 for (i = 0; i < num_entries; i++) {
2019 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
2020 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2027 /*******************************************************************
2028 inits a SAMR_R_QUERY_DISPINFO structure.
2029 ********************************************************************/
2031 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2032 uint32 num_entries, uint32 total_size, uint32 data_size,
2033 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2036 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2038 r_u->total_size = total_size;
2040 r_u->data_size = data_size;
2042 r_u->switch_level = switch_level;
2043 r_u->num_entries = num_entries;
2046 r_u->ptr_entries = 0;
2048 r_u->ptr_entries = 1;
2050 r_u->num_entries2 = num_entries;
2053 r_u->status = status;
2056 /*******************************************************************
2057 reads or writes a structure.
2058 ********************************************************************/
2060 BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2061 prs_struct *ps, int depth)
2066 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2072 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2074 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2076 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2081 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2083 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2086 if (r_u->ptr_entries==0) {
2089 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2095 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2098 switch (r_u->switch_level) {
2100 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2101 r_u->num_entries, ps, depth))
2105 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2106 r_u->num_entries, ps, depth))
2110 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2111 r_u->num_entries, ps, depth))
2115 if(!sam_io_sam_dispinfo_4("user list",
2116 r_u->ctr->sam.info4,
2117 r_u->num_entries, ps, depth))
2121 if(!sam_io_sam_dispinfo_5("group list",
2122 r_u->ctr->sam.info5,
2123 r_u->num_entries, ps, depth))
2127 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2133 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2139 /*******************************************************************
2140 inits a SAMR_Q_OPEN_GROUP structure.
2141 ********************************************************************/
2143 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2145 uint32 access_mask, uint32 rid)
2147 DEBUG(5, ("init_samr_q_open_group\n"));
2149 q_c->domain_pol = *hnd;
2150 q_c->access_mask = access_mask;
2151 q_c->rid_group = rid;
2154 /*******************************************************************
2155 reads or writes a structure.
2156 ********************************************************************/
2158 BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
2159 prs_struct *ps, int depth)
2164 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2170 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2173 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2175 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2181 /*******************************************************************
2182 reads or writes a structure.
2183 ********************************************************************/
2185 BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
2186 prs_struct *ps, int depth)
2191 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2197 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2200 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2206 /*******************************************************************
2207 inits a GROUP_INFO1 structure.
2208 ********************************************************************/
2210 void init_samr_group_info1(GROUP_INFO1 * gr1,
2211 char *acct_name, char *acct_desc,
2214 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2215 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
2217 DEBUG(5, ("init_samr_group_info1\n"));
2219 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
2221 gr1->unknown_1 = 0x3;
2222 gr1->num_members = num_members;
2224 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
2226 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
2227 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
2230 /*******************************************************************
2231 reads or writes a structure.
2232 ********************************************************************/
2234 BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
2235 prs_struct *ps, int depth)
2240 prs_debug(ps, depth, desc, "samr_io_group_info1");
2246 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2249 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2251 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2254 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2257 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2258 gr1->hdr_acct_name.buffer, ps, depth))
2261 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2262 gr1->hdr_acct_desc.buffer, ps, depth))
2268 /*******************************************************************
2269 inits a GROUP_INFO3 structure.
2270 ********************************************************************/
2272 void init_samr_group_info3(GROUP_INFO3 *gr3)
2274 DEBUG(5, ("init_samr_group_info3\n"));
2276 gr3->unknown_1 = 0x3;
2279 /*******************************************************************
2280 reads or writes a structure.
2281 ********************************************************************/
2283 BOOL samr_io_group_info3(char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2288 prs_debug(ps, depth, desc, "samr_io_group_info3");
2294 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2300 /*******************************************************************
2301 inits a GROUP_INFO4 structure.
2302 ********************************************************************/
2304 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2306 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2308 DEBUG(5, ("init_samr_group_info4\n"));
2310 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2311 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2314 /*******************************************************************
2315 reads or writes a structure.
2316 ********************************************************************/
2318 BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
2319 prs_struct *ps, int depth)
2324 prs_debug(ps, depth, desc, "samr_io_group_info4");
2330 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2332 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2333 gr4->hdr_acct_desc.buffer, ps, depth))
2339 /*******************************************************************
2340 reads or writes a structure.
2341 ********************************************************************/
2343 static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR **ctr,
2344 prs_struct *ps, int depth)
2346 if (UNMARSHALLING(ps))
2347 *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
2352 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2355 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2358 switch ((*ctr)->switch_value1) {
2360 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2364 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2368 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2372 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2379 /*******************************************************************
2380 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2381 ********************************************************************/
2383 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2384 POLICY_HND *pol, char *acct_desc,
2387 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2389 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2393 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2394 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2396 q_e->access_mask = access_mask;
2399 /*******************************************************************
2400 reads or writes a structure.
2401 ********************************************************************/
2403 BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2404 prs_struct *ps, int depth)
2409 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2415 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2418 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2420 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2421 q_e->hdr_acct_desc.buffer, ps, depth))
2426 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2432 /*******************************************************************
2433 reads or writes a structure.
2434 ********************************************************************/
2436 BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2437 prs_struct *ps, int depth)
2442 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2448 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2451 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2453 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2459 /*******************************************************************
2460 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2461 ********************************************************************/
2463 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2466 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2468 q_c->group_pol = *hnd;
2471 /*******************************************************************
2472 reads or writes a structure.
2473 ********************************************************************/
2475 BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2476 prs_struct *ps, int depth)
2481 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2487 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2493 /*******************************************************************
2494 reads or writes a structure.
2495 ********************************************************************/
2497 BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2498 prs_struct *ps, int depth)
2503 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2509 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2512 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2518 /*******************************************************************
2519 inits a SAMR_Q_DEL_GROUPMEM structure.
2520 ********************************************************************/
2522 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2523 POLICY_HND *pol, uint32 rid)
2525 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2531 /*******************************************************************
2532 reads or writes a structure.
2533 ********************************************************************/
2535 BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2536 prs_struct *ps, int depth)
2541 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2547 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2550 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2556 /*******************************************************************
2557 inits a SAMR_R_DEL_GROUPMEM structure.
2558 ********************************************************************/
2560 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2563 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2565 r_u->status = status;
2568 /*******************************************************************
2569 reads or writes a structure.
2570 ********************************************************************/
2572 BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2573 prs_struct *ps, int depth)
2578 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2584 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2590 /*******************************************************************
2591 inits a SAMR_Q_ADD_GROUPMEM structure.
2592 ********************************************************************/
2594 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2595 POLICY_HND *pol, uint32 rid)
2597 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2601 q_e->unknown = 0x0005;
2604 /*******************************************************************
2605 reads or writes a structure.
2606 ********************************************************************/
2608 BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2609 prs_struct *ps, int depth)
2614 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2620 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2623 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2625 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2631 /*******************************************************************
2632 inits a SAMR_R_ADD_GROUPMEM structure.
2633 ********************************************************************/
2635 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2638 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2640 r_u->status = status;
2643 /*******************************************************************
2644 reads or writes a structure.
2645 ********************************************************************/
2647 BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2648 prs_struct *ps, int depth)
2653 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2659 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2665 /*******************************************************************
2666 inits a SAMR_Q_SET_GROUPINFO structure.
2667 ********************************************************************/
2669 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2670 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2672 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2678 /*******************************************************************
2679 reads or writes a structure.
2680 ********************************************************************/
2682 BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2683 prs_struct *ps, int depth)
2688 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2694 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2697 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2703 /*******************************************************************
2704 inits a SAMR_R_SET_GROUPINFO structure.
2705 ********************************************************************/
2707 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2709 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2711 r_u->status = status;
2714 /*******************************************************************
2715 reads or writes a structure.
2716 ********************************************************************/
2718 BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
2719 prs_struct *ps, int depth)
2724 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2730 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2736 /*******************************************************************
2737 inits a SAMR_Q_QUERY_GROUPINFO structure.
2738 ********************************************************************/
2740 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2741 POLICY_HND *pol, uint16 switch_level)
2743 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2747 q_e->switch_level = switch_level;
2750 /*******************************************************************
2751 reads or writes a structure.
2752 ********************************************************************/
2754 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2755 prs_struct *ps, int depth)
2760 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2766 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2769 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2775 /*******************************************************************
2776 inits a SAMR_R_QUERY_GROUPINFO structure.
2777 ********************************************************************/
2779 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2780 GROUP_INFO_CTR * ctr, NTSTATUS status)
2782 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2784 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2786 r_u->status = status;
2789 /*******************************************************************
2790 reads or writes a structure.
2791 ********************************************************************/
2793 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2794 prs_struct *ps, int depth)
2799 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2805 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2808 if (r_u->ptr != 0) {
2809 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2815 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2821 /*******************************************************************
2822 inits a SAMR_Q_QUERY_GROUPMEM structure.
2823 ********************************************************************/
2825 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2827 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2829 q_c->group_pol = *hnd;
2832 /*******************************************************************
2833 reads or writes a structure.
2834 ********************************************************************/
2836 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2837 prs_struct *ps, int depth)
2842 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2848 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2854 /*******************************************************************
2855 inits a SAMR_R_QUERY_GROUPMEM structure.
2856 ********************************************************************/
2858 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2859 uint32 num_entries, uint32 *rid,
2860 uint32 *attr, NTSTATUS status)
2862 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2864 if (NT_STATUS_IS_OK(status)) {
2866 r_u->num_entries = num_entries;
2868 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2869 r_u->ptr_rids = rid != NULL ? 1 : 0;
2871 r_u->num_rids = num_entries;
2874 r_u->num_attrs = num_entries;
2878 r_u->num_entries = 0;
2881 r_u->status = status;
2884 /*******************************************************************
2885 reads or writes a structure.
2886 ********************************************************************/
2888 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2889 prs_struct *ps, int depth)
2896 if (UNMARSHALLING(ps))
2899 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2905 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2907 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2910 if (r_u->ptr != 0) {
2911 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2913 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2916 if (r_u->ptr_rids != 0) {
2917 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2919 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2920 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2921 if (r_u->rid == NULL)
2925 for (i = 0; i < r_u->num_rids; i++) {
2926 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2931 if (r_u->ptr_attrs != 0) {
2932 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2935 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2936 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2937 if (r_u->attr == NULL)
2941 for (i = 0; i < r_u->num_attrs; i++) {
2942 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2948 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2954 /*******************************************************************
2955 inits a SAMR_Q_QUERY_USERGROUPS structure.
2956 ********************************************************************/
2958 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2961 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2966 /*******************************************************************
2967 reads or writes a structure.
2968 ********************************************************************/
2970 BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2971 prs_struct *ps, int depth)
2976 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2982 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2988 /*******************************************************************
2989 inits a SAMR_R_QUERY_USERGROUPS structure.
2990 ********************************************************************/
2992 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2993 uint32 num_gids, DOM_GID * gid,
2996 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2998 if (NT_STATUS_IS_OK(status)) {
3000 r_u->num_entries = num_gids;
3001 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3002 r_u->num_entries2 = num_gids;
3007 r_u->num_entries = 0;
3012 r_u->status = status;
3015 /*******************************************************************
3016 reads or writes a structure.
3017 ********************************************************************/
3019 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
3020 prs_struct *ps, int depth)
3026 prs_debug(ps, depth, desc, "samr_io_gids");
3032 if(!prs_uint32("num_gids", ps, depth, num_gids))
3035 if ((*num_gids) != 0) {
3036 if (UNMARSHALLING(ps)) {
3037 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
3040 if ((*gid) == NULL) {
3044 for (i = 0; i < (*num_gids); i++) {
3045 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3053 /*******************************************************************
3054 reads or writes a structure.
3055 ********************************************************************/
3057 BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3058 prs_struct *ps, int depth)
3063 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3069 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3072 if (r_u->ptr_0 != 0) {
3073 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3075 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3078 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3079 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3086 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3092 /*******************************************************************
3093 inits a SAMR_Q_ENUM_DOMAINS structure.
3094 ********************************************************************/
3096 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3098 uint32 start_idx, uint32 size)
3100 DEBUG(5, ("init_samr_q_enum_domains\n"));
3104 q_e->start_idx = start_idx;
3105 q_e->max_size = size;
3108 /*******************************************************************
3109 reads or writes a structure.
3110 ********************************************************************/
3112 BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3113 prs_struct *ps, int depth)
3118 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3124 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3127 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3129 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3135 /*******************************************************************
3136 inits a SAMR_R_ENUM_DOMAINS structure.
3137 ********************************************************************/
3139 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3140 uint32 next_idx, uint32 num_sam_entries)
3142 DEBUG(5, ("init_samr_r_enum_domains\n"));
3144 r_u->next_idx = next_idx;
3146 if (num_sam_entries != 0) {
3147 r_u->ptr_entries1 = 1;
3148 r_u->ptr_entries2 = 1;
3149 r_u->num_entries2 = num_sam_entries;
3150 r_u->num_entries3 = num_sam_entries;
3152 r_u->num_entries4 = num_sam_entries;
3154 r_u->ptr_entries1 = 0;
3155 r_u->num_entries2 = num_sam_entries;
3156 r_u->ptr_entries2 = 1;
3160 /*******************************************************************
3161 reads or writes a structure.
3162 ********************************************************************/
3164 BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3165 prs_struct *ps, int depth)
3172 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3178 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3180 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3183 if (r_u->ptr_entries1 != 0) {
3184 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3186 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3188 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3191 if (UNMARSHALLING(ps)) {
3192 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3193 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3196 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3197 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3198 r_u->num_entries4 = 0;
3199 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3203 for (i = 0; i < r_u->num_entries2; i++) {
3205 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3206 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3210 for (i = 0; i < r_u->num_entries2; i++) {
3212 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3213 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3214 r_u->sam[i].hdr_name.buffer, ps,
3223 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3225 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3231 /*******************************************************************
3232 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3233 ********************************************************************/
3235 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3237 uint32 start_idx, uint32 size)
3239 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3243 q_e->start_idx = start_idx;
3244 q_e->max_size = size;
3247 /*******************************************************************
3248 reads or writes a structure.
3249 ********************************************************************/
3251 BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3252 prs_struct *ps, int depth)
3257 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3263 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3266 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3268 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3274 /*******************************************************************
3275 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3276 ********************************************************************/
3278 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3279 uint32 next_idx, uint32 num_sam_entries)
3281 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3283 r_u->next_idx = next_idx;
3285 if (num_sam_entries != 0) {
3286 r_u->ptr_entries1 = 1;
3287 r_u->ptr_entries2 = 1;
3288 r_u->num_entries2 = num_sam_entries;
3289 r_u->num_entries3 = num_sam_entries;
3291 r_u->num_entries4 = num_sam_entries;
3293 r_u->ptr_entries1 = 0;
3294 r_u->num_entries2 = num_sam_entries;
3295 r_u->ptr_entries2 = 1;
3299 /*******************************************************************
3300 reads or writes a structure.
3301 ********************************************************************/
3303 BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3304 prs_struct *ps, int depth)
3311 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3317 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3319 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3322 if (r_u->ptr_entries1 != 0) {
3323 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3325 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3327 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3330 if (UNMARSHALLING(ps)) {
3331 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3332 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3335 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3337 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3338 r_u->num_entries4 = 0;
3339 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3343 for (i = 0; i < r_u->num_entries2; i++) {
3344 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3348 for (i = 0; i < r_u->num_entries2; i++) {
3349 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3350 r_u->sam[i].hdr_name.buffer, ps, depth))
3357 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3359 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3365 /*******************************************************************
3366 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3367 ********************************************************************/
3369 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3370 POLICY_HND *pol, uint32 start_idx,
3373 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3377 q_e->start_idx = start_idx;
3378 q_e->max_size = size;
3382 /*******************************************************************
3383 reads or writes a structure.
3384 ********************************************************************/
3386 BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3387 prs_struct *ps, int depth)
3392 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3398 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3401 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3403 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3409 /*******************************************************************
3410 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3411 ********************************************************************/
3413 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3415 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3417 r_u->next_idx = next_idx;
3419 if (num_sam_entries != 0) {
3420 r_u->ptr_entries1 = 1;
3421 r_u->ptr_entries2 = 1;
3422 r_u->num_entries2 = num_sam_entries;
3423 r_u->num_entries3 = num_sam_entries;
3425 r_u->num_entries4 = num_sam_entries;
3427 r_u->ptr_entries1 = 0;
3428 r_u->num_entries2 = num_sam_entries;
3429 r_u->ptr_entries2 = 1;
3433 /*******************************************************************
3434 reads or writes a structure.
3435 ********************************************************************/
3437 BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3438 prs_struct *ps, int depth)
3445 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3451 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3453 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3456 if (r_u->ptr_entries1 != 0) {
3457 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3459 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3461 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3464 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3465 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3466 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3469 if (r_u->num_entries2 != 0 &&
3470 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3471 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3472 r_u->num_entries4 = 0;
3473 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3477 for (i = 0; i < r_u->num_entries2; i++) {
3478 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3482 for (i = 0; i < r_u->num_entries2; i++) {
3483 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3484 r_u->sam[i].hdr_name.buffer, ps,
3492 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3494 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3500 /*******************************************************************
3501 inits a ALIAS_INFO1 structure.
3502 ********************************************************************/
3504 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3506 int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0;
3507 int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0;
3509 DEBUG(5, ("init_samr_alias_info1\n"));
3511 init_uni_hdr(&al1->hdr_acct_name, acct_len_name);
3512 init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name);
3514 al1->num_member=num_member;
3516 init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc);
3517 init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc);
3520 /*******************************************************************
3521 reads or writes a structure.
3522 ********************************************************************/
3524 BOOL samr_io_alias_info1(char *desc, ALIAS_INFO1 * al1,
3525 prs_struct *ps, int depth)
3530 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3536 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3538 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3540 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3543 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3544 al1->hdr_acct_name.buffer, ps, depth))
3550 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3551 al1->hdr_acct_desc.buffer, ps, depth))
3557 /*******************************************************************
3558 inits a ALIAS_INFO3 structure.
3559 ********************************************************************/
3561 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3563 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3565 DEBUG(5, ("init_samr_alias_info3\n"));
3567 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3568 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3571 /*******************************************************************
3572 reads or writes a structure.
3573 ********************************************************************/
3575 BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
3576 prs_struct *ps, int depth)
3581 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3587 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3589 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3590 al3->hdr_acct_desc.buffer, ps, depth))
3596 /*******************************************************************
3597 reads or writes a structure.
3598 ********************************************************************/
3600 BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
3601 prs_struct *ps, int depth)
3606 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3609 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3611 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3614 switch (ctr->switch_value1) {
3616 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3620 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3624 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3631 /*******************************************************************
3632 inits a SAMR_Q_QUERY_ALIASINFO structure.
3633 ********************************************************************/
3635 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3636 POLICY_HND *pol, uint16 switch_level)
3638 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3641 q_e->switch_level = switch_level;
3644 /*******************************************************************
3645 reads or writes a structure.
3646 ********************************************************************/
3648 BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3649 prs_struct *ps, int depth)
3654 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3660 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3663 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3669 /*******************************************************************
3670 inits a SAMR_R_QUERY_ALIASINFO structure.
3671 ********************************************************************/
3673 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3674 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3676 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3678 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3680 r_u->status = status;
3683 /*******************************************************************
3684 reads or writes a structure.
3685 ********************************************************************/
3687 BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3688 prs_struct *ps, int depth)
3693 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3699 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3702 if (r_u->ptr != 0) {
3703 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3709 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3715 /*******************************************************************
3716 inits a SAMR_Q_SET_ALIASINFO structure.
3717 ********************************************************************/
3719 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3720 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3722 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3724 q_u->alias_pol = *hnd;
3728 /*******************************************************************
3729 reads or writes a structure.
3730 ********************************************************************/
3732 BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3733 prs_struct *ps, int depth)
3738 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3744 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3746 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3752 /*******************************************************************
3753 reads or writes a structure.
3754 ********************************************************************/
3756 BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
3757 prs_struct *ps, int depth)
3762 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3767 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3773 /*******************************************************************
3774 inits a SAMR_Q_QUERY_USERALIASES structure.
3775 ********************************************************************/
3777 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3780 uint32 *ptr_sid, DOM_SID2 * sid)
3782 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3786 q_u->num_sids1 = num_sids;
3788 q_u->num_sids2 = num_sids;
3790 q_u->ptr_sid = ptr_sid;
3794 /*******************************************************************
3795 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3796 ********************************************************************/
3798 BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3799 prs_struct *ps, int depth)
3807 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3813 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3816 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3818 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3824 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3827 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3828 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3829 if (q_u->ptr_sid == NULL)
3832 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3833 if (q_u->sid == NULL)
3837 for (i = 0; i < q_u->num_sids2; i++) {
3838 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3839 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3843 for (i = 0; i < q_u->num_sids2; i++) {
3844 if (q_u->ptr_sid[i] != 0) {
3845 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3846 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3854 /*******************************************************************
3855 inits a SAMR_R_QUERY_USERALIASES structure.
3856 ********************************************************************/
3858 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3859 uint32 num_rids, uint32 *rid,
3862 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3864 if (NT_STATUS_IS_OK(status)) {
3865 r_u->num_entries = num_rids;
3867 r_u->num_entries2 = num_rids;
3871 r_u->num_entries = 0;
3873 r_u->num_entries2 = 0;
3876 r_u->status = status;
3879 /*******************************************************************
3880 reads or writes a structure.
3881 ********************************************************************/
3883 BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
3884 prs_struct *ps, int depth)
3891 prs_debug(ps, depth, desc, "samr_io_rids");
3897 if(!prs_uint32("num_rids", ps, depth, num_rids))
3900 if ((*num_rids) != 0) {
3901 if (UNMARSHALLING(ps)) {
3903 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3908 for (i = 0; i < (*num_rids); i++) {
3909 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3910 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3918 /*******************************************************************
3919 reads or writes a structure.
3920 ********************************************************************/
3922 BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3923 prs_struct *ps, int depth)
3928 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3934 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3936 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3939 if (r_u->ptr != 0) {
3940 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3946 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3952 /*******************************************************************
3953 inits a SAMR_Q_OPEN_ALIAS structure.
3954 ********************************************************************/
3956 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3957 uint32 access_mask, uint32 rid)
3959 DEBUG(5, ("init_samr_q_open_alias\n"));
3961 q_u->dom_pol = *pol;
3962 q_u->access_mask = access_mask;
3963 q_u->rid_alias = rid;
3966 /*******************************************************************
3967 reads or writes a structure.
3968 ********************************************************************/
3970 BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3971 prs_struct *ps, int depth)
3976 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3982 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3985 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3987 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3993 /*******************************************************************
3994 reads or writes a structure.
3995 ********************************************************************/
3997 BOOL samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS * r_u,
3998 prs_struct *ps, int depth)
4003 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4009 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4012 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4018 /*******************************************************************
4019 inits a SAMR_Q_LOOKUP_RIDS structure.
4020 ********************************************************************/
4022 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4023 POLICY_HND *pol, uint32 flags,
4024 uint32 num_rids, uint32 *rid)
4026 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4030 q_u->num_rids1 = num_rids;
4033 q_u->num_rids2 = num_rids;
4034 q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0]));
4035 if (q_u->rid == NULL) {
4039 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4043 /*******************************************************************
4044 reads or writes a structure.
4045 ********************************************************************/
4047 BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4048 prs_struct *ps, int depth)
4056 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4059 if (UNMARSHALLING(ps))
4065 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4068 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4070 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4072 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4074 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4077 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4078 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
4079 if (q_u->rid == NULL)
4083 for (i = 0; i < q_u->num_rids2; i++) {
4084 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4085 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4092 /*******************************************************************
4093 inits a SAMR_R_LOOKUP_RIDS structure.
4094 ********************************************************************/
4096 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4097 uint32 num_names, UNIHDR * hdr_name,
4098 UNISTR2 *uni_name, uint32 *type)
4100 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4102 r_u->hdr_name = NULL;
4103 r_u->uni_name = NULL;
4106 if (num_names != 0) {
4107 r_u->num_names1 = num_names;
4109 r_u->num_names2 = num_names;
4111 r_u->num_types1 = num_names;
4113 r_u->num_types2 = num_names;
4115 r_u->hdr_name = hdr_name;
4116 r_u->uni_name = uni_name;
4119 r_u->num_names1 = num_names;
4121 r_u->num_names2 = num_names;
4123 r_u->num_types1 = num_names;
4125 r_u->num_types2 = num_names;
4129 /*******************************************************************
4130 reads or writes a structure.
4131 ********************************************************************/
4133 BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4134 prs_struct *ps, int depth)
4141 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4147 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4149 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4152 if (r_u->ptr_names != 0) {
4154 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4158 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4159 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
4160 if (r_u->hdr_name == NULL)
4163 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
4164 if (r_u->uni_name == NULL)
4168 for (i = 0; i < r_u->num_names2; i++) {
4169 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4170 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4173 for (i = 0; i < r_u->num_names2; i++) {
4174 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4175 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4183 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4185 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4188 if (r_u->ptr_types != 0) {
4190 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4193 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4194 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
4195 if (r_u->type == NULL)
4199 for (i = 0; i < r_u->num_types2; i++) {
4200 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4201 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4206 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4212 /*******************************************************************
4213 inits a SAMR_Q_OPEN_ALIAS structure.
4214 ********************************************************************/
4216 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4218 DEBUG(5, ("init_samr_q_delete_alias\n"));
4220 q_u->alias_pol = *hnd;
4223 /*******************************************************************
4224 reads or writes a structure.
4225 ********************************************************************/
4227 BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4228 prs_struct *ps, int depth)
4233 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4239 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4245 /*******************************************************************
4246 reads or writes a structure.
4247 ********************************************************************/
4249 BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4250 prs_struct *ps, int depth)
4255 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4261 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4263 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4269 /*******************************************************************
4270 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4271 ********************************************************************/
4273 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4274 POLICY_HND *hnd, char *acct_desc)
4276 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
4278 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4280 q_u->dom_pol = *hnd;
4282 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
4283 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
4285 q_u->access_mask = 0x001f000f;
4288 /*******************************************************************
4289 reads or writes a structure.
4290 ********************************************************************/
4292 BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4293 prs_struct *ps, int depth)
4298 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4304 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4307 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4309 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4310 q_u->hdr_acct_desc.buffer, ps, depth))
4315 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4321 /*******************************************************************
4322 reads or writes a structure.
4323 ********************************************************************/
4325 BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4326 prs_struct *ps, int depth)
4331 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4337 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4340 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4343 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4349 /*******************************************************************
4350 inits a SAMR_Q_ADD_ALIASMEM structure.
4351 ********************************************************************/
4353 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4356 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4358 q_u->alias_pol = *hnd;
4359 init_dom_sid2(&q_u->sid, sid);
4362 /*******************************************************************
4363 reads or writes a structure.
4364 ********************************************************************/
4366 BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4367 prs_struct *ps, int depth)
4372 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4378 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4380 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4386 /*******************************************************************
4387 reads or writes a structure.
4388 ********************************************************************/
4390 BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4391 prs_struct *ps, int depth)
4396 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4402 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4408 /*******************************************************************
4409 inits a SAMR_Q_DEL_ALIASMEM structure.
4410 ********************************************************************/
4412 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4415 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4417 q_u->alias_pol = *hnd;
4418 init_dom_sid2(&q_u->sid, sid);
4421 /*******************************************************************
4422 reads or writes a structure.
4423 ********************************************************************/
4425 BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4426 prs_struct *ps, int depth)
4431 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4437 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4439 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4445 /*******************************************************************
4446 reads or writes a structure.
4447 ********************************************************************/
4449 BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4450 prs_struct *ps, int depth)
4455 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4461 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4467 /*******************************************************************
4468 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4469 ********************************************************************/
4471 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4474 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4476 q_c->alias_pol = *hnd;
4479 /*******************************************************************
4480 reads or writes a structure.
4481 ********************************************************************/
4483 BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4484 prs_struct *ps, int depth)
4489 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4495 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4501 /*******************************************************************
4502 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4503 ********************************************************************/
4505 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4508 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4510 r_u->status = status;
4513 /*******************************************************************
4514 reads or writes a structure.
4515 ********************************************************************/
4517 BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4518 prs_struct *ps, int depth)
4523 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4529 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4535 /*******************************************************************
4536 inits a SAMR_Q_QUERY_ALIASMEM structure.
4537 ********************************************************************/
4539 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4542 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4544 q_c->alias_pol = *hnd;
4547 /*******************************************************************
4548 reads or writes a structure.
4549 ********************************************************************/
4551 BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4552 prs_struct *ps, int depth)
4557 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4563 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4569 /*******************************************************************
4570 inits a SAMR_R_QUERY_ALIASMEM structure.
4571 ********************************************************************/
4573 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4574 uint32 num_sids, DOM_SID2 * sid,
4577 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4579 if (NT_STATUS_IS_OK(status)) {
4580 r_u->num_sids = num_sids;
4581 r_u->ptr = (num_sids != 0) ? 1 : 0;
4582 r_u->num_sids1 = num_sids;
4590 r_u->status = status;
4593 /*******************************************************************
4594 reads or writes a structure.
4595 ********************************************************************/
4597 BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4598 prs_struct *ps, int depth)
4601 uint32 ptr_sid[MAX_LOOKUP_SIDS];
4606 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4612 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4614 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4617 if (r_u->ptr != 0) {
4618 SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids);
4620 if (r_u->num_sids != 0) {
4621 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4624 for (i = 0; i < r_u->num_sids1; i++) {
4626 if(!prs_uint32("", ps, depth, &ptr_sid[i]))
4630 for (i = 0; i < r_u->num_sids1; i++) {
4631 if (ptr_sid[i] != 0) {
4632 if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth))
4641 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4647 /*******************************************************************
4648 inits a SAMR_Q_LOOKUP_NAMES structure.
4649 ********************************************************************/
4651 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4652 POLICY_HND *pol, uint32 flags,
4653 uint32 num_names, const char **name)
4657 DEBUG(5, ("init_samr_q_lookup_names\n"));
4661 q_u->num_names1 = num_names;
4664 q_u->num_names2 = num_names;
4666 if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR))))
4667 return NT_STATUS_NO_MEMORY;
4669 if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2))))
4670 return NT_STATUS_NO_MEMORY;
4672 for (i = 0; i < num_names; i++) {
4673 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4674 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4675 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4678 return NT_STATUS_OK;
4681 /*******************************************************************
4682 reads or writes a structure.
4683 ********************************************************************/
4685 BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4686 prs_struct *ps, int depth)
4693 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4696 if (UNMARSHALLING(ps))
4702 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4705 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4707 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4709 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4711 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4714 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4715 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4717 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4719 if (!q_u->hdr_name || !q_u->uni_name)
4723 for (i = 0; i < q_u->num_names2; i++) {
4724 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4728 for (i = 0; i < q_u->num_names2; i++) {
4729 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4736 /*******************************************************************
4737 inits a SAMR_R_LOOKUP_NAMES structure.
4738 ********************************************************************/
4740 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4742 uint32 *rid, uint32 *type,
4745 DEBUG(5, ("init_samr_r_lookup_names\n"));
4747 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4750 r_u->num_types1 = num_rids;
4752 r_u->num_types2 = num_rids;
4754 r_u->num_rids1 = num_rids;
4756 r_u->num_rids2 = num_rids;
4758 if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4759 return NT_STATUS_NO_MEMORY;
4760 if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4761 return NT_STATUS_NO_MEMORY;
4763 if (!r_u->rids || !r_u->types)
4766 for (i = 0; i < num_rids; i++) {
4767 r_u->rids[i] = rid[i];
4768 r_u->types[i] = type[i];
4773 r_u->num_types1 = 0;
4775 r_u->num_types2 = 0;
4785 r_u->status = status;
4787 return NT_STATUS_OK;
4790 /*******************************************************************
4791 reads or writes a structure.
4792 ********************************************************************/
4794 BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4795 prs_struct *ps, int depth)
4803 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4806 if (UNMARSHALLING(ps))
4812 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4814 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4817 if (r_u->ptr_rids != 0) {
4818 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4821 if (r_u->num_rids2 != r_u->num_rids1) {
4826 if (UNMARSHALLING(ps))
4827 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4830 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4834 for (i = 0; i < r_u->num_rids2; i++) {
4835 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4836 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4841 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4843 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4846 if (r_u->ptr_types != 0) {
4847 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4850 if (r_u->num_types2 != r_u->num_types1) {
4855 if (UNMARSHALLING(ps))
4856 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4859 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4863 for (i = 0; i < r_u->num_types2; i++) {
4864 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4865 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4870 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4876 /*******************************************************************
4877 inits a SAMR_Q_DELETE_DOM_USER structure.
4878 ********************************************************************/
4880 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4883 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4885 q_c->user_pol = *hnd;
4888 /*******************************************************************
4889 reads or writes a structure.
4890 ********************************************************************/
4892 BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4893 prs_struct *ps, int depth)
4898 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4904 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4910 /*******************************************************************
4911 reads or writes a structure.
4912 ********************************************************************/
4914 BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4915 prs_struct *ps, int depth)
4920 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4926 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4928 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4934 /*******************************************************************
4935 reads or writes a structure.
4936 ********************************************************************/
4938 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4940 uint32 access_mask, uint32 rid)
4942 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4944 q_u->domain_pol = *pol;
4945 q_u->access_mask = access_mask;
4946 q_u->user_rid = rid;
4949 /*******************************************************************
4950 reads or writes a structure.
4951 ********************************************************************/
4953 BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
4954 prs_struct *ps, int depth)
4959 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4965 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4968 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4970 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4976 /*******************************************************************
4977 reads or writes a structure.
4978 ********************************************************************/
4980 BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
4981 prs_struct *ps, int depth)
4986 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4992 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4995 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5002 /*******************************************************************
5003 reads or writes a structure.
5004 ********************************************************************/
5006 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5009 uint32 acb_info, uint32 access_mask)
5012 len_name = strlen(name);
5014 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5016 q_u->domain_pol = *pol;
5018 init_uni_hdr(&q_u->hdr_name, len_name);
5019 init_unistr2(&q_u->uni_name, name, len_name);
5021 q_u->acb_info = acb_info;
5022 q_u->access_mask = access_mask;
5025 /*******************************************************************
5026 reads or writes a structure.
5027 ********************************************************************/
5029 BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
5030 prs_struct *ps, int depth)
5035 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5041 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5044 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5046 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5051 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5053 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5059 /*******************************************************************
5060 reads or writes a structure.
5061 ********************************************************************/
5063 BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
5064 prs_struct *ps, int depth)
5069 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5075 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5078 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5080 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5082 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5088 /*******************************************************************
5089 inits a SAMR_Q_QUERY_USERINFO structure.
5090 ********************************************************************/
5092 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5093 POLICY_HND *hnd, uint16 switch_value)
5095 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5098 q_u->switch_value = switch_value;
5101 /*******************************************************************
5102 reads or writes a structure.
5103 ********************************************************************/
5105 BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5106 prs_struct *ps, int depth)
5111 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5117 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5120 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5126 /*******************************************************************
5127 reads or writes a LOGON_HRS structure.
5128 ********************************************************************/
5130 static BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs,
5131 prs_struct *ps, int depth)
5136 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5142 if(!prs_uint32("len ", ps, depth, &hrs->len))
5145 if (hrs->len > sizeof(hrs->hours)) {
5146 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5147 hrs->len = sizeof(hrs->hours);
5150 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5156 /*******************************************************************
5157 inits a SAM_USER_INFO_12 structure.
5158 ********************************************************************/
5160 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5161 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5163 DEBUG(5, ("init_sam_user_info12\n"));
5165 usr->lm_pwd_active =
5166 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5167 usr->nt_pwd_active =
5168 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5171 /*******************************************************************
5172 reads or writes a structure.
5173 ********************************************************************/
5175 static BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
5176 prs_struct *ps, int depth)
5181 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5187 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5189 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5192 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5194 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5200 /*******************************************************************
5201 inits a SAM_USER_INFO_10 structure.
5202 ********************************************************************/
5204 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5206 DEBUG(5, ("init_sam_user_info10\n"));
5208 usr->acb_info = acb_info;
5211 /*******************************************************************
5212 reads or writes a structure.
5213 ********************************************************************/
5215 static BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
5216 prs_struct *ps, int depth)
5221 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5227 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5233 /*******************************************************************
5234 inits a SAM_USER_INFO_11 structure.
5235 ********************************************************************/
5237 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5240 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5244 DEBUG(5, ("init_sam_user_info11\n"));
5246 len_mach_acct = strlen(mach_acct);
5248 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
5249 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5251 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
5252 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5254 usr->ptr_1 = 1; /* pointer */
5255 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5256 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5258 usr->ptr_2 = 1; /* pointer */
5259 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5261 usr->ptr_3 = 1; /* pointer */
5262 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5264 usr->rid_user = rid_user;
5265 usr->rid_group = rid_group;
5267 usr->acct_ctrl = acct_ctrl;
5268 usr->unknown_3 = 0x0000;
5270 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5271 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5273 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5274 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5276 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
5279 /*******************************************************************
5280 reads or writes a structure.
5281 ********************************************************************/
5283 static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
5284 prs_struct *ps, int depth)
5289 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5295 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5298 if(!smb_io_time("time", &usr->expiry, ps, depth))
5301 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5304 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5307 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5310 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5312 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5315 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5318 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5320 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5323 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5325 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5328 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5330 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5332 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5334 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5336 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5338 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5341 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5344 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5347 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5353 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5359 /*************************************************************************
5362 unknown_3 = 0x09f8 27fa
5363 unknown_5 = 0x0001 0000
5364 unknown_6 = 0x0000 04ec
5366 *************************************************************************/
5368 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5370 DEBUG(10, ("init_sam_user_info24:\n"));
5371 memcpy(usr->pass, newpass, sizeof(usr->pass));
5372 usr->pw_len = pw_len;
5375 /*******************************************************************
5376 reads or writes a structure.
5377 ********************************************************************/
5379 static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
5380 prs_struct *ps, int depth)
5385 prs_debug(ps, depth, desc, "sam_io_user_info24");
5391 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5395 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5396 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5405 /*************************************************************************
5406 init_sam_user_info23
5408 unknown_3 = 0x09f8 27fa
5409 unknown_5 = 0x0001 0000
5410 unknown_6 = 0x0000 04ec
5412 *************************************************************************/
5414 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5415 NTTIME * logoff_time, /* all zeros */
5416 NTTIME * kickoff_time, /* all zeros */
5417 NTTIME * pass_last_set_time, /* all zeros */
5418 NTTIME * pass_can_change_time, /* all zeros */
5419 NTTIME * pass_must_change_time, /* all zeros */
5430 uint32 user_rid, /* 0x0000 0000 */
5437 char newpass[516], uint32 unknown_6)
5439 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5440 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5441 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5442 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5443 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5444 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5445 int len_description = desc != NULL ? desc->uni_str_len : 0;
5446 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5447 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5448 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5450 usr->logon_time = *logon_time; /* all zeros */
5451 usr->logoff_time = *logoff_time; /* all zeros */
5452 usr->kickoff_time = *kickoff_time; /* all zeros */
5453 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5454 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5455 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5457 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5458 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5459 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5460 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5461 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5462 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5463 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5464 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5465 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5466 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5468 ZERO_STRUCT(usr->nt_pwd);
5469 ZERO_STRUCT(usr->lm_pwd);
5471 usr->user_rid = user_rid; /* 0x0000 0000 */
5472 usr->group_rid = group_rid;
5473 usr->acb_info = acb_info;
5474 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5476 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5477 usr->ptr_logon_hrs = hrs ? 1 : 0;
5479 if (nt_time_is_zero(pass_must_change_time)) {
5480 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5482 usr->passmustchange=0;
5486 ZERO_STRUCT(usr->padding1);
5487 ZERO_STRUCT(usr->padding2);
5489 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5491 memcpy(usr->pass, newpass, sizeof(usr->pass));
5493 copy_unistr2(&usr->uni_user_name, user_name);
5494 copy_unistr2(&usr->uni_full_name, full_name);
5495 copy_unistr2(&usr->uni_home_dir, home_dir);
5496 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5497 copy_unistr2(&usr->uni_logon_script, log_scr);
5498 copy_unistr2(&usr->uni_profile_path, prof_path);
5499 copy_unistr2(&usr->uni_acct_desc, desc);
5500 copy_unistr2(&usr->uni_workstations, wkstas);
5501 copy_unistr2(&usr->uni_unknown_str, unk_str);
5502 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5504 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5507 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5510 /*************************************************************************
5511 init_sam_user_info23
5513 unknown_3 = 0x09f8 27fa
5514 unknown_5 = 0x0001 0000
5515 unknown_6 = 0x0000 04ec
5517 *************************************************************************/
5519 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5520 NTTIME * logoff_time, /* all zeros */
5521 NTTIME * kickoff_time, /* all zeros */
5522 NTTIME * pass_last_set_time, /* all zeros */
5523 NTTIME * pass_can_change_time, /* all zeros */
5524 NTTIME * pass_must_change_time, /* all zeros */
5525 char *user_name, /* NULL */
5527 char *home_dir, char *dir_drive, char *log_scr,
5528 char *prof_path, char *desc, char *wkstas,
5529 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5530 uint32 group_rid, uint32 acb_info,
5531 uint32 unknown_3, uint16 logon_divs,
5532 LOGON_HRS * hrs, uint32 unknown_5,
5533 char newpass[516], uint32 unknown_6)
5535 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5536 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5537 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5538 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5539 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5540 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5541 int len_description = desc != NULL ? strlen(desc) : 0;
5542 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5543 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5544 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5546 usr->logon_time = *logon_time; /* all zeros */
5547 usr->logoff_time = *logoff_time; /* all zeros */
5548 usr->kickoff_time = *kickoff_time; /* all zeros */
5549 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5550 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5551 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5553 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5554 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5555 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5556 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5557 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5558 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5559 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5560 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5561 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5562 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5564 ZERO_STRUCT(usr->nt_pwd);
5565 ZERO_STRUCT(usr->lm_pwd);
5567 usr->user_rid = user_rid; /* 0x0000 0000 */
5568 usr->group_rid = group_rid;
5569 usr->acb_info = acb_info;
5570 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5572 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5573 usr->ptr_logon_hrs = hrs ? 1 : 0;
5575 if (nt_time_is_zero(pass_must_change_time)) {
5576 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5578 usr->passmustchange=0;
5581 ZERO_STRUCT(usr->padding1);
5582 ZERO_STRUCT(usr->padding2);
5584 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5586 memcpy(usr->pass, newpass, sizeof(usr->pass));
5588 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5589 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5590 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5591 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5592 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5593 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5594 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5595 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5596 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5597 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5599 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5602 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5605 /*******************************************************************
5606 reads or writes a structure.
5607 ********************************************************************/
5609 static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
5610 prs_struct *ps, int depth)
5615 prs_debug(ps, depth, desc, "sam_io_user_info23");
5621 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5623 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5625 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5627 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5629 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5631 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5634 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5636 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5638 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5640 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5642 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5644 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5646 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5648 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5650 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5652 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5655 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5657 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5660 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5662 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5664 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5667 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5669 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5673 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5676 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5679 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5681 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5683 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5687 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5690 /* here begins pointed-to data */
5692 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5695 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5698 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5701 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5704 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5707 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5710 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5713 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5716 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5719 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5722 /* ok, this is only guess-work (as usual) */
5723 if (usr->ptr_logon_hrs) {
5724 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5726 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5728 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5730 } else if (UNMARSHALLING(ps)) {
5738 /*******************************************************************
5739 reads or writes a structure.
5740 NB. This structure is *definately* incorrect. It's my best guess
5741 currently for W2K SP2. The password field is encrypted in a different
5742 way than normal... And there are definately other problems. JRA.
5743 ********************************************************************/
5745 static BOOL sam_io_user_info25(char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5750 prs_debug(ps, depth, desc, "sam_io_user_info25");
5756 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5758 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5760 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5762 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5764 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5766 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5769 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5771 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5773 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5775 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5777 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5779 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5781 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5783 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5785 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5787 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5790 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5792 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5795 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5797 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5799 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5802 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5805 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5808 /* here begins pointed-to data */
5810 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5813 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5816 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5819 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5822 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5825 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5828 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5831 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5834 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5837 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5840 #if 0 /* JRA - unknown... */
5841 /* ok, this is only guess-work (as usual) */
5842 if (usr->ptr_logon_hrs) {
5843 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5845 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5847 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5849 } else if (UNMARSHALLING(ps)) {
5859 /*************************************************************************
5860 init_sam_user_info21W
5862 unknown_3 = 0x00ff ffff
5863 unknown_5 = 0x0002 0000
5864 unknown_6 = 0x0000 04ec
5866 *************************************************************************/
5868 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5869 NTTIME * logon_time,
5870 NTTIME * logoff_time,
5871 NTTIME * kickoff_time,
5872 NTTIME * pass_last_set_time,
5873 NTTIME * pass_can_change_time,
5874 NTTIME * pass_must_change_time,
5893 uint32 unknown_5, uint32 unknown_6)
5895 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5896 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5897 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5898 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5899 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5900 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5901 int len_description = desc != NULL ? desc->uni_str_len : 0;
5902 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5903 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5904 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5906 usr->logon_time = *logon_time;
5907 usr->logoff_time = *logoff_time;
5908 usr->kickoff_time = *kickoff_time;
5909 usr->pass_last_set_time = *pass_last_set_time;
5910 usr->pass_can_change_time = *pass_can_change_time;
5911 usr->pass_must_change_time = *pass_must_change_time;
5913 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5914 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5915 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5916 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5917 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5918 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5919 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5920 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5921 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5922 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5924 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5925 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5927 usr->user_rid = user_rid;
5928 usr->group_rid = group_rid;
5929 usr->acb_info = acb_info;
5930 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5932 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5933 usr->ptr_logon_hrs = hrs ? 1 : 0;
5934 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5936 if (nt_time_is_zero(pass_must_change_time)) {
5937 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5939 usr->passmustchange=0;
5943 ZERO_STRUCT(usr->padding1);
5944 ZERO_STRUCT(usr->padding2);
5946 copy_unistr2(&usr->uni_user_name, user_name);
5947 copy_unistr2(&usr->uni_full_name, full_name);
5948 copy_unistr2(&usr->uni_home_dir, home_dir);
5949 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5950 copy_unistr2(&usr->uni_logon_script, log_scr);
5951 copy_unistr2(&usr->uni_profile_path, prof_path);
5952 copy_unistr2(&usr->uni_acct_desc, desc);
5953 copy_unistr2(&usr->uni_workstations, wkstas);
5954 copy_unistr2(&usr->uni_unknown_str, unk_str);
5955 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5957 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5960 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5963 /*************************************************************************
5964 init_sam_user_info21
5966 unknown_3 = 0x00ff ffff
5967 unknown_5 = 0x0002 0000
5968 unknown_6 = 0x0000 04ec
5970 *************************************************************************/
5972 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5974 NTTIME logon_time, logoff_time, kickoff_time,
5975 pass_last_set_time, pass_can_change_time,
5976 pass_must_change_time;
5978 int len_user_name, len_full_name, len_home_dir,
5979 len_dir_drive, len_logon_script, len_profile_path,
5980 len_description, len_workstations, len_unknown_str,
5983 const char* user_name = pdb_get_username(pw);
5984 const char* full_name = pdb_get_fullname(pw);
5985 const char* home_dir = pdb_get_homedir(pw);
5986 const char* dir_drive = pdb_get_dir_drive(pw);
5987 const char* logon_script = pdb_get_logon_script(pw);
5988 const char* profile_path = pdb_get_profile_path(pw);
5989 const char* description = pdb_get_acct_desc(pw);
5990 const char* workstations = pdb_get_workstations(pw);
5991 const char* munged_dial = pdb_get_munged_dial(pw);
5994 const DOM_SID *user_sid;
5997 const DOM_SID *group_sid;
5999 len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
6000 len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
6001 len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
6002 len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
6003 len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
6004 len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
6005 len_description = description != NULL ? strlen(description )+1 : 0;
6006 len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
6007 len_unknown_str = 0;
6008 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6011 /* Create NTTIME structs */
6012 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6013 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6014 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6015 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6016 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6017 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6019 /* structure assignment */
6020 usr->logon_time = logon_time;
6021 usr->logoff_time = logoff_time;
6022 usr->kickoff_time = kickoff_time;
6023 usr->pass_last_set_time = pass_last_set_time;
6024 usr->pass_can_change_time = pass_can_change_time;
6025 usr->pass_must_change_time = pass_must_change_time;
6027 init_uni_hdr(&usr->hdr_user_name, len_user_name);
6028 init_uni_hdr(&usr->hdr_full_name, len_full_name);
6029 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
6030 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
6031 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
6032 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
6033 init_uni_hdr(&usr->hdr_acct_desc, len_description);
6034 init_uni_hdr(&usr->hdr_workstations, len_workstations);
6035 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
6036 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6038 ZERO_STRUCT(usr->nt_pwd);
6039 ZERO_STRUCT(usr->lm_pwd);
6041 user_sid = pdb_get_user_sid(pw);
6043 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6044 fstring user_sid_string;
6045 fstring domain_sid_string;
6046 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6047 "the domain sid %s. Failing operation.\n",
6049 sid_to_string(user_sid_string, user_sid),
6050 sid_to_string(domain_sid_string, domain_sid)));
6051 return NT_STATUS_UNSUCCESSFUL;
6054 group_sid = pdb_get_group_sid(pw);
6056 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6057 fstring group_sid_string;
6058 fstring domain_sid_string;
6059 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6060 "which conflicts with the domain sid %s. Failing operation.\n",
6062 sid_to_string(group_sid_string, group_sid),
6063 sid_to_string(domain_sid_string, domain_sid)));
6064 return NT_STATUS_UNSUCCESSFUL;
6067 usr->user_rid = user_rid;
6068 usr->group_rid = group_rid;
6069 usr->acb_info = pdb_get_acct_ctrl(pw);
6072 Look at a user on a real NT4 PDC with usrmgr, press
6073 'ok'. Then you will see that unknown_3 is set to
6074 0x08f827fa. Look at the user immediately after that again,
6075 and you will see that 0x00fffff is returned. This solves
6076 the problem that you get access denied after having looked
6080 usr->unknown_3 = 0x00ffffff;
6082 usr->logon_divs = pdb_get_logon_divs(pw);
6083 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6084 usr->unknown_5 = pdb_get_unknown_5(pw); /* 0x0002 0000 */
6086 if (pdb_get_pass_must_change_time(pw) == 0) {
6087 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6089 usr->passmustchange=0;
6093 ZERO_STRUCT(usr->padding1);
6094 ZERO_STRUCT(usr->padding2);
6096 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
6097 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
6098 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
6099 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
6100 init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
6101 init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
6102 init_unistr2(&usr->uni_acct_desc, description, len_description);
6103 init_unistr2(&usr->uni_workstations, workstations, len_workstations);
6104 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
6105 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6107 usr->unknown_6 = pdb_get_unknown_6(pw);
6110 if (pdb_get_hours(pw)) {
6111 usr->logon_hrs.len = pdb_get_hours_len(pw);
6112 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6114 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6116 return NT_STATUS_OK;
6119 /*******************************************************************
6120 reads or writes a structure.
6121 ********************************************************************/
6123 static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
6124 prs_struct *ps, int depth)
6129 prs_debug(ps, depth, desc, "sam_io_user_info21");
6135 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6137 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6139 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6141 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6143 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6145 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6148 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6150 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6152 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6154 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6156 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6158 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6160 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6162 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6164 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6166 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6169 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6171 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6174 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6176 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6178 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6181 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
6183 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6187 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6190 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
6193 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6195 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6197 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6200 /* here begins pointed-to data */
6202 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6204 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6206 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6208 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6210 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6212 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6214 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6216 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6218 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6220 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6223 /* ok, this is only guess-work (as usual) */
6224 if (usr->ptr_logon_hrs) {
6227 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6229 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6231 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6233 } else if (UNMARSHALLING(ps)) {
6241 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6243 int len_munged_dial;
6244 const char* munged_dial = pdb_get_munged_dial(pw);
6246 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6247 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6248 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6252 /*******************************************************************
6253 reads or writes a structure.
6254 ********************************************************************/
6256 static BOOL sam_io_user_info20(char *desc, SAM_USER_INFO_20 *usr,
6257 prs_struct *ps, int depth)
6262 prs_debug(ps, depth, desc, "sam_io_user_info20");
6268 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6271 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6277 /*******************************************************************
6278 inits a SAM_USERINFO_CTR structure.
6279 ********************************************************************/
6281 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6282 uint16 switch_value,
6283 SAM_USER_INFO_21 * usr)
6285 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6287 ctr->switch_value = switch_value;
6288 ctr->info.id = NULL;
6290 switch (switch_value) {
6292 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
6293 if (ctr->info.id10 == NULL)
6294 return NT_STATUS_NO_MEMORY;
6296 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6299 /* whoops - got this wrong. i think. or don't understand what's happening. */
6303 info = (void *)&id11;
6305 expire.low = 0xffffffff;
6306 expire.high = 0x7fffffff;
6308 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
6309 init_sam_user_info11(ctr->info.id11, &expire,
6310 "BROOKFIELDS$", /* name */
6311 0x03ef, /* user rid */
6312 0x201, /* group rid */
6313 0x0080); /* acb info */
6319 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
6320 if (ctr->info.id12 == NULL)
6321 return NT_STATUS_NO_MEMORY;
6323 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6327 SAM_USER_INFO_21 *cusr;
6328 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
6329 ctr->info.id21 = cusr;
6330 if (ctr->info.id21 == NULL)
6331 return NT_STATUS_NO_MEMORY;
6332 memcpy(cusr, usr, sizeof(*usr));
6333 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6334 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6338 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6339 return NT_STATUS_INVALID_INFO_CLASS;
6342 return NT_STATUS_OK;
6345 /*******************************************************************
6346 inits a SAM_USERINFO_CTR structure.
6347 ********************************************************************/
6349 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
6350 uint16 switch_value, void *info)
6352 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6354 ctr->switch_value = switch_value;
6355 ctr->info.id = info;
6357 switch (switch_value) {
6359 SamOEMhash(ctr->info.id24->pass, sess_key, 516);
6360 dump_data(100, (char *)sess_key, 16);
6361 dump_data(100, (char *)ctr->info.id24->pass, 516);
6364 SamOEMhash(ctr->info.id23->pass, sess_key, 516);
6365 dump_data(100, (char *)sess_key, 16);
6366 dump_data(100, (char *)ctr->info.id23->pass, 516);
6369 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6373 /*******************************************************************
6374 reads or writes a structure.
6375 ********************************************************************/
6377 static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR **ppctr,
6378 prs_struct *ps, int depth)
6381 SAM_USERINFO_CTR *ctr;
6383 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6386 if (UNMARSHALLING(ps)) {
6387 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
6395 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6397 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6404 switch (ctr->switch_value) {
6406 if (UNMARSHALLING(ps))
6407 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
6408 if (ctr->info.id10 == NULL) {
6409 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6412 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6415 if (UNMARSHALLING(ps))
6416 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
6418 if (ctr->info.id11 == NULL) {
6419 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6422 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6425 if (UNMARSHALLING(ps))
6426 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
6428 if (ctr->info.id12 == NULL) {
6429 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6432 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6435 if (UNMARSHALLING(ps))
6436 ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20));
6438 if (ctr->info.id20 == NULL) {
6439 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6442 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6445 if (UNMARSHALLING(ps))
6446 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
6448 if (ctr->info.id21 == NULL) {
6449 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6452 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6455 if (UNMARSHALLING(ps))
6456 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
6458 if (ctr->info.id23 == NULL) {
6459 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6462 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6465 if (UNMARSHALLING(ps))
6466 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
6468 if (ctr->info.id24 == NULL) {
6469 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6472 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6475 if (UNMARSHALLING(ps))
6476 ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25));
6478 if (ctr->info.id25 == NULL) {
6479 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6482 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6485 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6493 /*******************************************************************
6494 inits a SAMR_R_QUERY_USERINFO structure.
6495 ********************************************************************/
6497 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6498 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6500 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6505 if (NT_STATUS_IS_OK(status)) {
6510 r_u->status = status; /* return status */
6513 /*******************************************************************
6514 reads or writes a structure.
6515 ********************************************************************/
6517 BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
6518 prs_struct *ps, int depth)
6523 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6529 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6532 if (r_u->ptr != 0) {
6533 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6539 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6545 /*******************************************************************
6546 inits a SAMR_Q_SET_USERINFO structure.
6547 ********************************************************************/
6549 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6550 POLICY_HND *hnd, unsigned char sess_key[16],
6551 uint16 switch_value, void *info)
6553 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6556 q_u->switch_value = switch_value;
6557 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6560 /*******************************************************************
6561 reads or writes a structure.
6562 ********************************************************************/
6564 BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
6565 prs_struct *ps, int depth)
6570 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6576 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6578 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6580 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6586 /*******************************************************************
6587 inits a SAMR_R_SET_USERINFO structure.
6588 ********************************************************************/
6590 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6592 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6594 r_u->status = status; /* return status */
6597 /*******************************************************************
6598 reads or writes a structure.
6599 ********************************************************************/
6601 BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
6602 prs_struct *ps, int depth)
6607 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6613 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6619 /*******************************************************************
6620 inits a SAMR_Q_SET_USERINFO2 structure.
6621 ********************************************************************/
6623 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6624 POLICY_HND *hnd, unsigned char sess_key[16],
6625 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6627 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6630 q_u->switch_value = switch_value;
6633 if (q_u->ctr != NULL)
6634 q_u->ctr->switch_value = switch_value;
6636 switch (switch_value) {
6638 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16);
6639 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16);
6640 dump_data(100, (char *)sess_key, 16);
6641 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6642 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6647 /*******************************************************************
6648 reads or writes a structure.
6649 ********************************************************************/
6651 BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6652 prs_struct *ps, int depth)
6657 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6663 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6666 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6668 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6674 /*******************************************************************
6675 inits a SAMR_R_SET_USERINFO2 structure.
6676 ********************************************************************/
6678 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6680 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6682 r_u->status = status; /* return status */
6685 /*******************************************************************
6686 reads or writes a structure.
6687 ********************************************************************/
6689 BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
6690 prs_struct *ps, int depth)
6695 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6701 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6707 /*******************************************************************
6708 inits a SAMR_Q_CONNECT structure.
6709 ********************************************************************/
6711 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6712 char *srv_name, uint32 access_mask)
6714 int len_srv_name = strlen(srv_name);
6716 DEBUG(5, ("init_samr_q_connect\n"));
6718 /* make PDC server name \\server */
6719 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6720 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6722 /* example values: 0x0000 0002 */
6723 q_u->access_mask = access_mask;
6726 /*******************************************************************
6727 reads or writes a structure.
6728 ********************************************************************/
6730 BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
6731 prs_struct *ps, int depth)
6736 prs_debug(ps, depth, desc, "samr_io_q_connect");
6742 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6744 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6749 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6755 /*******************************************************************
6756 reads or writes a structure.
6757 ********************************************************************/
6759 BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
6760 prs_struct *ps, int depth)
6765 prs_debug(ps, depth, desc, "samr_io_r_connect");
6771 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6774 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6780 /*******************************************************************
6781 inits a SAMR_Q_CONNECT4 structure.
6782 ********************************************************************/
6784 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6785 char *srv_name, uint32 access_mask)
6787 int len_srv_name = strlen(srv_name);
6789 DEBUG(5, ("init_samr_q_connect\n"));
6791 /* make PDC server name \\server */
6792 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6793 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6795 /* Only value we've seen, possibly an address type ? */
6798 /* example values: 0x0000 0002 */
6799 q_u->access_mask = access_mask;
6802 /*******************************************************************
6803 reads or writes a structure.
6804 ********************************************************************/
6806 BOOL samr_io_q_connect4(char *desc, SAMR_Q_CONNECT4 * q_u,
6807 prs_struct *ps, int depth)
6812 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6818 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6820 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6825 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6827 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6833 /*******************************************************************
6834 reads or writes a structure.
6835 ********************************************************************/
6837 BOOL samr_io_r_connect4(char *desc, SAMR_R_CONNECT4 * r_u,
6838 prs_struct *ps, int depth)
6843 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6849 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6852 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6858 /*******************************************************************
6859 inits a SAMR_Q_CONNECT_ANON structure.
6860 ********************************************************************/
6862 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6864 DEBUG(5, ("init_samr_q_connect_anon\n"));
6867 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6868 q_u->unknown_1 = 0x01;
6869 q_u->access_mask = 0x20;
6872 /*******************************************************************
6873 reads or writes a structure.
6874 ********************************************************************/
6876 BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
6877 prs_struct *ps, int depth)
6882 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6888 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6890 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6892 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6894 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6900 /*******************************************************************
6901 reads or writes a structure.
6902 ********************************************************************/
6904 BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
6905 prs_struct *ps, int depth)
6910 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6916 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6919 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6925 /*******************************************************************
6926 inits a SAMR_Q_GET_DOM_PWINFO structure.
6927 ********************************************************************/
6929 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6932 int len_srv_name = strlen(srv_name);
6934 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6937 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6938 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6941 /*******************************************************************
6942 reads or writes a structure.
6943 ********************************************************************/
6945 BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6946 prs_struct *ps, int depth)
6951 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6957 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6959 if (q_u->ptr != 0) {
6960 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6962 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6969 /*******************************************************************
6970 reads or writes a structure.
6971 ********************************************************************/
6973 BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6974 prs_struct *ps, int depth)
6979 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6986 * We need 16 bytes here according to tests. Don't know
6987 * what they are, but the length is important for the singing
6990 if(!prs_uint32("unk_0", ps, depth, &r_u->unk_0))
6992 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
6994 if(!prs_uint32("unk_2", ps, depth, &r_u->unk_2))
6997 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7003 /*******************************************************************
7004 make a SAMR_ENC_PASSWD structure.
7005 ********************************************************************/
7007 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
7015 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7019 /*******************************************************************
7020 reads or writes a SAMR_ENC_PASSWD structure.
7021 ********************************************************************/
7023 BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
7024 prs_struct *ps, int depth)
7029 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7035 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7038 if (pwd->ptr != 0) {
7039 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7046 /*******************************************************************
7047 inits a SAMR_ENC_HASH structure.
7048 ********************************************************************/
7050 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
7058 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7062 /*******************************************************************
7063 reads or writes a SAMR_ENC_HASH structure.
7064 ********************************************************************/
7066 BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
7067 prs_struct *ps, int depth)
7072 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7078 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7080 if (hsh->ptr != 0) {
7081 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7088 /*******************************************************************
7089 inits a SAMR_R_GET_DOM_PWINFO structure.
7090 ********************************************************************/
7092 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7093 char *dest_host, char *user_name,
7094 char nt_newpass[516],
7095 uchar nt_oldhash[16],
7096 char lm_newpass[516],
7097 uchar lm_oldhash[16])
7099 int len_dest_host = strlen(dest_host);
7100 int len_user_name = strlen(user_name);
7102 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7105 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
7106 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
7107 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
7108 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
7110 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7111 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7113 q_u->unknown = 0x01;
7115 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7116 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7119 /*******************************************************************
7120 reads or writes a structure.
7121 ********************************************************************/
7123 BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7124 prs_struct *ps, int depth)
7129 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7135 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7138 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7140 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7145 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7147 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7150 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7152 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7155 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7158 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7160 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7166 /*******************************************************************
7167 inits a SAMR_R_CHGPASSWD_USER structure.
7168 ********************************************************************/
7170 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7172 DEBUG(5, ("init_r_chgpasswd_user\n"));
7174 r_u->status = status;
7177 /*******************************************************************
7178 reads or writes a structure.
7179 ********************************************************************/
7181 BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7182 prs_struct *ps, int depth)
7187 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7193 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7199 /*******************************************************************
7200 reads or writes a structure.
7201 ********************************************************************/
7203 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7204 POLICY_HND *domain_pol, uint16 switch_value)
7206 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7208 q_u->domain_pol = *domain_pol;
7209 q_u->switch_value = switch_value;
7212 /*******************************************************************
7213 reads or writes a structure.
7214 ********************************************************************/
7216 BOOL samr_io_q_unknown_2e(char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7217 prs_struct *ps, int depth)
7222 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7228 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7231 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7237 /*******************************************************************
7238 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7239 ********************************************************************/
7241 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7242 uint16 switch_value, SAM_UNK_CTR * ctr,
7245 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7248 r_u->switch_value = 0;
7249 r_u->status = status; /* return status */
7251 if (NT_STATUS_IS_OK(status)) {
7252 r_u->switch_value = switch_value;
7258 /*******************************************************************
7259 reads or writes a structure.
7260 ********************************************************************/
7262 BOOL samr_io_r_samr_unknown_2e(char *desc, SAMR_R_UNKNOWN_2E * r_u,
7263 prs_struct *ps, int depth)
7268 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7274 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7277 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7278 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7283 switch (r_u->switch_value) {
7285 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7289 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7293 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7297 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7301 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7305 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7309 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7313 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7314 r_u->switch_value));
7315 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7323 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7330 /*******************************************************************
7331 reads or writes a structure.
7332 ********************************************************************/
7334 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7335 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7337 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7339 q_u->domain_pol = *domain_pol;
7340 q_u->switch_value0 = switch_value;
7342 q_u->switch_value = switch_value;
7347 /*******************************************************************
7348 reads or writes a structure.
7349 ********************************************************************/
7351 BOOL samr_io_q_set_domain_info(char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7352 prs_struct *ps, int depth)
7357 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7363 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7366 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7369 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7375 if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL)
7378 switch (q_u->switch_value) {
7381 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7385 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7389 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7393 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7397 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7401 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7405 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7409 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7410 q_u->switch_value));
7417 /*******************************************************************
7418 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7419 ********************************************************************/
7421 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7423 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7425 r_u->status = status; /* return status */
7428 /*******************************************************************
7429 reads or writes a structure.
7430 ********************************************************************/
7432 BOOL samr_io_r_set_domain_info(char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7433 prs_struct *ps, int depth)
7438 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7444 if(!prs_ntstatus("status", ps, depth, &r_u->status))