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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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,
1451 uint32 max_entries, uint32 max_size)
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 = max_size;
1464 /*******************************************************************
1465 reads or writes a structure.
1466 ********************************************************************/
1468 BOOL samr_io_q_query_dispinfo(const 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, SAM_ACCOUNT *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];
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(const 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, SAM_ACCOUNT *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];
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(const 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, DOMAIN_GRP *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];
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(const 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, SAM_ACCOUNT *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];
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(const 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, DOMAIN_GRP *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];
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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4598 prs_struct *ps, int depth)
4605 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4611 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4613 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4616 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4617 uint32 *ptr_sid = NULL;
4619 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4622 ptr_sid = talloc(ps->mem_ctx, sizeof(uint32) * r_u->num_sids1);
4627 for (i = 0; i < r_u->num_sids1; i++) {
4629 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4633 if (UNMARSHALLING(ps)) {
4634 r_u->sid = talloc(ps->mem_ctx, r_u->num_sids1 * sizeof(DOM_SID2));
4637 for (i = 0; i < r_u->num_sids1; i++) {
4638 if (ptr_sid[i] != 0) {
4639 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4647 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4653 /*******************************************************************
4654 inits a SAMR_Q_LOOKUP_NAMES structure.
4655 ********************************************************************/
4657 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4658 POLICY_HND *pol, uint32 flags,
4659 uint32 num_names, const char **name)
4663 DEBUG(5, ("init_samr_q_lookup_names\n"));
4667 q_u->num_names1 = num_names;
4670 q_u->num_names2 = num_names;
4672 if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR))))
4673 return NT_STATUS_NO_MEMORY;
4675 if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2))))
4676 return NT_STATUS_NO_MEMORY;
4678 for (i = 0; i < num_names; i++) {
4679 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4680 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4681 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4684 return NT_STATUS_OK;
4687 /*******************************************************************
4688 reads or writes a structure.
4689 ********************************************************************/
4691 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4692 prs_struct *ps, int depth)
4699 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4702 if (UNMARSHALLING(ps))
4708 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4711 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4713 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4715 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4717 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4720 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4721 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4723 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4725 if (!q_u->hdr_name || !q_u->uni_name)
4729 for (i = 0; i < q_u->num_names2; i++) {
4730 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4734 for (i = 0; i < q_u->num_names2; i++) {
4735 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4742 /*******************************************************************
4743 inits a SAMR_R_LOOKUP_NAMES structure.
4744 ********************************************************************/
4746 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4748 uint32 *rid, uint32 *type,
4751 DEBUG(5, ("init_samr_r_lookup_names\n"));
4753 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4756 r_u->num_types1 = num_rids;
4758 r_u->num_types2 = num_rids;
4760 r_u->num_rids1 = num_rids;
4762 r_u->num_rids2 = num_rids;
4764 if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4765 return NT_STATUS_NO_MEMORY;
4766 if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4767 return NT_STATUS_NO_MEMORY;
4769 if (!r_u->rids || !r_u->types)
4772 for (i = 0; i < num_rids; i++) {
4773 r_u->rids[i] = rid[i];
4774 r_u->types[i] = type[i];
4779 r_u->num_types1 = 0;
4781 r_u->num_types2 = 0;
4791 r_u->status = status;
4793 return NT_STATUS_OK;
4796 /*******************************************************************
4797 reads or writes a structure.
4798 ********************************************************************/
4800 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4801 prs_struct *ps, int depth)
4809 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4812 if (UNMARSHALLING(ps))
4818 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4820 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4823 if (r_u->ptr_rids != 0) {
4824 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4827 if (r_u->num_rids2 != r_u->num_rids1) {
4832 if (UNMARSHALLING(ps))
4833 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4836 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4840 for (i = 0; i < r_u->num_rids2; i++) {
4841 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4842 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4847 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4849 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4852 if (r_u->ptr_types != 0) {
4853 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4856 if (r_u->num_types2 != r_u->num_types1) {
4861 if (UNMARSHALLING(ps))
4862 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4865 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4869 for (i = 0; i < r_u->num_types2; i++) {
4870 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4871 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4876 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4882 /*******************************************************************
4883 inits a SAMR_Q_DELETE_DOM_USER structure.
4884 ********************************************************************/
4886 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4889 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4891 q_c->user_pol = *hnd;
4894 /*******************************************************************
4895 reads or writes a structure.
4896 ********************************************************************/
4898 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4899 prs_struct *ps, int depth)
4904 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4910 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4916 /*******************************************************************
4917 reads or writes a structure.
4918 ********************************************************************/
4920 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4921 prs_struct *ps, int depth)
4926 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4932 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4934 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4940 /*******************************************************************
4941 reads or writes a structure.
4942 ********************************************************************/
4944 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4946 uint32 access_mask, uint32 rid)
4948 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4950 q_u->domain_pol = *pol;
4951 q_u->access_mask = access_mask;
4952 q_u->user_rid = rid;
4955 /*******************************************************************
4956 reads or writes a structure.
4957 ********************************************************************/
4959 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4960 prs_struct *ps, int depth)
4965 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4971 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4974 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4976 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4982 /*******************************************************************
4983 reads or writes a structure.
4984 ********************************************************************/
4986 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4987 prs_struct *ps, int depth)
4992 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4998 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5001 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5008 /*******************************************************************
5009 reads or writes a structure.
5010 ********************************************************************/
5012 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5015 uint32 acb_info, uint32 access_mask)
5018 len_name = strlen(name);
5020 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5022 q_u->domain_pol = *pol;
5024 init_uni_hdr(&q_u->hdr_name, len_name);
5025 init_unistr2(&q_u->uni_name, name, len_name);
5027 q_u->acb_info = acb_info;
5028 q_u->access_mask = access_mask;
5031 /*******************************************************************
5032 reads or writes a structure.
5033 ********************************************************************/
5035 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5036 prs_struct *ps, int depth)
5041 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5047 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5050 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5052 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5057 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5059 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5065 /*******************************************************************
5066 reads or writes a structure.
5067 ********************************************************************/
5069 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5070 prs_struct *ps, int depth)
5075 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5081 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5084 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5086 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5088 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5094 /*******************************************************************
5095 inits a SAMR_Q_QUERY_USERINFO structure.
5096 ********************************************************************/
5098 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5099 POLICY_HND *hnd, uint16 switch_value)
5101 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5104 q_u->switch_value = switch_value;
5107 /*******************************************************************
5108 reads or writes a structure.
5109 ********************************************************************/
5111 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5112 prs_struct *ps, int depth)
5117 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5123 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5126 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5132 /*******************************************************************
5133 reads or writes a LOGON_HRS structure.
5134 ********************************************************************/
5136 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5137 prs_struct *ps, int depth)
5142 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5148 if(!prs_uint32("len ", ps, depth, &hrs->len))
5151 if (hrs->len > sizeof(hrs->hours)) {
5152 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5153 hrs->len = sizeof(hrs->hours);
5156 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5162 /*******************************************************************
5163 inits a SAM_USER_INFO_12 structure.
5164 ********************************************************************/
5166 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5167 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5169 DEBUG(5, ("init_sam_user_info12\n"));
5171 usr->lm_pwd_active =
5172 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5173 usr->nt_pwd_active =
5174 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5177 /*******************************************************************
5178 reads or writes a structure.
5179 ********************************************************************/
5181 static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u,
5182 prs_struct *ps, int depth)
5187 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5193 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5195 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5198 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5200 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5206 /*******************************************************************
5207 inits a SAM_USER_INFO_10 structure.
5208 ********************************************************************/
5210 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5212 DEBUG(5, ("init_sam_user_info10\n"));
5214 usr->acb_info = acb_info;
5217 /*******************************************************************
5218 reads or writes a structure.
5219 ********************************************************************/
5221 static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr,
5222 prs_struct *ps, int depth)
5227 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5233 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5239 /*******************************************************************
5240 inits a SAM_USER_INFO_11 structure.
5241 ********************************************************************/
5243 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5246 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5250 DEBUG(5, ("init_sam_user_info11\n"));
5252 len_mach_acct = strlen(mach_acct);
5254 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
5255 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5257 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
5258 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5260 usr->ptr_1 = 1; /* pointer */
5261 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5262 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5264 usr->ptr_2 = 1; /* pointer */
5265 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5267 usr->ptr_3 = 1; /* pointer */
5268 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5270 usr->rid_user = rid_user;
5271 usr->rid_group = rid_group;
5273 usr->acct_ctrl = acct_ctrl;
5274 usr->unknown_3 = 0x0000;
5276 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5277 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5279 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5280 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5282 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
5285 /*******************************************************************
5286 reads or writes a structure.
5287 ********************************************************************/
5289 static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr,
5290 prs_struct *ps, int depth)
5295 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5301 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5304 if(!smb_io_time("time", &usr->expiry, ps, depth))
5307 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5310 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5313 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5316 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5318 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5321 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5324 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5326 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5329 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5331 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5334 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5336 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5338 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5340 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5342 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5344 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5347 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5350 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5353 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5359 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5365 /*************************************************************************
5368 unknown_3 = 0x09f8 27fa
5369 unknown_5 = 0x0001 0000
5370 unknown_6 = 0x0000 04ec
5372 *************************************************************************/
5374 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5376 DEBUG(10, ("init_sam_user_info24:\n"));
5377 memcpy(usr->pass, newpass, sizeof(usr->pass));
5378 usr->pw_len = pw_len;
5381 /*******************************************************************
5382 reads or writes a structure.
5383 ********************************************************************/
5385 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5386 prs_struct *ps, int depth)
5391 prs_debug(ps, depth, desc, "sam_io_user_info24");
5397 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5401 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5402 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5411 /*************************************************************************
5412 init_sam_user_info23
5414 unknown_3 = 0x09f8 27fa
5415 unknown_5 = 0x0001 0000
5416 unknown_6 = 0x0000 04ec
5418 *************************************************************************/
5420 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5421 NTTIME * logoff_time, /* all zeros */
5422 NTTIME * kickoff_time, /* all zeros */
5423 NTTIME * pass_last_set_time, /* all zeros */
5424 NTTIME * pass_can_change_time, /* all zeros */
5425 NTTIME * pass_must_change_time, /* all zeros */
5436 uint32 user_rid, /* 0x0000 0000 */
5443 char newpass[516], uint32 unknown_6)
5445 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5446 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5447 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5448 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5449 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5450 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5451 int len_description = desc != NULL ? desc->uni_str_len : 0;
5452 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5453 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5454 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5456 usr->logon_time = *logon_time; /* all zeros */
5457 usr->logoff_time = *logoff_time; /* all zeros */
5458 usr->kickoff_time = *kickoff_time; /* all zeros */
5459 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5460 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5461 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5463 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5464 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5465 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5466 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5467 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5468 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5469 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5470 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5471 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5472 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5474 ZERO_STRUCT(usr->nt_pwd);
5475 ZERO_STRUCT(usr->lm_pwd);
5477 usr->user_rid = user_rid; /* 0x0000 0000 */
5478 usr->group_rid = group_rid;
5479 usr->acb_info = acb_info;
5480 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5482 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5483 usr->ptr_logon_hrs = hrs ? 1 : 0;
5485 if (nt_time_is_zero(pass_must_change_time)) {
5486 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5488 usr->passmustchange=0;
5492 ZERO_STRUCT(usr->padding1);
5493 ZERO_STRUCT(usr->padding2);
5495 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5497 memcpy(usr->pass, newpass, sizeof(usr->pass));
5499 copy_unistr2(&usr->uni_user_name, user_name);
5500 copy_unistr2(&usr->uni_full_name, full_name);
5501 copy_unistr2(&usr->uni_home_dir, home_dir);
5502 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5503 copy_unistr2(&usr->uni_logon_script, log_scr);
5504 copy_unistr2(&usr->uni_profile_path, prof_path);
5505 copy_unistr2(&usr->uni_acct_desc, desc);
5506 copy_unistr2(&usr->uni_workstations, wkstas);
5507 copy_unistr2(&usr->uni_unknown_str, unk_str);
5508 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5510 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5513 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5516 /*************************************************************************
5517 init_sam_user_info23
5519 unknown_3 = 0x09f8 27fa
5520 unknown_5 = 0x0001 0000
5521 unknown_6 = 0x0000 04ec
5523 *************************************************************************/
5525 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5526 NTTIME * logoff_time, /* all zeros */
5527 NTTIME * kickoff_time, /* all zeros */
5528 NTTIME * pass_last_set_time, /* all zeros */
5529 NTTIME * pass_can_change_time, /* all zeros */
5530 NTTIME * pass_must_change_time, /* all zeros */
5531 char *user_name, /* NULL */
5533 char *home_dir, char *dir_drive, char *log_scr,
5534 char *prof_path, const char *desc, char *wkstas,
5535 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5536 uint32 group_rid, uint32 acb_info,
5537 uint32 unknown_3, uint16 logon_divs,
5538 LOGON_HRS * hrs, uint32 unknown_5,
5539 char newpass[516], uint32 unknown_6)
5541 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5542 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5543 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5544 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5545 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5546 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5547 int len_description = desc != NULL ? strlen(desc) : 0;
5548 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5549 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5550 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5552 usr->logon_time = *logon_time; /* all zeros */
5553 usr->logoff_time = *logoff_time; /* all zeros */
5554 usr->kickoff_time = *kickoff_time; /* all zeros */
5555 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5556 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5557 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5559 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5560 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5561 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5562 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5563 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5564 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5565 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5566 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5567 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5568 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5570 ZERO_STRUCT(usr->nt_pwd);
5571 ZERO_STRUCT(usr->lm_pwd);
5573 usr->user_rid = user_rid; /* 0x0000 0000 */
5574 usr->group_rid = group_rid;
5575 usr->acb_info = acb_info;
5576 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5578 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5579 usr->ptr_logon_hrs = hrs ? 1 : 0;
5581 if (nt_time_is_zero(pass_must_change_time)) {
5582 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5584 usr->passmustchange=0;
5587 ZERO_STRUCT(usr->padding1);
5588 ZERO_STRUCT(usr->padding2);
5590 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5592 memcpy(usr->pass, newpass, sizeof(usr->pass));
5594 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5595 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5596 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5597 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5598 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5599 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5600 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5601 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5602 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5603 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5605 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5608 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5611 /*******************************************************************
5612 reads or writes a structure.
5613 ********************************************************************/
5615 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5616 prs_struct *ps, int depth)
5621 prs_debug(ps, depth, desc, "sam_io_user_info23");
5627 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5629 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5631 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5633 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5635 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5637 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5640 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5642 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5644 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5646 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5648 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5650 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5652 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5654 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5656 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5658 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5661 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5663 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5666 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5668 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5670 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5673 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5675 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5679 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5682 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5685 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5687 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5689 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5693 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5696 /* here begins pointed-to data */
5698 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5701 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5704 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5707 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5710 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5713 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5716 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5719 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5722 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5725 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5728 /* ok, this is only guess-work (as usual) */
5729 if (usr->ptr_logon_hrs) {
5730 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5732 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5734 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5736 } else if (UNMARSHALLING(ps)) {
5744 /*******************************************************************
5745 reads or writes a structure.
5746 NB. This structure is *definately* incorrect. It's my best guess
5747 currently for W2K SP2. The password field is encrypted in a different
5748 way than normal... And there are definately other problems. JRA.
5749 ********************************************************************/
5751 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5756 prs_debug(ps, depth, desc, "sam_io_user_info25");
5762 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5764 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5766 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5768 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5770 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5772 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5775 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5777 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5779 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5781 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5783 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5785 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5787 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5789 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5791 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5793 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5796 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5798 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5801 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5803 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5805 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5808 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5811 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5814 /* here begins pointed-to data */
5816 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5819 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5822 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5825 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5828 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5831 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5834 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5837 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5840 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5843 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5846 #if 0 /* JRA - unknown... */
5847 /* ok, this is only guess-work (as usual) */
5848 if (usr->ptr_logon_hrs) {
5849 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5851 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5853 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5855 } else if (UNMARSHALLING(ps)) {
5865 /*************************************************************************
5866 init_sam_user_info21W
5868 unknown_3 = 0x00ff ffff
5869 unknown_5 = 0x0002 0000
5870 unknown_6 = 0x0000 04ec
5872 *************************************************************************/
5874 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5875 NTTIME * logon_time,
5876 NTTIME * logoff_time,
5877 NTTIME * kickoff_time,
5878 NTTIME * pass_last_set_time,
5879 NTTIME * pass_can_change_time,
5880 NTTIME * pass_must_change_time,
5899 uint32 unknown_5, uint32 unknown_6)
5901 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5902 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5903 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5904 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5905 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5906 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5907 int len_description = desc != NULL ? desc->uni_str_len : 0;
5908 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5909 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5910 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5912 usr->logon_time = *logon_time;
5913 usr->logoff_time = *logoff_time;
5914 usr->kickoff_time = *kickoff_time;
5915 usr->pass_last_set_time = *pass_last_set_time;
5916 usr->pass_can_change_time = *pass_can_change_time;
5917 usr->pass_must_change_time = *pass_must_change_time;
5919 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5920 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5921 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5922 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5923 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5924 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5925 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5926 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5927 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5928 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5930 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5931 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5933 usr->user_rid = user_rid;
5934 usr->group_rid = group_rid;
5935 usr->acb_info = acb_info;
5936 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5938 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5939 usr->ptr_logon_hrs = hrs ? 1 : 0;
5940 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5942 if (nt_time_is_zero(pass_must_change_time)) {
5943 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5945 usr->passmustchange=0;
5949 ZERO_STRUCT(usr->padding1);
5950 ZERO_STRUCT(usr->padding2);
5952 copy_unistr2(&usr->uni_user_name, user_name);
5953 copy_unistr2(&usr->uni_full_name, full_name);
5954 copy_unistr2(&usr->uni_home_dir, home_dir);
5955 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5956 copy_unistr2(&usr->uni_logon_script, log_scr);
5957 copy_unistr2(&usr->uni_profile_path, prof_path);
5958 copy_unistr2(&usr->uni_acct_desc, desc);
5959 copy_unistr2(&usr->uni_workstations, wkstas);
5960 copy_unistr2(&usr->uni_unknown_str, unk_str);
5961 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5963 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5966 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5969 /*************************************************************************
5970 init_sam_user_info21
5972 unknown_3 = 0x00ff ffff
5973 unknown_5 = 0x0002 0000
5974 unknown_6 = 0x0000 04ec
5976 *************************************************************************/
5978 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5980 NTTIME logon_time, logoff_time, kickoff_time,
5981 pass_last_set_time, pass_can_change_time,
5982 pass_must_change_time;
5984 int len_user_name, len_full_name, len_home_dir,
5985 len_dir_drive, len_logon_script, len_profile_path,
5986 len_description, len_workstations, len_unknown_str,
5989 const char* user_name = pdb_get_username(pw);
5990 const char* full_name = pdb_get_fullname(pw);
5991 const char* home_dir = pdb_get_homedir(pw);
5992 const char* dir_drive = pdb_get_dir_drive(pw);
5993 const char* logon_script = pdb_get_logon_script(pw);
5994 const char* profile_path = pdb_get_profile_path(pw);
5995 const char* description = pdb_get_acct_desc(pw);
5996 const char* workstations = pdb_get_workstations(pw);
5997 const char* munged_dial = pdb_get_munged_dial(pw);
6000 const DOM_SID *user_sid;
6003 const DOM_SID *group_sid;
6005 len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
6006 len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
6007 len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
6008 len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
6009 len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
6010 len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
6011 len_description = description != NULL ? strlen(description )+1 : 0;
6012 len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
6013 len_unknown_str = 0;
6014 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6017 /* Create NTTIME structs */
6018 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6019 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6020 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6021 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6022 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6023 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6025 /* structure assignment */
6026 usr->logon_time = logon_time;
6027 usr->logoff_time = logoff_time;
6028 usr->kickoff_time = kickoff_time;
6029 usr->pass_last_set_time = pass_last_set_time;
6030 usr->pass_can_change_time = pass_can_change_time;
6031 usr->pass_must_change_time = pass_must_change_time;
6033 init_uni_hdr(&usr->hdr_user_name, len_user_name);
6034 init_uni_hdr(&usr->hdr_full_name, len_full_name);
6035 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
6036 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
6037 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
6038 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
6039 init_uni_hdr(&usr->hdr_acct_desc, len_description);
6040 init_uni_hdr(&usr->hdr_workstations, len_workstations);
6041 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
6042 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6044 ZERO_STRUCT(usr->nt_pwd);
6045 ZERO_STRUCT(usr->lm_pwd);
6047 user_sid = pdb_get_user_sid(pw);
6049 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6050 fstring user_sid_string;
6051 fstring domain_sid_string;
6052 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6053 "the domain sid %s. Failing operation.\n",
6055 sid_to_string(user_sid_string, user_sid),
6056 sid_to_string(domain_sid_string, domain_sid)));
6057 return NT_STATUS_UNSUCCESSFUL;
6060 group_sid = pdb_get_group_sid(pw);
6062 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6063 fstring group_sid_string;
6064 fstring domain_sid_string;
6065 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6066 "which conflicts with the domain sid %s. Failing operation.\n",
6068 sid_to_string(group_sid_string, group_sid),
6069 sid_to_string(domain_sid_string, domain_sid)));
6070 return NT_STATUS_UNSUCCESSFUL;
6073 usr->user_rid = user_rid;
6074 usr->group_rid = group_rid;
6075 usr->acb_info = pdb_get_acct_ctrl(pw);
6078 Look at a user on a real NT4 PDC with usrmgr, press
6079 'ok'. Then you will see that unknown_3 is set to
6080 0x08f827fa. Look at the user immediately after that again,
6081 and you will see that 0x00fffff is returned. This solves
6082 the problem that you get access denied after having looked
6086 usr->unknown_3 = 0x00ffffff;
6088 usr->logon_divs = pdb_get_logon_divs(pw);
6089 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6090 usr->unknown_5 = pdb_get_unknown_5(pw); /* 0x0002 0000 */
6092 if (pdb_get_pass_must_change_time(pw) == 0) {
6093 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6095 usr->passmustchange=0;
6099 ZERO_STRUCT(usr->padding1);
6100 ZERO_STRUCT(usr->padding2);
6102 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
6103 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
6104 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
6105 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
6106 init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
6107 init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
6108 init_unistr2(&usr->uni_acct_desc, description, len_description);
6109 init_unistr2(&usr->uni_workstations, workstations, len_workstations);
6110 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
6111 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6113 usr->unknown_6 = pdb_get_unknown_6(pw);
6116 if (pdb_get_hours(pw)) {
6117 usr->logon_hrs.len = pdb_get_hours_len(pw);
6118 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6120 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6122 return NT_STATUS_OK;
6125 /*******************************************************************
6126 reads or writes a structure.
6127 ********************************************************************/
6129 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6130 prs_struct *ps, int depth)
6135 prs_debug(ps, depth, desc, "sam_io_user_info21");
6141 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6143 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6145 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6147 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6149 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6151 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6154 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6156 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6158 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6160 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6162 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6164 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6166 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6168 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6170 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6172 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6175 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6177 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6180 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6182 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6184 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6187 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
6189 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6193 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6196 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
6199 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6201 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6203 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6206 /* here begins pointed-to data */
6208 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6210 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6212 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6214 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6216 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6218 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6220 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6222 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6224 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6226 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6229 /* ok, this is only guess-work (as usual) */
6230 if (usr->ptr_logon_hrs) {
6233 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6235 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6237 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6239 } else if (UNMARSHALLING(ps)) {
6247 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6249 int len_munged_dial;
6250 const char* munged_dial = pdb_get_munged_dial(pw);
6252 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6253 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6254 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6258 /*******************************************************************
6259 reads or writes a structure.
6260 ********************************************************************/
6262 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6263 prs_struct *ps, int depth)
6268 prs_debug(ps, depth, desc, "sam_io_user_info20");
6274 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6277 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6283 /*******************************************************************
6284 inits a SAM_USERINFO_CTR structure.
6285 ********************************************************************/
6287 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6288 uint16 switch_value,
6289 SAM_USER_INFO_21 * usr)
6291 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6293 ctr->switch_value = switch_value;
6294 ctr->info.id = NULL;
6296 switch (switch_value) {
6298 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
6299 if (ctr->info.id10 == NULL)
6300 return NT_STATUS_NO_MEMORY;
6302 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6305 /* whoops - got this wrong. i think. or don't understand what's happening. */
6309 info = (void *)&id11;
6311 expire.low = 0xffffffff;
6312 expire.high = 0x7fffffff;
6314 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
6315 init_sam_user_info11(ctr->info.id11, &expire,
6316 "BROOKFIELDS$", /* name */
6317 0x03ef, /* user rid */
6318 0x201, /* group rid */
6319 0x0080); /* acb info */
6325 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
6326 if (ctr->info.id12 == NULL)
6327 return NT_STATUS_NO_MEMORY;
6329 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6333 SAM_USER_INFO_21 *cusr;
6334 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
6335 ctr->info.id21 = cusr;
6336 if (ctr->info.id21 == NULL)
6337 return NT_STATUS_NO_MEMORY;
6338 memcpy(cusr, usr, sizeof(*usr));
6339 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6340 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6344 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6345 return NT_STATUS_INVALID_INFO_CLASS;
6348 return NT_STATUS_OK;
6351 /*******************************************************************
6352 inits a SAM_USERINFO_CTR structure.
6353 ********************************************************************/
6355 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
6356 uint16 switch_value, void *info)
6358 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6360 ctr->switch_value = switch_value;
6361 ctr->info.id = info;
6363 switch (switch_value) {
6365 SamOEMhash(ctr->info.id24->pass, sess_key, 516);
6366 dump_data(100, (char *)sess_key, 16);
6367 dump_data(100, (char *)ctr->info.id24->pass, 516);
6370 SamOEMhash(ctr->info.id23->pass, sess_key, 516);
6371 dump_data(100, (char *)sess_key, 16);
6372 dump_data(100, (char *)ctr->info.id23->pass, 516);
6375 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6379 /*******************************************************************
6380 reads or writes a structure.
6381 ********************************************************************/
6383 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6384 prs_struct *ps, int depth)
6387 SAM_USERINFO_CTR *ctr;
6389 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6392 if (UNMARSHALLING(ps)) {
6393 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
6401 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6403 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6410 switch (ctr->switch_value) {
6412 if (UNMARSHALLING(ps))
6413 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
6414 if (ctr->info.id10 == NULL) {
6415 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6418 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6421 if (UNMARSHALLING(ps))
6422 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
6424 if (ctr->info.id11 == NULL) {
6425 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6428 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6431 if (UNMARSHALLING(ps))
6432 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
6434 if (ctr->info.id12 == NULL) {
6435 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6438 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6441 if (UNMARSHALLING(ps))
6442 ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20));
6444 if (ctr->info.id20 == NULL) {
6445 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6448 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6451 if (UNMARSHALLING(ps))
6452 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
6454 if (ctr->info.id21 == NULL) {
6455 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6458 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6461 if (UNMARSHALLING(ps))
6462 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
6464 if (ctr->info.id23 == NULL) {
6465 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6468 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6471 if (UNMARSHALLING(ps))
6472 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
6474 if (ctr->info.id24 == NULL) {
6475 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6478 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6481 if (UNMARSHALLING(ps))
6482 ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25));
6484 if (ctr->info.id25 == NULL) {
6485 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6488 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6491 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6499 /*******************************************************************
6500 inits a SAMR_R_QUERY_USERINFO structure.
6501 ********************************************************************/
6503 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6504 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6506 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6511 if (NT_STATUS_IS_OK(status)) {
6516 r_u->status = status; /* return status */
6519 /*******************************************************************
6520 reads or writes a structure.
6521 ********************************************************************/
6523 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6524 prs_struct *ps, int depth)
6529 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6535 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6538 if (r_u->ptr != 0) {
6539 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6545 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6551 /*******************************************************************
6552 inits a SAMR_Q_SET_USERINFO structure.
6553 ********************************************************************/
6555 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6556 POLICY_HND *hnd, unsigned char sess_key[16],
6557 uint16 switch_value, void *info)
6559 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6562 q_u->switch_value = switch_value;
6563 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6566 /*******************************************************************
6567 reads or writes a structure.
6568 ********************************************************************/
6570 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6571 prs_struct *ps, int depth)
6576 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6582 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6584 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6586 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6592 /*******************************************************************
6593 inits a SAMR_R_SET_USERINFO structure.
6594 ********************************************************************/
6596 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6598 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6600 r_u->status = status; /* return status */
6603 /*******************************************************************
6604 reads or writes a structure.
6605 ********************************************************************/
6607 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6608 prs_struct *ps, int depth)
6613 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6619 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6625 /*******************************************************************
6626 inits a SAMR_Q_SET_USERINFO2 structure.
6627 ********************************************************************/
6629 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6630 POLICY_HND *hnd, unsigned char sess_key[16],
6631 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6633 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6636 q_u->switch_value = switch_value;
6639 if (q_u->ctr != NULL)
6640 q_u->ctr->switch_value = switch_value;
6642 switch (switch_value) {
6644 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16);
6645 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16);
6646 dump_data(100, (char *)sess_key, 16);
6647 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6648 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6653 /*******************************************************************
6654 reads or writes a structure.
6655 ********************************************************************/
6657 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6658 prs_struct *ps, int depth)
6663 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6669 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6672 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6674 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6680 /*******************************************************************
6681 inits a SAMR_R_SET_USERINFO2 structure.
6682 ********************************************************************/
6684 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6686 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6688 r_u->status = status; /* return status */
6691 /*******************************************************************
6692 reads or writes a structure.
6693 ********************************************************************/
6695 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6696 prs_struct *ps, int depth)
6701 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6707 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6713 /*******************************************************************
6714 inits a SAMR_Q_CONNECT structure.
6715 ********************************************************************/
6717 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6718 char *srv_name, uint32 access_mask)
6720 int len_srv_name = strlen(srv_name);
6722 DEBUG(5, ("init_samr_q_connect\n"));
6724 /* make PDC server name \\server */
6725 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6726 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6728 /* example values: 0x0000 0002 */
6729 q_u->access_mask = access_mask;
6732 /*******************************************************************
6733 reads or writes a structure.
6734 ********************************************************************/
6736 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6737 prs_struct *ps, int depth)
6742 prs_debug(ps, depth, desc, "samr_io_q_connect");
6748 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6750 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6755 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6761 /*******************************************************************
6762 reads or writes a structure.
6763 ********************************************************************/
6765 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6766 prs_struct *ps, int depth)
6771 prs_debug(ps, depth, desc, "samr_io_r_connect");
6777 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6780 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6786 /*******************************************************************
6787 inits a SAMR_Q_CONNECT4 structure.
6788 ********************************************************************/
6790 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6791 char *srv_name, uint32 access_mask)
6793 int len_srv_name = strlen(srv_name);
6795 DEBUG(5, ("init_samr_q_connect\n"));
6797 /* make PDC server name \\server */
6798 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6799 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6801 /* Only value we've seen, possibly an address type ? */
6804 /* example values: 0x0000 0002 */
6805 q_u->access_mask = access_mask;
6808 /*******************************************************************
6809 reads or writes a structure.
6810 ********************************************************************/
6812 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6813 prs_struct *ps, int depth)
6818 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6824 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6826 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6831 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6833 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6839 /*******************************************************************
6840 reads or writes a structure.
6841 ********************************************************************/
6843 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6844 prs_struct *ps, int depth)
6849 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6855 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6858 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6864 /*******************************************************************
6865 inits a SAMR_Q_CONNECT_ANON structure.
6866 ********************************************************************/
6868 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6870 DEBUG(5, ("init_samr_q_connect_anon\n"));
6873 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6874 q_u->unknown_1 = 0x01;
6875 q_u->access_mask = 0x20;
6878 /*******************************************************************
6879 reads or writes a structure.
6880 ********************************************************************/
6882 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6883 prs_struct *ps, int depth)
6888 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6894 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6896 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6898 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6900 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6906 /*******************************************************************
6907 reads or writes a structure.
6908 ********************************************************************/
6910 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6911 prs_struct *ps, int depth)
6916 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6922 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6925 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6931 /*******************************************************************
6932 inits a SAMR_Q_GET_DOM_PWINFO structure.
6933 ********************************************************************/
6935 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6938 int len_srv_name = strlen(srv_name);
6940 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6943 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6944 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6947 /*******************************************************************
6948 reads or writes a structure.
6949 ********************************************************************/
6951 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6952 prs_struct *ps, int depth)
6957 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6963 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6965 if (q_u->ptr != 0) {
6966 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6968 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6975 /*******************************************************************
6976 reads or writes a structure.
6977 ********************************************************************/
6979 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6980 prs_struct *ps, int depth)
6985 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6992 * We need 16 bytes here according to tests. Don't know
6993 * what they are, but the length is important for the singing
6996 if(!prs_uint32("unk_0", ps, depth, &r_u->unk_0))
6998 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
7000 if(!prs_uint32("unk_2", ps, depth, &r_u->unk_2))
7003 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7009 /*******************************************************************
7010 make a SAMR_ENC_PASSWD structure.
7011 ********************************************************************/
7013 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
7021 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7025 /*******************************************************************
7026 reads or writes a SAMR_ENC_PASSWD structure.
7027 ********************************************************************/
7029 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7030 prs_struct *ps, int depth)
7035 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7041 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7044 if (pwd->ptr != 0) {
7045 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7052 /*******************************************************************
7053 inits a SAMR_ENC_HASH structure.
7054 ********************************************************************/
7056 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
7064 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7068 /*******************************************************************
7069 reads or writes a SAMR_ENC_HASH structure.
7070 ********************************************************************/
7072 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7073 prs_struct *ps, int depth)
7078 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7084 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7086 if (hsh->ptr != 0) {
7087 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7094 /*******************************************************************
7095 inits a SAMR_R_GET_DOM_PWINFO structure.
7096 ********************************************************************/
7098 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7099 char *dest_host, char *user_name,
7100 char nt_newpass[516],
7101 uchar nt_oldhash[16],
7102 char lm_newpass[516],
7103 uchar lm_oldhash[16])
7105 int len_dest_host = strlen(dest_host);
7106 int len_user_name = strlen(user_name);
7108 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7111 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
7112 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
7113 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
7114 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
7116 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7117 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7119 q_u->unknown = 0x01;
7121 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7122 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7125 /*******************************************************************
7126 reads or writes a structure.
7127 ********************************************************************/
7129 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7130 prs_struct *ps, int depth)
7135 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7141 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7144 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7146 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7151 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7153 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7156 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7158 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7161 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7164 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7166 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7172 /*******************************************************************
7173 inits a SAMR_R_CHGPASSWD_USER structure.
7174 ********************************************************************/
7176 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7178 DEBUG(5, ("init_r_chgpasswd_user\n"));
7180 r_u->status = status;
7183 /*******************************************************************
7184 reads or writes a structure.
7185 ********************************************************************/
7187 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7188 prs_struct *ps, int depth)
7193 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7199 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7205 /*******************************************************************
7206 reads or writes a structure.
7207 ********************************************************************/
7209 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7210 POLICY_HND *domain_pol, uint16 switch_value)
7212 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7214 q_u->domain_pol = *domain_pol;
7215 q_u->switch_value = switch_value;
7218 /*******************************************************************
7219 reads or writes a structure.
7220 ********************************************************************/
7222 BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7223 prs_struct *ps, int depth)
7228 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7234 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7237 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7243 /*******************************************************************
7244 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7245 ********************************************************************/
7247 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7248 uint16 switch_value, SAM_UNK_CTR * ctr,
7251 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7254 r_u->switch_value = 0;
7255 r_u->status = status; /* return status */
7257 if (NT_STATUS_IS_OK(status)) {
7258 r_u->switch_value = switch_value;
7264 /*******************************************************************
7265 reads or writes a structure.
7266 ********************************************************************/
7268 BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u,
7269 prs_struct *ps, int depth)
7274 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7280 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7283 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7284 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7289 switch (r_u->switch_value) {
7291 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7295 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7299 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7303 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7307 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7311 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7315 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7319 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7320 r_u->switch_value));
7321 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7329 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7336 /*******************************************************************
7337 reads or writes a structure.
7338 ********************************************************************/
7340 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7341 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7343 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7345 q_u->domain_pol = *domain_pol;
7346 q_u->switch_value0 = switch_value;
7348 q_u->switch_value = switch_value;
7353 /*******************************************************************
7354 reads or writes a structure.
7355 ********************************************************************/
7357 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7358 prs_struct *ps, int depth)
7363 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7369 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7372 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7375 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7381 if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL)
7384 switch (q_u->switch_value) {
7387 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7391 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7395 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7399 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7403 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7407 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7411 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7415 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7416 q_u->switch_value));
7423 /*******************************************************************
7424 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7425 ********************************************************************/
7427 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7429 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7431 r_u->status = status; /* return status */
7434 /*******************************************************************
7435 reads or writes a structure.
7436 ********************************************************************/
7438 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7439 prs_struct *ps, int depth)
7444 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7450 if(!prs_ntstatus("status", ps, depth, &r_u->status))