2 * Unix SMB/Netbios implementation.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-2000,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
7 * Copyright (C) Paul Ashton 1997-2000,
8 * Copyright (C) Elrond 2000,
9 * Copyright (C) Jeremy Allison 2001
10 * Copyright (C) Jean François Micouleau 1998-2001.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include "rpc_parse.h"
31 /*******************************************************************
32 inits a SAMR_Q_CLOSE_HND structure.
33 ********************************************************************/
35 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
37 DEBUG(5, ("init_samr_q_close_hnd\n"));
42 /*******************************************************************
43 reads or writes a structure.
44 ********************************************************************/
46 BOOL samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND * q_u,
47 prs_struct *ps, int depth)
52 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
58 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
61 /*******************************************************************
62 reads or writes a structure.
63 ********************************************************************/
65 BOOL samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND * r_u,
66 prs_struct *ps, int depth)
71 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
77 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
80 if(!prs_ntstatus("status", ps, depth, &r_u->status))
86 /*******************************************************************
87 inits a SAMR_Q_LOOKUP_DOMAIN structure.
88 ********************************************************************/
90 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
91 POLICY_HND *pol, char *dom_name)
93 int len_name = strlen(dom_name);
95 DEBUG(5, ("init_samr_q_lookup_domain\n"));
97 q_u->connect_pol = *pol;
99 init_uni_hdr(&q_u->hdr_domain, len_name);
100 init_unistr2(&q_u->uni_domain, dom_name, len_name);
103 /*******************************************************************
104 reads or writes a structure.
105 ********************************************************************/
106 BOOL samr_io_q_lookup_domain(char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
107 prs_struct *ps, int depth)
112 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
118 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
121 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
124 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
130 /*******************************************************************
131 inits a SAMR_R_LOOKUP_DOMAIN structure.
132 ********************************************************************/
134 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
135 DOM_SID *dom_sid, NTSTATUS status)
137 DEBUG(5, ("init_samr_r_lookup_domain\n"));
139 r_u->status = status;
141 if (NT_STATUS_IS_OK(status)) {
143 init_dom_sid2(&r_u->dom_sid, dom_sid);
147 /*******************************************************************
148 reads or writes a structure.
149 ********************************************************************/
151 BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
152 prs_struct *ps, int depth)
157 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
163 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
166 if (r_u->ptr_sid != 0) {
167 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
173 if(!prs_ntstatus("status", ps, depth, &r_u->status))
179 /*******************************************************************
180 reads or writes a structure.
181 ********************************************************************/
183 void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
185 DEBUG(5, ("samr_init_samr_q_unknown_2d\n"));
187 q_u->dom_pol = *dom_pol;
188 init_dom_sid2(&q_u->sid, sid);
191 /*******************************************************************
192 reads or writes a structure.
193 ********************************************************************/
195 BOOL samr_io_q_unknown_2d(char *desc, SAMR_Q_UNKNOWN_2D * q_u,
196 prs_struct *ps, int depth)
201 prs_debug(ps, depth, desc, "samr_io_q_unknown_2d");
207 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
210 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
219 /*******************************************************************
220 reads or writes a structure.
221 ********************************************************************/
223 BOOL samr_io_r_unknown_2d(char *desc, SAMR_R_UNKNOWN_2D * r_u,
224 prs_struct *ps, int depth)
229 prs_debug(ps, depth, desc, "samr_io_r_unknown_2d");
235 if(!prs_ntstatus("status", ps, depth, &r_u->status))
241 /*******************************************************************
242 reads or writes a structure.
243 ********************************************************************/
245 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
246 POLICY_HND *pol, uint32 flags,
249 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
253 init_dom_sid2(&q_u->dom_sid, sid);
256 /*******************************************************************
257 reads or writes a structure.
258 ********************************************************************/
260 BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
261 prs_struct *ps, int depth)
266 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
272 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
275 if(!prs_uint32("flags", ps, depth, &q_u->flags))
278 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
284 /*******************************************************************
285 reads or writes a structure.
286 ********************************************************************/
288 BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN * r_u,
289 prs_struct *ps, int depth)
294 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
300 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
303 if(!prs_ntstatus("status", ps, depth, &r_u->status))
309 /*******************************************************************
310 reads or writes a structure.
311 ********************************************************************/
313 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
314 POLICY_HND *user_pol)
316 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
318 q_u->user_pol = *user_pol;
321 /*******************************************************************
322 reads or writes a structure.
323 ********************************************************************/
325 BOOL samr_io_q_get_usrdom_pwinfo(char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
326 prs_struct *ps, int depth)
331 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
337 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
340 /*******************************************************************
342 ********************************************************************/
344 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
346 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
348 r_u->unknown_0 = 0x0000;
352 * r_u->unknown_1 = 0x0015;
355 r_u->unknown_1 = 0x01D1;
356 r_u->unknown_1 = 0x0015;
358 r_u->unknown_2 = 0x00000000;
360 r_u->status = status;
363 /*******************************************************************
364 reads or writes a structure.
365 ********************************************************************/
367 BOOL samr_io_r_get_usrdom_pwinfo(char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
368 prs_struct *ps, int depth)
373 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
379 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
381 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
383 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
385 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
391 /*******************************************************************
392 reads or writes a structure.
393 ********************************************************************/
395 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
396 POLICY_HND *user_pol, uint32 sec_info)
398 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
400 q_u->user_pol = *user_pol;
401 q_u->sec_info = sec_info;
405 /*******************************************************************
406 reads or writes a structure.
407 ********************************************************************/
409 BOOL samr_io_q_query_sec_obj(char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
410 prs_struct *ps, int depth)
415 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
421 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
424 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
430 /*******************************************************************
431 reads or writes a structure.
432 ********************************************************************/
434 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
435 POLICY_HND *domain_pol, uint16 switch_value)
437 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
439 q_u->domain_pol = *domain_pol;
440 q_u->switch_value = switch_value;
443 /*******************************************************************
444 reads or writes a structure.
445 ********************************************************************/
447 BOOL samr_io_q_query_dom_info(char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
448 prs_struct *ps, int depth)
453 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
459 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
462 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
469 /*******************************************************************
471 ********************************************************************/
473 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
475 u_3->logout.low = nt_logout.low;
476 u_3->logout.high = nt_logout.high;
479 /*******************************************************************
480 reads or writes a structure.
481 ********************************************************************/
483 static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 * u_3,
484 prs_struct *ps, int depth)
489 prs_debug(ps, depth, desc, "sam_io_unk_info3");
492 if(!smb_io_time("logout", &u_3->logout, ps, depth))
498 /*******************************************************************
500 ********************************************************************/
502 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
504 u_6->unknown_0 = 0x00000000;
506 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
509 /*******************************************************************
510 reads or writes a structure.
511 ********************************************************************/
513 static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 * u_6,
514 prs_struct *ps, int depth)
519 prs_debug(ps, depth, desc, "sam_io_unk_info6");
522 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
524 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
526 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
532 /*******************************************************************
534 ********************************************************************/
536 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
538 u_7->unknown_0 = 0x0003;
541 /*******************************************************************
542 reads or writes a structure.
543 ********************************************************************/
545 static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 * u_7,
546 prs_struct *ps, int depth)
551 prs_debug(ps, depth, desc, "sam_io_unk_info7");
554 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
560 /*******************************************************************
562 ********************************************************************/
564 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
566 u_12->duration.low = nt_lock_duration.low;
567 u_12->duration.high = nt_lock_duration.high;
568 u_12->reset_count.low = nt_reset_time.low;
569 u_12->reset_count.high = nt_reset_time.high;
571 u_12->bad_attempt_lockout = lockout;
574 /*******************************************************************
575 reads or writes a structure.
576 ********************************************************************/
578 static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
579 prs_struct *ps, int depth)
584 prs_debug(ps, depth, desc, "sam_io_unk_info12");
587 if(!smb_io_time("duration", &u_12->duration, ps, depth))
589 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
591 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
597 /*******************************************************************
599 ********************************************************************/
600 void init_unk_info5(SAM_UNK_INFO_5 * u_5,char *server)
602 int len_server = strlen(server);
604 init_uni_hdr(&u_5->hdr_server, len_server);
606 init_unistr2(&u_5->uni_server, server, len_server);
609 /*******************************************************************
610 reads or writes a structure.
611 ********************************************************************/
613 static BOOL sam_io_unk_info5(char *desc, SAM_UNK_INFO_5 * u_5,
614 prs_struct *ps, int depth)
619 prs_debug(ps, depth, desc, "sam_io_unk_info5");
622 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
625 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
631 /*******************************************************************
633 ********************************************************************/
634 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
635 char *domain, char *server,
636 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
638 int len_domain = strlen(domain);
639 int len_server = strlen(server);
641 u_2->unknown_0 = 0x00000000;
642 u_2->unknown_1 = 0x80000000;
643 u_2->unknown_2 = 0x00000000;
646 init_uni_hdr(&u_2->hdr_domain, len_domain);
647 init_uni_hdr(&u_2->hdr_server, len_server);
649 u_2->seq_num = seq_num;
650 u_2->unknown_3 = 0x00000000;
652 u_2->unknown_4 = 0x00000001;
653 u_2->unknown_5 = 0x00000003;
654 u_2->unknown_6 = 0x00000001;
655 u_2->num_domain_usrs = num_users;
656 u_2->num_domain_grps = num_groups;
657 u_2->num_local_grps = num_alias;
659 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
661 init_unistr2(&u_2->uni_domain, domain, len_domain);
662 init_unistr2(&u_2->uni_server, server, len_server);
665 /*******************************************************************
666 reads or writes a structure.
667 ********************************************************************/
669 static BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 * u_2,
670 prs_struct *ps, int depth)
675 prs_debug(ps, depth, desc, "sam_io_unk_info2");
678 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
680 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
682 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
685 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
687 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
689 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
692 /* put all the data in here, at the moment, including what the above
693 pointer is referring to
696 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
698 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
701 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
703 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
705 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
707 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
709 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
711 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
714 if(!prs_uint8s(False, "padding", ps, depth, u_2->padding,sizeof(u_2->padding)))
717 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
719 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
725 /*******************************************************************
727 ********************************************************************/
729 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
730 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
732 u_1->min_length_password = min_pass_len;
733 u_1->password_history = pass_hist;
736 /* password never expire */
737 u_1->expire.high = nt_expire.high;
738 u_1->expire.low = nt_expire.low;
740 /* can change the password now */
741 u_1->min_passwordage.high = nt_min_age.high;
742 u_1->min_passwordage.low = nt_min_age.low;
746 /*******************************************************************
747 reads or writes a structure.
748 ********************************************************************/
750 static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 * u_1,
751 prs_struct *ps, int depth)
756 prs_debug(ps, depth, desc, "sam_io_unk_info1");
759 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
761 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
763 if(!prs_uint32("flag", ps, depth, &u_1->flag))
765 if(!smb_io_time("expire", &u_1->expire, ps, depth))
767 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
773 /*******************************************************************
774 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
775 ********************************************************************/
777 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
778 uint16 switch_value, SAM_UNK_CTR * ctr,
781 DEBUG(5, ("init_samr_r_query_dom_info\n"));
784 r_u->switch_value = 0;
785 r_u->status = status; /* return status */
787 if (NT_STATUS_IS_OK(status)) {
788 r_u->switch_value = switch_value;
794 /*******************************************************************
795 reads or writes a structure.
796 ********************************************************************/
798 BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
799 prs_struct *ps, int depth)
804 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
810 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
813 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
814 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
819 switch (r_u->switch_value) {
821 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
825 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
829 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
833 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
837 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
841 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
845 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
849 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
851 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
859 if(!prs_ntstatus("status", ps, depth, &r_u->status))
865 /*******************************************************************
866 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
867 ********************************************************************/
869 BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
870 prs_struct *ps, int depth)
875 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
881 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
884 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
888 if(!prs_ntstatus("status", ps, depth, &r_u->status))
894 /*******************************************************************
895 reads or writes a SAM_STR1 structure.
896 ********************************************************************/
898 static BOOL sam_io_sam_str1(char *desc, SAM_STR1 * sam, uint32 acct_buf,
899 uint32 name_buf, uint32 desc_buf,
900 prs_struct *ps, int depth)
905 prs_debug(ps, depth, desc, "sam_io_sam_str1");
910 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
913 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
916 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
922 /*******************************************************************
923 inits a SAM_ENTRY1 structure.
924 ********************************************************************/
926 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
927 uint32 len_sam_name, uint32 len_sam_full,
928 uint32 len_sam_desc, uint32 rid_user,
931 DEBUG(5, ("init_sam_entry1\n"));
935 sam->user_idx = user_idx;
936 sam->rid_user = rid_user;
937 sam->acb_info = acb_info;
939 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
940 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
941 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
944 /*******************************************************************
945 reads or writes a SAM_ENTRY1 structure.
946 ********************************************************************/
948 static BOOL sam_io_sam_entry1(char *desc, SAM_ENTRY1 * sam,
949 prs_struct *ps, int depth)
954 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
960 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
963 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
965 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
971 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
973 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
975 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
981 /*******************************************************************
982 reads or writes a SAM_STR2 structure.
983 ********************************************************************/
985 static BOOL sam_io_sam_str2(char *desc, SAM_STR2 * sam, uint32 acct_buf,
986 uint32 desc_buf, prs_struct *ps, int depth)
991 prs_debug(ps, depth, desc, "sam_io_sam_str2");
997 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
999 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1005 /*******************************************************************
1006 inits a SAM_ENTRY2 structure.
1007 ********************************************************************/
1008 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1009 uint32 len_sam_name, uint32 len_sam_desc,
1010 uint32 rid_user, uint16 acb_info)
1012 DEBUG(5, ("init_sam_entry2\n"));
1014 sam->user_idx = user_idx;
1015 sam->rid_user = rid_user;
1016 sam->acb_info = acb_info;
1018 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
1019 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
1022 /*******************************************************************
1023 reads or writes a SAM_ENTRY2 structure.
1024 ********************************************************************/
1026 static BOOL sam_io_sam_entry2(char *desc, SAM_ENTRY2 * sam,
1027 prs_struct *ps, int depth)
1032 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1038 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1041 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1043 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1049 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1051 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1057 /*******************************************************************
1058 reads or writes a SAM_STR3 structure.
1059 ********************************************************************/
1061 static BOOL sam_io_sam_str3(char *desc, SAM_STR3 * sam, uint32 acct_buf,
1062 uint32 desc_buf, prs_struct *ps, int depth)
1067 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1073 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1075 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1081 /*******************************************************************
1082 inits a SAM_ENTRY3 structure.
1083 ********************************************************************/
1085 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1086 uint32 len_grp_name, uint32 len_grp_desc,
1089 DEBUG(5, ("init_sam_entry3\n"));
1091 sam->grp_idx = grp_idx;
1092 sam->rid_grp = rid_grp;
1093 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1095 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1096 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1099 /*******************************************************************
1100 reads or writes a SAM_ENTRY3 structure.
1101 ********************************************************************/
1103 static BOOL sam_io_sam_entry3(char *desc, SAM_ENTRY3 * sam,
1104 prs_struct *ps, int depth)
1109 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1115 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1118 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1120 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1123 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1125 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1131 /*******************************************************************
1132 inits a SAM_ENTRY4 structure.
1133 ********************************************************************/
1135 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1136 uint32 len_acct_name)
1138 DEBUG(5, ("init_sam_entry4\n"));
1140 sam->user_idx = user_idx;
1141 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1144 /*******************************************************************
1145 reads or writes a SAM_ENTRY4 structure.
1146 ********************************************************************/
1148 static BOOL sam_io_sam_entry4(char *desc, SAM_ENTRY4 * sam,
1149 prs_struct *ps, int depth)
1154 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1160 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1162 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1168 /*******************************************************************
1169 inits a SAM_ENTRY5 structure.
1170 ********************************************************************/
1172 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1173 uint32 len_grp_name)
1175 DEBUG(5, ("init_sam_entry5\n"));
1177 sam->grp_idx = grp_idx;
1178 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1182 /*******************************************************************
1183 reads or writes a SAM_ENTRY5 structure.
1184 ********************************************************************/
1186 static BOOL sam_io_sam_entry5(char *desc, SAM_ENTRY5 * sam,
1187 prs_struct *ps, int depth)
1192 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1198 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1200 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1206 /*******************************************************************
1207 inits a SAM_ENTRY structure.
1208 ********************************************************************/
1210 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1212 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1215 init_uni_hdr(&sam->hdr_name, len_sam_name);
1218 /*******************************************************************
1219 reads or writes a SAM_ENTRY structure.
1220 ********************************************************************/
1222 static BOOL sam_io_sam_entry(char *desc, SAM_ENTRY * sam,
1223 prs_struct *ps, int depth)
1228 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1233 if(!prs_uint32("rid", ps, depth, &sam->rid))
1235 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1241 /*******************************************************************
1242 inits a SAMR_Q_ENUM_DOM_USERS structure.
1243 ********************************************************************/
1245 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1247 uint16 acb_mask, uint16 unk_1, uint32 size)
1249 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1253 q_e->start_idx = start_idx; /* zero indicates lots */
1254 q_e->acb_mask = acb_mask;
1255 q_e->unknown_1 = unk_1;
1256 q_e->max_size = size;
1259 /*******************************************************************
1260 reads or writes a structure.
1261 ********************************************************************/
1263 BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1264 prs_struct *ps, int depth)
1269 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1275 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1278 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1280 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1282 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1285 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1292 /*******************************************************************
1293 inits a SAMR_R_ENUM_DOM_USERS structure.
1294 ********************************************************************/
1296 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1297 uint32 next_idx, uint32 num_sam_entries)
1299 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1301 r_u->next_idx = next_idx;
1303 if (num_sam_entries != 0) {
1304 r_u->ptr_entries1 = 1;
1305 r_u->ptr_entries2 = 1;
1306 r_u->num_entries2 = num_sam_entries;
1307 r_u->num_entries3 = num_sam_entries;
1309 r_u->num_entries4 = num_sam_entries;
1311 r_u->ptr_entries1 = 0;
1312 r_u->num_entries2 = num_sam_entries;
1313 r_u->ptr_entries2 = 1;
1317 /*******************************************************************
1318 reads or writes a structure.
1319 ********************************************************************/
1321 BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1322 prs_struct *ps, int depth)
1329 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1335 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1337 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1340 if (r_u->ptr_entries1 != 0) {
1341 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1343 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1345 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1348 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1349 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1350 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
1353 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1354 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1355 r_u->num_entries4 = 0;
1356 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1360 for (i = 0; i < r_u->num_entries2; i++) {
1361 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1365 for (i = 0; i < r_u->num_entries2; i++) {
1366 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1375 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1377 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1383 /*******************************************************************
1384 inits a SAMR_Q_QUERY_DISPINFO structure.
1385 ********************************************************************/
1387 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1388 uint16 switch_level, uint32 start_idx,
1391 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1393 q_e->domain_pol = *pol;
1395 q_e->switch_level = switch_level;
1397 q_e->start_idx = start_idx;
1398 q_e->max_entries = max_entries;
1399 q_e->max_size = 0xffff; /* Not especially useful */
1402 /*******************************************************************
1403 reads or writes a structure.
1404 ********************************************************************/
1406 BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1407 prs_struct *ps, int depth)
1412 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1418 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1421 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1426 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1428 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1430 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1436 /*******************************************************************
1437 inits a SAM_DISPINFO_1 structure.
1438 ********************************************************************/
1440 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1441 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1443 uint32 len_sam_name, len_sam_full, len_sam_desc;
1446 SAM_ACCOUNT *pwd = NULL;
1449 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1452 return NT_STATUS_OK;
1454 sam->sam=(SAM_ENTRY1 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY1));
1456 return NT_STATUS_NO_MEMORY;
1458 sam->str=(SAM_STR1 *)talloc(ctx, num_entries*sizeof(SAM_STR1));
1460 return NT_STATUS_NO_MEMORY;
1462 ZERO_STRUCTP(sam->sam);
1463 ZERO_STRUCTP(sam->str);
1465 for (i = 0; i < num_entries ; i++) {
1466 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1468 pwd=disp_user_info[i+start_idx].sam;
1470 len_sam_name = strlen(pdb_get_username(pwd));
1471 len_sam_full = strlen(pdb_get_fullname(pwd));
1472 len_sam_desc = strlen(pdb_get_acct_desc(pwd));
1474 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1475 len_sam_name, len_sam_full, len_sam_desc,
1476 pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd));
1478 ZERO_STRUCTP(&sam->str[i].uni_acct_name);
1479 ZERO_STRUCTP(&sam->str[i].uni_full_name);
1480 ZERO_STRUCTP(&sam->str[i].uni_acct_desc);
1482 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), len_sam_name);
1483 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), len_sam_full);
1484 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1487 return NT_STATUS_OK;
1490 /*******************************************************************
1491 reads or writes a structure.
1492 ********************************************************************/
1494 static BOOL sam_io_sam_dispinfo_1(char *desc, SAM_DISPINFO_1 * sam,
1496 prs_struct *ps, int depth)
1500 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1506 if (UNMARSHALLING(ps) && num_entries > 0) {
1508 if ((sam->sam = (SAM_ENTRY1 *)
1509 prs_alloc_mem(ps, sizeof(SAM_ENTRY1) *
1510 num_entries)) == NULL) {
1511 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1515 if ((sam->str = (SAM_STR1 *)
1516 prs_alloc_mem(ps, sizeof(SAM_STR1) *
1517 num_entries)) == NULL) {
1518 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1523 for (i = 0; i < num_entries; i++) {
1524 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1528 for (i = 0; i < num_entries; i++) {
1529 if(!sam_io_sam_str1("", &sam->str[i],
1530 sam->sam[i].hdr_acct_name.buffer,
1531 sam->sam[i].hdr_user_name.buffer,
1532 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1539 /*******************************************************************
1540 inits a SAM_DISPINFO_2 structure.
1541 ********************************************************************/
1543 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1544 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1546 uint32 len_sam_name, len_sam_desc;
1549 SAM_ACCOUNT *pwd = NULL;
1552 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1555 return NT_STATUS_OK;
1557 if (!(sam->sam=(SAM_ENTRY2 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY2))))
1558 return NT_STATUS_NO_MEMORY;
1560 if (!(sam->str=(SAM_STR2 *)talloc(ctx, num_entries*sizeof(SAM_STR2))))
1561 return NT_STATUS_NO_MEMORY;
1563 ZERO_STRUCTP(sam->sam);
1564 ZERO_STRUCTP(sam->str);
1566 for (i = 0; i < num_entries; i++) {
1567 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1568 pwd=disp_user_info[i+start_idx].sam;
1570 len_sam_name = strlen(pdb_get_username(pwd));
1571 len_sam_desc = strlen(pdb_get_acct_desc(pwd));
1573 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1574 len_sam_name, len_sam_desc,
1575 pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd));
1577 ZERO_STRUCTP(&sam->str[i].uni_srv_name);
1578 ZERO_STRUCTP(&sam->str[i].uni_srv_desc);
1580 init_unistr2(&sam->str[i].uni_srv_name, pdb_get_username(pwd), len_sam_name);
1581 init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1584 return NT_STATUS_OK;
1587 /*******************************************************************
1588 reads or writes a structure.
1589 ********************************************************************/
1591 static BOOL sam_io_sam_dispinfo_2(char *desc, SAM_DISPINFO_2 * sam,
1593 prs_struct *ps, int depth)
1600 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1606 if (UNMARSHALLING(ps) && num_entries > 0) {
1608 if ((sam->sam = (SAM_ENTRY2 *)
1609 prs_alloc_mem(ps, sizeof(SAM_ENTRY2) *
1610 num_entries)) == NULL) {
1611 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1615 if ((sam->str = (SAM_STR2 *)
1616 prs_alloc_mem(ps, sizeof(SAM_STR2) *
1617 num_entries)) == NULL) {
1618 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1623 for (i = 0; i < num_entries; i++) {
1624 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1628 for (i = 0; i < num_entries; i++) {
1629 if(!sam_io_sam_str2("", &sam->str[i],
1630 sam->sam[i].hdr_srv_name.buffer,
1631 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1638 /*******************************************************************
1639 inits a SAM_DISPINFO_3 structure.
1640 ********************************************************************/
1642 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1643 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1645 uint32 len_sam_name, len_sam_desc;
1651 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1654 return NT_STATUS_OK;
1656 if (!(sam->sam=(SAM_ENTRY3 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY3))))
1657 return NT_STATUS_NO_MEMORY;
1659 if (!(sam->str=(SAM_STR3 *)talloc(ctx, num_entries*sizeof(SAM_STR3))))
1660 return NT_STATUS_NO_MEMORY;
1662 ZERO_STRUCTP(sam->sam);
1663 ZERO_STRUCTP(sam->str);
1665 for (i = 0; i < num_entries; i++) {
1666 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1667 grp=disp_group_info[i+start_idx].grp;
1669 len_sam_name = strlen(grp[i].name);
1670 len_sam_desc = strlen(grp[i].comment);
1672 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp[i].rid);
1674 init_unistr2(&sam->str[i].uni_grp_name, grp[i].name, len_sam_name);
1675 init_unistr2(&sam->str[i].uni_grp_desc, grp[i].comment, len_sam_desc);
1678 return NT_STATUS_OK;
1681 /*******************************************************************
1682 reads or writes a structure.
1683 ********************************************************************/
1685 static BOOL sam_io_sam_dispinfo_3(char *desc, SAM_DISPINFO_3 * sam,
1687 prs_struct *ps, int depth)
1694 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1700 if (UNMARSHALLING(ps) && num_entries > 0) {
1702 if ((sam->sam = (SAM_ENTRY3 *)
1703 prs_alloc_mem(ps, sizeof(SAM_ENTRY3) *
1704 num_entries)) == NULL) {
1705 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1709 if ((sam->str = (SAM_STR3 *)
1710 prs_alloc_mem(ps, sizeof(SAM_STR3) *
1711 num_entries)) == NULL) {
1712 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1717 for (i = 0; i < num_entries; i++) {
1718 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1722 for (i = 0; i < num_entries; i++) {
1723 if(!sam_io_sam_str3("", &sam->str[i],
1724 sam->sam[i].hdr_grp_name.buffer,
1725 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1732 /*******************************************************************
1733 inits a SAM_DISPINFO_4 structure.
1734 ********************************************************************/
1736 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1737 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1739 uint32 len_sam_name;
1742 SAM_ACCOUNT *pwd = NULL;
1745 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1748 return NT_STATUS_OK;
1750 if (!(sam->sam=(SAM_ENTRY4 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY4))))
1751 return NT_STATUS_NO_MEMORY;
1753 if (!(sam->str=(SAM_STR4 *)talloc(ctx, num_entries*sizeof(SAM_STR4))))
1754 return NT_STATUS_NO_MEMORY;
1756 ZERO_STRUCTP(sam->sam);
1757 ZERO_STRUCTP(sam->str);
1759 for (i = 0; i < num_entries; i++) {
1760 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1761 pwd=disp_user_info[i+start_idx].sam;
1763 len_sam_name = strlen(pdb_get_username(pwd));
1765 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1767 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1770 return NT_STATUS_OK;
1773 /*******************************************************************
1774 reads or writes a structure.
1775 ********************************************************************/
1777 static BOOL sam_io_sam_dispinfo_4(char *desc, SAM_DISPINFO_4 * sam,
1779 prs_struct *ps, int depth)
1786 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1792 if (UNMARSHALLING(ps) && num_entries > 0) {
1794 if ((sam->sam = (SAM_ENTRY4 *)
1795 prs_alloc_mem(ps, sizeof(SAM_ENTRY4) *
1796 num_entries)) == NULL) {
1797 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1801 if ((sam->str = (SAM_STR4 *)
1802 prs_alloc_mem(ps, sizeof(SAM_STR4) *
1803 num_entries)) == NULL) {
1804 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1809 for (i = 0; i < num_entries; i++) {
1810 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1814 for (i = 0; i < num_entries; i++) {
1815 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1816 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1823 /*******************************************************************
1824 inits a SAM_DISPINFO_5 structure.
1825 ********************************************************************/
1827 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1828 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1830 uint32 len_sam_name;
1836 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1839 return NT_STATUS_OK;
1841 if (!(sam->sam=(SAM_ENTRY5 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY5))))
1842 return NT_STATUS_NO_MEMORY;
1844 if (!(sam->str=(SAM_STR5 *)talloc(ctx, num_entries*sizeof(SAM_STR5))))
1845 return NT_STATUS_NO_MEMORY;
1847 ZERO_STRUCTP(sam->sam);
1848 ZERO_STRUCTP(sam->str);
1850 for (i = 0; i < num_entries; i++) {
1851 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1852 grp=disp_group_info[i+start_idx].grp;
1854 len_sam_name = strlen(grp[i].name);
1856 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1857 init_string2(&sam->str[i].grp_name, grp[i].name, len_sam_name+1, len_sam_name);
1860 return NT_STATUS_OK;
1863 /*******************************************************************
1864 reads or writes a structure.
1865 ********************************************************************/
1867 static BOOL sam_io_sam_dispinfo_5(char *desc, SAM_DISPINFO_5 * sam,
1869 prs_struct *ps, int depth)
1876 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1882 if (UNMARSHALLING(ps) && num_entries > 0) {
1884 if ((sam->sam = (SAM_ENTRY5 *)
1885 prs_alloc_mem(ps, sizeof(SAM_ENTRY5) *
1886 num_entries)) == NULL) {
1887 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1891 if ((sam->str = (SAM_STR5 *)
1892 prs_alloc_mem(ps, sizeof(SAM_STR5) *
1893 num_entries)) == NULL) {
1894 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1899 for (i = 0; i < num_entries; i++) {
1900 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1904 for (i = 0; i < num_entries; i++) {
1905 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1906 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1913 /*******************************************************************
1914 inits a SAMR_R_QUERY_DISPINFO structure.
1915 ********************************************************************/
1917 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1918 uint32 num_entries, uint32 total_size, uint32 data_size,
1919 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1922 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1924 r_u->total_size = total_size;
1926 r_u->data_size = data_size;
1928 r_u->switch_level = switch_level;
1929 r_u->num_entries = num_entries;
1932 r_u->ptr_entries = 0;
1934 r_u->ptr_entries = 1;
1936 r_u->num_entries2 = num_entries;
1939 r_u->status = status;
1942 /*******************************************************************
1943 reads or writes a structure.
1944 ********************************************************************/
1946 BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1947 prs_struct *ps, int depth)
1952 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
1958 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
1960 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
1962 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
1967 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
1969 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
1972 if (r_u->ptr_entries==0) {
1975 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1981 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1984 switch (r_u->switch_level) {
1986 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
1987 r_u->num_entries, ps, depth))
1991 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
1992 r_u->num_entries, ps, depth))
1996 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
1997 r_u->num_entries, ps, depth))
2001 if(!sam_io_sam_dispinfo_4("user list",
2002 r_u->ctr->sam.info4,
2003 r_u->num_entries, ps, depth))
2007 if(!sam_io_sam_dispinfo_5("group list",
2008 r_u->ctr->sam.info5,
2009 r_u->num_entries, ps, depth))
2013 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2019 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2025 /*******************************************************************
2026 inits a SAMR_Q_OPEN_GROUP structure.
2027 ********************************************************************/
2029 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2031 uint32 access_mask, uint32 rid)
2033 DEBUG(5, ("init_samr_q_open_group\n"));
2035 q_c->domain_pol = *hnd;
2036 q_c->access_mask = access_mask;
2037 q_c->rid_group = rid;
2040 /*******************************************************************
2041 reads or writes a structure.
2042 ********************************************************************/
2044 BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
2045 prs_struct *ps, int depth)
2050 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2056 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2059 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2061 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2067 /*******************************************************************
2068 reads or writes a structure.
2069 ********************************************************************/
2071 BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
2072 prs_struct *ps, int depth)
2077 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2083 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2086 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2092 /*******************************************************************
2093 inits a GROUP_INFO1 structure.
2094 ********************************************************************/
2096 void init_samr_group_info1(GROUP_INFO1 * gr1,
2097 char *acct_name, char *acct_desc,
2100 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2101 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
2103 DEBUG(5, ("init_samr_group_info1\n"));
2105 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
2107 gr1->unknown_1 = 0x3;
2108 gr1->num_members = num_members;
2110 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
2112 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
2113 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
2116 /*******************************************************************
2117 reads or writes a structure.
2118 ********************************************************************/
2120 BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
2121 prs_struct *ps, int depth)
2126 prs_debug(ps, depth, desc, "samr_io_group_info1");
2132 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2135 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2137 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2140 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2143 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2144 gr1->hdr_acct_name.buffer, ps, depth))
2147 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2148 gr1->hdr_acct_desc.buffer, ps, depth))
2154 /*******************************************************************
2155 inits a GROUP_INFO3 structure.
2156 ********************************************************************/
2158 void init_samr_group_info3(GROUP_INFO3 *gr3)
2160 DEBUG(5, ("init_samr_group_info3\n"));
2162 gr3->unknown_1 = 0x3;
2165 /*******************************************************************
2166 reads or writes a structure.
2167 ********************************************************************/
2169 BOOL samr_io_group_info3(char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2174 prs_debug(ps, depth, desc, "samr_io_group_info3");
2180 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2186 /*******************************************************************
2187 inits a GROUP_INFO4 structure.
2188 ********************************************************************/
2190 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2192 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2194 DEBUG(5, ("init_samr_group_info4\n"));
2196 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2197 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2200 /*******************************************************************
2201 reads or writes a structure.
2202 ********************************************************************/
2204 BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
2205 prs_struct *ps, int depth)
2210 prs_debug(ps, depth, desc, "samr_io_group_info4");
2216 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2218 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2219 gr4->hdr_acct_desc.buffer, ps, depth))
2225 /*******************************************************************
2226 reads or writes a structure.
2227 ********************************************************************/
2229 static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR **ctr,
2230 prs_struct *ps, int depth)
2232 if (UNMARSHALLING(ps))
2233 *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
2238 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2241 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2244 switch ((*ctr)->switch_value1) {
2246 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2250 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2254 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2258 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2265 /*******************************************************************
2266 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2267 ********************************************************************/
2269 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2270 POLICY_HND *pol, char *acct_desc,
2273 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2275 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2279 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2280 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2282 q_e->access_mask = access_mask;
2285 /*******************************************************************
2286 reads or writes a structure.
2287 ********************************************************************/
2289 BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2290 prs_struct *ps, int depth)
2295 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2301 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2304 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2306 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2307 q_e->hdr_acct_desc.buffer, ps, depth))
2312 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2318 /*******************************************************************
2319 reads or writes a structure.
2320 ********************************************************************/
2322 BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2323 prs_struct *ps, int depth)
2328 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2334 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2337 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2339 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2345 /*******************************************************************
2346 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2347 ********************************************************************/
2349 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2352 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2354 q_c->group_pol = *hnd;
2357 /*******************************************************************
2358 reads or writes a structure.
2359 ********************************************************************/
2361 BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2362 prs_struct *ps, int depth)
2367 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2373 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2379 /*******************************************************************
2380 reads or writes a structure.
2381 ********************************************************************/
2383 BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2384 prs_struct *ps, int depth)
2389 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2395 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2398 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2404 /*******************************************************************
2405 inits a SAMR_Q_DEL_GROUPMEM structure.
2406 ********************************************************************/
2408 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2409 POLICY_HND *pol, uint32 rid)
2411 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2417 /*******************************************************************
2418 reads or writes a structure.
2419 ********************************************************************/
2421 BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2422 prs_struct *ps, int depth)
2427 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2433 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2436 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2442 /*******************************************************************
2443 inits a SAMR_R_DEL_GROUPMEM structure.
2444 ********************************************************************/
2446 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2449 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2451 r_u->status = status;
2454 /*******************************************************************
2455 reads or writes a structure.
2456 ********************************************************************/
2458 BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2459 prs_struct *ps, int depth)
2464 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2470 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2476 /*******************************************************************
2477 inits a SAMR_Q_ADD_GROUPMEM structure.
2478 ********************************************************************/
2480 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2481 POLICY_HND *pol, uint32 rid)
2483 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2487 q_e->unknown = 0x0005;
2490 /*******************************************************************
2491 reads or writes a structure.
2492 ********************************************************************/
2494 BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2495 prs_struct *ps, int depth)
2500 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2506 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2509 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2511 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2517 /*******************************************************************
2518 inits a SAMR_R_ADD_GROUPMEM structure.
2519 ********************************************************************/
2521 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2524 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2526 r_u->status = status;
2529 /*******************************************************************
2530 reads or writes a structure.
2531 ********************************************************************/
2533 BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2534 prs_struct *ps, int depth)
2539 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2545 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2551 /*******************************************************************
2552 inits a SAMR_Q_SET_GROUPINFO structure.
2553 ********************************************************************/
2555 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2556 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2558 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2564 /*******************************************************************
2565 reads or writes a structure.
2566 ********************************************************************/
2568 BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2569 prs_struct *ps, int depth)
2574 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2580 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2583 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2589 /*******************************************************************
2590 inits a SAMR_R_SET_GROUPINFO structure.
2591 ********************************************************************/
2593 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2595 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2597 r_u->status = status;
2600 /*******************************************************************
2601 reads or writes a structure.
2602 ********************************************************************/
2604 BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
2605 prs_struct *ps, int depth)
2610 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2616 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2622 /*******************************************************************
2623 inits a SAMR_Q_QUERY_GROUPINFO structure.
2624 ********************************************************************/
2626 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2627 POLICY_HND *pol, uint16 switch_level)
2629 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2633 q_e->switch_level = switch_level;
2636 /*******************************************************************
2637 reads or writes a structure.
2638 ********************************************************************/
2640 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2641 prs_struct *ps, int depth)
2646 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2652 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2655 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2661 /*******************************************************************
2662 inits a SAMR_R_QUERY_GROUPINFO structure.
2663 ********************************************************************/
2665 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2666 GROUP_INFO_CTR * ctr, NTSTATUS status)
2668 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2670 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2672 r_u->status = status;
2675 /*******************************************************************
2676 reads or writes a structure.
2677 ********************************************************************/
2679 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2680 prs_struct *ps, int depth)
2685 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2691 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2694 if (r_u->ptr != 0) {
2695 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2701 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2707 /*******************************************************************
2708 inits a SAMR_Q_QUERY_GROUPMEM structure.
2709 ********************************************************************/
2711 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2713 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2715 q_c->group_pol = *hnd;
2718 /*******************************************************************
2719 reads or writes a structure.
2720 ********************************************************************/
2722 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2723 prs_struct *ps, int depth)
2728 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2734 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2740 /*******************************************************************
2741 inits a SAMR_R_QUERY_GROUPMEM structure.
2742 ********************************************************************/
2744 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2745 uint32 num_entries, uint32 *rid,
2746 uint32 *attr, NTSTATUS status)
2748 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2750 if (NT_STATUS_IS_OK(status)) {
2752 r_u->num_entries = num_entries;
2754 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2755 r_u->ptr_rids = rid != NULL ? 1 : 0;
2757 r_u->num_rids = num_entries;
2760 r_u->num_attrs = num_entries;
2764 r_u->num_entries = 0;
2767 r_u->status = status;
2770 /*******************************************************************
2771 reads or writes a structure.
2772 ********************************************************************/
2774 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2775 prs_struct *ps, int depth)
2782 if (UNMARSHALLING(ps))
2785 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2791 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2793 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2796 if (r_u->ptr != 0) {
2797 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2799 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2802 if (r_u->ptr_rids != 0) {
2803 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2805 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2806 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2807 if (r_u->rid == NULL)
2811 for (i = 0; i < r_u->num_rids; i++) {
2812 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2817 if (r_u->ptr_attrs != 0) {
2818 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2821 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2822 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2823 if (r_u->attr == NULL)
2827 for (i = 0; i < r_u->num_attrs; i++) {
2828 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2834 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2840 /*******************************************************************
2841 inits a SAMR_Q_QUERY_USERGROUPS structure.
2842 ********************************************************************/
2844 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2847 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2852 /*******************************************************************
2853 reads or writes a structure.
2854 ********************************************************************/
2856 BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2857 prs_struct *ps, int depth)
2862 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2868 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2874 /*******************************************************************
2875 inits a SAMR_R_QUERY_USERGROUPS structure.
2876 ********************************************************************/
2878 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2879 uint32 num_gids, DOM_GID * gid,
2882 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2884 if (NT_STATUS_IS_OK(status)) {
2886 r_u->num_entries = num_gids;
2887 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2888 r_u->num_entries2 = num_gids;
2893 r_u->num_entries = 0;
2898 r_u->status = status;
2901 /*******************************************************************
2902 reads or writes a structure.
2903 ********************************************************************/
2905 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
2906 prs_struct *ps, int depth)
2912 prs_debug(ps, depth, desc, "samr_io_gids");
2918 if(!prs_uint32("num_gids", ps, depth, num_gids))
2921 if ((*num_gids) != 0) {
2922 if (UNMARSHALLING(ps)) {
2923 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
2926 if ((*gid) == NULL) {
2930 for (i = 0; i < (*num_gids); i++) {
2931 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
2939 /*******************************************************************
2940 reads or writes a structure.
2941 ********************************************************************/
2943 BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
2944 prs_struct *ps, int depth)
2949 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
2955 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
2958 if (r_u->ptr_0 != 0) {
2959 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2961 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
2964 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
2965 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
2972 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2978 /*******************************************************************
2979 inits a SAMR_Q_ENUM_DOMAINS structure.
2980 ********************************************************************/
2982 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
2984 uint32 start_idx, uint32 size)
2986 DEBUG(5, ("init_samr_q_enum_domains\n"));
2990 q_e->start_idx = start_idx;
2991 q_e->max_size = size;
2994 /*******************************************************************
2995 reads or writes a structure.
2996 ********************************************************************/
2998 BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
2999 prs_struct *ps, int depth)
3004 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3010 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3013 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3015 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3021 /*******************************************************************
3022 inits a SAMR_R_ENUM_DOMAINS structure.
3023 ********************************************************************/
3025 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3026 uint32 next_idx, uint32 num_sam_entries)
3028 DEBUG(5, ("init_samr_r_enum_domains\n"));
3030 r_u->next_idx = next_idx;
3032 if (num_sam_entries != 0) {
3033 r_u->ptr_entries1 = 1;
3034 r_u->ptr_entries2 = 1;
3035 r_u->num_entries2 = num_sam_entries;
3036 r_u->num_entries3 = num_sam_entries;
3038 r_u->num_entries4 = num_sam_entries;
3040 r_u->ptr_entries1 = 0;
3041 r_u->num_entries2 = num_sam_entries;
3042 r_u->ptr_entries2 = 1;
3046 /*******************************************************************
3047 reads or writes a structure.
3048 ********************************************************************/
3050 BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3051 prs_struct *ps, int depth)
3058 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3064 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3066 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3069 if (r_u->ptr_entries1 != 0) {
3070 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3072 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3074 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3077 if (UNMARSHALLING(ps)) {
3078 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3079 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3082 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3083 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3084 r_u->num_entries4 = 0;
3085 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3089 for (i = 0; i < r_u->num_entries2; i++) {
3091 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3092 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3096 for (i = 0; i < r_u->num_entries2; i++) {
3098 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3099 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3100 r_u->sam[i].hdr_name.buffer, ps,
3109 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3111 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3117 /*******************************************************************
3118 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3119 ********************************************************************/
3121 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3123 uint32 start_idx, uint32 size)
3125 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3129 q_e->start_idx = start_idx;
3130 q_e->max_size = size;
3133 /*******************************************************************
3134 reads or writes a structure.
3135 ********************************************************************/
3137 BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3138 prs_struct *ps, int depth)
3143 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3149 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3152 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3154 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3160 /*******************************************************************
3161 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3162 ********************************************************************/
3164 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3165 uint32 next_idx, uint32 num_sam_entries)
3167 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3169 r_u->next_idx = next_idx;
3171 if (num_sam_entries != 0) {
3172 r_u->ptr_entries1 = 1;
3173 r_u->ptr_entries2 = 1;
3174 r_u->num_entries2 = num_sam_entries;
3175 r_u->num_entries3 = num_sam_entries;
3177 r_u->num_entries4 = num_sam_entries;
3179 r_u->ptr_entries1 = 0;
3180 r_u->num_entries2 = num_sam_entries;
3181 r_u->ptr_entries2 = 1;
3185 /*******************************************************************
3186 reads or writes a structure.
3187 ********************************************************************/
3189 BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3190 prs_struct *ps, int depth)
3197 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3203 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3205 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3208 if (r_u->ptr_entries1 != 0) {
3209 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3211 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3213 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3216 if (UNMARSHALLING(ps)) {
3217 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3218 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3221 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3223 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3224 r_u->num_entries4 = 0;
3225 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3229 for (i = 0; i < r_u->num_entries2; i++) {
3230 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3234 for (i = 0; i < r_u->num_entries2; i++) {
3235 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3236 r_u->sam[i].hdr_name.buffer, ps, depth))
3243 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3245 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3251 /*******************************************************************
3252 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3253 ********************************************************************/
3255 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3256 POLICY_HND *pol, uint32 start_idx,
3259 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3263 q_e->start_idx = start_idx;
3264 q_e->max_size = size;
3268 /*******************************************************************
3269 reads or writes a structure.
3270 ********************************************************************/
3272 BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3273 prs_struct *ps, int depth)
3278 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3284 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3287 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3289 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3295 /*******************************************************************
3296 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3297 ********************************************************************/
3299 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3301 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3303 r_u->next_idx = next_idx;
3305 if (num_sam_entries != 0) {
3306 r_u->ptr_entries1 = 1;
3307 r_u->ptr_entries2 = 1;
3308 r_u->num_entries2 = num_sam_entries;
3309 r_u->num_entries3 = num_sam_entries;
3311 r_u->num_entries4 = num_sam_entries;
3313 r_u->ptr_entries1 = 0;
3314 r_u->num_entries2 = num_sam_entries;
3315 r_u->ptr_entries2 = 1;
3319 /*******************************************************************
3320 reads or writes a structure.
3321 ********************************************************************/
3323 BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3324 prs_struct *ps, int depth)
3331 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3337 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3339 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3342 if (r_u->ptr_entries1 != 0) {
3343 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3345 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3347 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3350 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3351 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3352 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3355 if (r_u->num_entries2 != 0 &&
3356 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3357 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3358 r_u->num_entries4 = 0;
3359 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3363 for (i = 0; i < r_u->num_entries2; i++) {
3364 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3368 for (i = 0; i < r_u->num_entries2; i++) {
3369 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3370 r_u->sam[i].hdr_name.buffer, ps,
3378 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3380 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3386 /*******************************************************************
3387 inits a ALIAS_INFO1 structure.
3388 ********************************************************************/
3390 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3392 int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0;
3393 int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0;
3395 DEBUG(5, ("init_samr_alias_info1\n"));
3397 init_uni_hdr(&al1->hdr_acct_name, acct_len_name);
3398 init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name);
3400 al1->num_member=num_member;
3402 init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc);
3403 init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc);
3406 /*******************************************************************
3407 reads or writes a structure.
3408 ********************************************************************/
3410 BOOL samr_io_alias_info1(char *desc, ALIAS_INFO1 * al1,
3411 prs_struct *ps, int depth)
3416 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3422 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3424 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3426 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3429 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3430 al1->hdr_acct_name.buffer, ps, depth))
3436 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3437 al1->hdr_acct_desc.buffer, ps, depth))
3443 /*******************************************************************
3444 inits a ALIAS_INFO3 structure.
3445 ********************************************************************/
3447 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3449 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3451 DEBUG(5, ("init_samr_alias_info3\n"));
3453 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3454 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3457 /*******************************************************************
3458 reads or writes a structure.
3459 ********************************************************************/
3461 BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
3462 prs_struct *ps, int depth)
3467 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3473 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3475 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3476 al3->hdr_acct_desc.buffer, ps, depth))
3482 /*******************************************************************
3483 reads or writes a structure.
3484 ********************************************************************/
3486 BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
3487 prs_struct *ps, int depth)
3492 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3495 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3497 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3500 switch (ctr->switch_value1) {
3502 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3506 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3510 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3517 /*******************************************************************
3518 inits a SAMR_Q_QUERY_ALIASINFO structure.
3519 ********************************************************************/
3521 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3522 POLICY_HND *pol, uint16 switch_level)
3524 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3527 q_e->switch_level = switch_level;
3530 /*******************************************************************
3531 reads or writes a structure.
3532 ********************************************************************/
3534 BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3535 prs_struct *ps, int depth)
3540 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3546 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3549 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3555 /*******************************************************************
3556 inits a SAMR_R_QUERY_ALIASINFO structure.
3557 ********************************************************************/
3559 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3560 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3562 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3564 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3566 r_u->status = status;
3569 /*******************************************************************
3570 reads or writes a structure.
3571 ********************************************************************/
3573 BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3574 prs_struct *ps, int depth)
3579 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3585 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3588 if (r_u->ptr != 0) {
3589 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3595 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3601 /*******************************************************************
3602 inits a SAMR_Q_SET_ALIASINFO structure.
3603 ********************************************************************/
3605 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3606 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3608 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3610 q_u->alias_pol = *hnd;
3614 /*******************************************************************
3615 reads or writes a structure.
3616 ********************************************************************/
3618 BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3619 prs_struct *ps, int depth)
3624 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3630 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3632 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3638 /*******************************************************************
3639 reads or writes a structure.
3640 ********************************************************************/
3642 BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
3643 prs_struct *ps, int depth)
3648 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3653 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3659 /*******************************************************************
3660 inits a SAMR_Q_QUERY_USERALIASES structure.
3661 ********************************************************************/
3663 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3666 uint32 *ptr_sid, DOM_SID2 * sid)
3668 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3672 q_u->num_sids1 = num_sids;
3674 q_u->num_sids2 = num_sids;
3676 q_u->ptr_sid = ptr_sid;
3680 /*******************************************************************
3681 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3682 ********************************************************************/
3684 BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3685 prs_struct *ps, int depth)
3693 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3699 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3702 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3704 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3710 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3713 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3714 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3715 if (q_u->ptr_sid == NULL)
3718 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3719 if (q_u->sid == NULL)
3723 for (i = 0; i < q_u->num_sids2; i++) {
3724 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3725 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3729 for (i = 0; i < q_u->num_sids2; i++) {
3730 if (q_u->ptr_sid[i] != 0) {
3731 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3732 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3740 /*******************************************************************
3741 inits a SAMR_R_QUERY_USERALIASES structure.
3742 ********************************************************************/
3744 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3745 uint32 num_rids, uint32 *rid,
3748 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3750 if (NT_STATUS_IS_OK(status)) {
3751 r_u->num_entries = num_rids;
3753 r_u->num_entries2 = num_rids;
3757 r_u->num_entries = 0;
3759 r_u->num_entries2 = 0;
3762 r_u->status = status;
3765 /*******************************************************************
3766 reads or writes a structure.
3767 ********************************************************************/
3769 BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
3770 prs_struct *ps, int depth)
3777 prs_debug(ps, depth, desc, "samr_io_rids");
3783 if(!prs_uint32("num_rids", ps, depth, num_rids))
3786 if ((*num_rids) != 0) {
3787 if (UNMARSHALLING(ps)) {
3789 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3794 for (i = 0; i < (*num_rids); i++) {
3795 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3796 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3804 /*******************************************************************
3805 reads or writes a structure.
3806 ********************************************************************/
3808 BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3809 prs_struct *ps, int depth)
3814 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3820 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3822 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3825 if (r_u->ptr != 0) {
3826 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3832 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3838 /*******************************************************************
3839 inits a SAMR_Q_OPEN_ALIAS structure.
3840 ********************************************************************/
3842 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3843 uint32 access_mask, uint32 rid)
3845 DEBUG(5, ("init_samr_q_open_alias\n"));
3847 q_u->dom_pol = *pol;
3848 q_u->access_mask = access_mask;
3849 q_u->rid_alias = rid;
3852 /*******************************************************************
3853 reads or writes a structure.
3854 ********************************************************************/
3856 BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3857 prs_struct *ps, int depth)
3862 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3868 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3871 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3873 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3879 /*******************************************************************
3880 reads or writes a structure.
3881 ********************************************************************/
3883 BOOL samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS * r_u,
3884 prs_struct *ps, int depth)
3889 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3895 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3898 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3904 /*******************************************************************
3905 inits a SAMR_Q_LOOKUP_RIDS structure.
3906 ********************************************************************/
3908 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3909 POLICY_HND *pol, uint32 flags,
3910 uint32 num_rids, uint32 *rid)
3912 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3916 q_u->num_rids1 = num_rids;
3919 q_u->num_rids2 = num_rids;
3920 q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0]));
3921 if (q_u->rid == NULL) {
3925 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
3929 /*******************************************************************
3930 reads or writes a structure.
3931 ********************************************************************/
3933 BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
3934 prs_struct *ps, int depth)
3942 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
3945 if (UNMARSHALLING(ps))
3951 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3954 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
3956 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
3958 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3960 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
3963 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
3964 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
3965 if (q_u->rid == NULL)
3969 for (i = 0; i < q_u->num_rids2; i++) {
3970 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
3971 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
3978 /*******************************************************************
3979 inits a SAMR_R_LOOKUP_RIDS structure.
3980 ********************************************************************/
3982 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
3983 uint32 num_names, UNIHDR * hdr_name,
3984 UNISTR2 *uni_name, uint32 *type)
3986 DEBUG(5, ("init_samr_r_lookup_rids\n"));
3988 r_u->hdr_name = NULL;
3989 r_u->uni_name = NULL;
3992 if (num_names != 0) {
3993 r_u->num_names1 = num_names;
3995 r_u->num_names2 = num_names;
3997 r_u->num_types1 = num_names;
3999 r_u->num_types2 = num_names;
4001 r_u->hdr_name = hdr_name;
4002 r_u->uni_name = uni_name;
4005 r_u->num_names1 = num_names;
4007 r_u->num_names2 = num_names;
4009 r_u->num_types1 = num_names;
4011 r_u->num_types2 = num_names;
4015 /*******************************************************************
4016 reads or writes a structure.
4017 ********************************************************************/
4019 BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4020 prs_struct *ps, int depth)
4027 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4033 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4035 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4038 if (r_u->ptr_names != 0) {
4040 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4044 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4045 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
4046 if (r_u->hdr_name == NULL)
4049 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
4050 if (r_u->uni_name == NULL)
4054 for (i = 0; i < r_u->num_names2; i++) {
4055 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4056 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4059 for (i = 0; i < r_u->num_names2; i++) {
4060 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4061 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4069 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4071 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4074 if (r_u->ptr_types != 0) {
4076 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4079 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4080 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
4081 if (r_u->type == NULL)
4085 for (i = 0; i < r_u->num_types2; i++) {
4086 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4087 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4092 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4098 /*******************************************************************
4099 inits a SAMR_Q_OPEN_ALIAS structure.
4100 ********************************************************************/
4102 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4104 DEBUG(5, ("init_samr_q_delete_alias\n"));
4106 q_u->alias_pol = *hnd;
4109 /*******************************************************************
4110 reads or writes a structure.
4111 ********************************************************************/
4113 BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4114 prs_struct *ps, int depth)
4119 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4125 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4131 /*******************************************************************
4132 reads or writes a structure.
4133 ********************************************************************/
4135 BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4136 prs_struct *ps, int depth)
4141 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4147 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4149 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4155 /*******************************************************************
4156 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4157 ********************************************************************/
4159 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4160 POLICY_HND *hnd, char *acct_desc)
4162 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
4164 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4166 q_u->dom_pol = *hnd;
4168 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
4169 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
4171 q_u->access_mask = 0x001f000f;
4174 /*******************************************************************
4175 reads or writes a structure.
4176 ********************************************************************/
4178 BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4179 prs_struct *ps, int depth)
4184 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4190 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4193 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4195 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4196 q_u->hdr_acct_desc.buffer, ps, depth))
4201 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4207 /*******************************************************************
4208 reads or writes a structure.
4209 ********************************************************************/
4211 BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4212 prs_struct *ps, int depth)
4217 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4223 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4226 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4229 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4235 /*******************************************************************
4236 inits a SAMR_Q_ADD_ALIASMEM structure.
4237 ********************************************************************/
4239 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4242 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4244 q_u->alias_pol = *hnd;
4245 init_dom_sid2(&q_u->sid, sid);
4248 /*******************************************************************
4249 reads or writes a structure.
4250 ********************************************************************/
4252 BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4253 prs_struct *ps, int depth)
4258 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4264 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4266 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4272 /*******************************************************************
4273 reads or writes a structure.
4274 ********************************************************************/
4276 BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4277 prs_struct *ps, int depth)
4282 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4288 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4294 /*******************************************************************
4295 inits a SAMR_Q_DEL_ALIASMEM structure.
4296 ********************************************************************/
4298 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4301 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4303 q_u->alias_pol = *hnd;
4304 init_dom_sid2(&q_u->sid, sid);
4307 /*******************************************************************
4308 reads or writes a structure.
4309 ********************************************************************/
4311 BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4312 prs_struct *ps, int depth)
4317 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4323 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4325 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4331 /*******************************************************************
4332 reads or writes a structure.
4333 ********************************************************************/
4335 BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4336 prs_struct *ps, int depth)
4341 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4347 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4353 /*******************************************************************
4354 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4355 ********************************************************************/
4357 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4360 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4362 q_c->alias_pol = *hnd;
4365 /*******************************************************************
4366 reads or writes a structure.
4367 ********************************************************************/
4369 BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4370 prs_struct *ps, int depth)
4375 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4381 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4387 /*******************************************************************
4388 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4389 ********************************************************************/
4391 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4394 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4396 r_u->status = status;
4399 /*******************************************************************
4400 reads or writes a structure.
4401 ********************************************************************/
4403 BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4404 prs_struct *ps, int depth)
4409 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4415 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4421 /*******************************************************************
4422 inits a SAMR_Q_QUERY_ALIASMEM structure.
4423 ********************************************************************/
4425 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4428 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4430 q_c->alias_pol = *hnd;
4433 /*******************************************************************
4434 reads or writes a structure.
4435 ********************************************************************/
4437 BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4438 prs_struct *ps, int depth)
4443 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4449 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4455 /*******************************************************************
4456 inits a SAMR_R_QUERY_ALIASMEM structure.
4457 ********************************************************************/
4459 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4460 uint32 num_sids, DOM_SID2 * sid,
4463 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4465 if (NT_STATUS_IS_OK(status)) {
4466 r_u->num_sids = num_sids;
4467 r_u->ptr = (num_sids != 0) ? 1 : 0;
4468 r_u->num_sids1 = num_sids;
4476 r_u->status = status;
4479 /*******************************************************************
4480 reads or writes a structure.
4481 ********************************************************************/
4483 BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4484 prs_struct *ps, int depth)
4487 uint32 ptr_sid[MAX_LOOKUP_SIDS];
4492 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4498 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4500 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4503 if (r_u->ptr != 0) {
4504 SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids);
4506 if (r_u->num_sids != 0) {
4507 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4510 for (i = 0; i < r_u->num_sids1; i++) {
4512 if(!prs_uint32("", ps, depth, &ptr_sid[i]))
4516 for (i = 0; i < r_u->num_sids1; i++) {
4517 if (ptr_sid[i] != 0) {
4518 if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth))
4527 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4533 /*******************************************************************
4534 inits a SAMR_Q_LOOKUP_NAMES structure.
4535 ********************************************************************/
4537 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4538 POLICY_HND *pol, uint32 flags,
4539 uint32 num_names, char **name)
4543 DEBUG(5, ("init_samr_q_lookup_names\n"));
4547 q_u->num_names1 = num_names;
4550 q_u->num_names2 = num_names;
4552 if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR))))
4553 return NT_STATUS_NO_MEMORY;
4555 if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2))))
4556 return NT_STATUS_NO_MEMORY;
4558 for (i = 0; i < num_names; i++) {
4559 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4560 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4561 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4564 return NT_STATUS_OK;
4567 /*******************************************************************
4568 reads or writes a structure.
4569 ********************************************************************/
4571 BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4572 prs_struct *ps, int depth)
4579 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4582 if (UNMARSHALLING(ps))
4588 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4591 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4593 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4595 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4597 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4600 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4601 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4603 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4605 if (!q_u->hdr_name || !q_u->uni_name)
4609 for (i = 0; i < q_u->num_names2; i++) {
4610 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4614 for (i = 0; i < q_u->num_names2; i++) {
4615 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4622 /*******************************************************************
4623 inits a SAMR_R_LOOKUP_NAMES structure.
4624 ********************************************************************/
4626 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4628 uint32 *rid, uint32 *type,
4631 DEBUG(5, ("init_samr_r_lookup_names\n"));
4633 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4636 r_u->num_types1 = num_rids;
4638 r_u->num_types2 = num_rids;
4640 r_u->num_rids1 = num_rids;
4642 r_u->num_rids2 = num_rids;
4644 if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4645 return NT_STATUS_NO_MEMORY;
4646 if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4647 return NT_STATUS_NO_MEMORY;
4649 if (!r_u->rids || !r_u->types)
4652 for (i = 0; i < num_rids; i++) {
4653 r_u->rids[i] = rid[i];
4654 r_u->types[i] = type[i];
4659 r_u->num_types1 = 0;
4661 r_u->num_types2 = 0;
4671 r_u->status = status;
4673 return NT_STATUS_OK;
4676 /*******************************************************************
4677 reads or writes a structure.
4678 ********************************************************************/
4680 BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4681 prs_struct *ps, int depth)
4689 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4692 if (UNMARSHALLING(ps))
4698 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4700 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4703 if (r_u->ptr_rids != 0) {
4704 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4707 if (r_u->num_rids2 != r_u->num_rids1) {
4712 if (UNMARSHALLING(ps))
4713 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4716 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4720 for (i = 0; i < r_u->num_rids2; i++) {
4721 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4722 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4727 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4729 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4732 if (r_u->ptr_types != 0) {
4733 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4736 if (r_u->num_types2 != r_u->num_types1) {
4741 if (UNMARSHALLING(ps))
4742 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4745 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4749 for (i = 0; i < r_u->num_types2; i++) {
4750 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4751 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4756 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4762 /*******************************************************************
4763 inits a SAMR_Q_DELETE_DOM_USER structure.
4764 ********************************************************************/
4766 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4769 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4771 q_c->user_pol = *hnd;
4774 /*******************************************************************
4775 reads or writes a structure.
4776 ********************************************************************/
4778 BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4779 prs_struct *ps, int depth)
4784 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4790 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4796 /*******************************************************************
4797 reads or writes a structure.
4798 ********************************************************************/
4800 BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4801 prs_struct *ps, int depth)
4806 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4812 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4814 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4820 /*******************************************************************
4821 reads or writes a structure.
4822 ********************************************************************/
4824 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4826 uint32 access_mask, uint32 rid)
4828 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4830 q_u->domain_pol = *pol;
4831 q_u->access_mask = access_mask;
4832 q_u->user_rid = rid;
4835 /*******************************************************************
4836 reads or writes a structure.
4837 ********************************************************************/
4839 BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
4840 prs_struct *ps, int depth)
4845 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4851 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4854 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4856 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4862 /*******************************************************************
4863 reads or writes a structure.
4864 ********************************************************************/
4866 BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
4867 prs_struct *ps, int depth)
4872 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4878 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4881 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4888 /*******************************************************************
4889 reads or writes a structure.
4890 ********************************************************************/
4892 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4895 uint32 acb_info, uint32 access_mask)
4898 len_name = strlen(name);
4900 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4902 q_u->domain_pol = *pol;
4904 init_uni_hdr(&q_u->hdr_name, len_name);
4905 init_unistr2(&q_u->uni_name, name, len_name);
4907 q_u->acb_info = acb_info;
4908 q_u->access_mask = access_mask;
4911 /*******************************************************************
4912 reads or writes a structure.
4913 ********************************************************************/
4915 BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
4916 prs_struct *ps, int depth)
4921 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4927 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4930 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
4932 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
4937 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
4939 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4945 /*******************************************************************
4946 reads or writes a structure.
4947 ********************************************************************/
4949 BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
4950 prs_struct *ps, int depth)
4955 prs_debug(ps, depth, desc, "samr_io_r_create_user");
4961 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4964 if(!prs_uint32("unknown_0", ps, depth, &r_u->unknown_0))
4966 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
4968 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4974 /*******************************************************************
4975 inits a SAMR_Q_QUERY_USERINFO structure.
4976 ********************************************************************/
4978 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
4979 POLICY_HND *hnd, uint16 switch_value)
4981 DEBUG(5, ("init_samr_q_query_userinfo\n"));
4984 q_u->switch_value = switch_value;
4987 /*******************************************************************
4988 reads or writes a structure.
4989 ********************************************************************/
4991 BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
4992 prs_struct *ps, int depth)
4997 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5003 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5006 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5012 /*******************************************************************
5013 reads or writes a LOGON_HRS structure.
5014 ********************************************************************/
5016 static BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs,
5017 prs_struct *ps, int depth)
5022 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5028 if(!prs_uint32("len ", ps, depth, &hrs->len))
5031 if (hrs->len > sizeof(hrs->hours)) {
5032 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5033 hrs->len = sizeof(hrs->hours);
5036 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5042 /*******************************************************************
5043 inits a SAM_USER_INFO_12 structure.
5044 ********************************************************************/
5046 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5047 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5049 DEBUG(5, ("init_sam_user_info12\n"));
5051 usr->lm_pwd_active =
5052 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5053 usr->nt_pwd_active =
5054 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5057 /*******************************************************************
5058 reads or writes a structure.
5059 ********************************************************************/
5061 static BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
5062 prs_struct *ps, int depth)
5067 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5073 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5075 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5078 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5080 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5086 /*******************************************************************
5087 inits a SAM_USER_INFO_10 structure.
5088 ********************************************************************/
5090 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5092 DEBUG(5, ("init_sam_user_info10\n"));
5094 usr->acb_info = acb_info;
5097 /*******************************************************************
5098 reads or writes a structure.
5099 ********************************************************************/
5101 static BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
5102 prs_struct *ps, int depth)
5107 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5113 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5119 /*******************************************************************
5120 inits a SAM_USER_INFO_11 structure.
5121 ********************************************************************/
5123 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5126 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5130 DEBUG(5, ("init_sam_user_info11\n"));
5132 len_mach_acct = strlen(mach_acct);
5134 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
5135 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5137 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
5138 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5140 usr->ptr_1 = 1; /* pointer */
5141 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5142 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5144 usr->ptr_2 = 1; /* pointer */
5145 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5147 usr->ptr_3 = 1; /* pointer */
5148 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5150 usr->rid_user = rid_user;
5151 usr->rid_group = rid_group;
5153 usr->acct_ctrl = acct_ctrl;
5154 usr->unknown_3 = 0x0000;
5156 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5157 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5159 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5160 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5162 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
5165 /*******************************************************************
5166 reads or writes a structure.
5167 ********************************************************************/
5169 static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
5170 prs_struct *ps, int depth)
5175 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5181 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5184 if(!smb_io_time("time", &usr->expiry, ps, depth))
5187 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5190 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5193 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5196 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5198 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5201 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5204 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5206 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5209 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5211 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5214 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5216 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5218 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5220 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5222 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5224 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5227 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5230 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5233 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5239 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5245 /*************************************************************************
5248 unknown_3 = 0x09f8 27fa
5249 unknown_5 = 0x0001 0000
5250 unknown_6 = 0x0000 04ec
5252 *************************************************************************/
5254 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5256 DEBUG(10, ("init_sam_user_info24:\n"));
5257 memcpy(usr->pass, newpass, sizeof(usr->pass));
5258 usr->pw_len = pw_len;
5261 /*******************************************************************
5262 reads or writes a structure.
5263 ********************************************************************/
5265 static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
5266 prs_struct *ps, int depth)
5271 prs_debug(ps, depth, desc, "sam_io_user_info24");
5277 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5281 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5282 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5291 /*************************************************************************
5292 init_sam_user_info23
5294 unknown_3 = 0x09f8 27fa
5295 unknown_5 = 0x0001 0000
5296 unknown_6 = 0x0000 04ec
5298 *************************************************************************/
5300 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5301 NTTIME * logoff_time, /* all zeros */
5302 NTTIME * kickoff_time, /* all zeros */
5303 NTTIME * pass_last_set_time, /* all zeros */
5304 NTTIME * pass_can_change_time, /* all zeros */
5305 NTTIME * pass_must_change_time, /* all zeros */
5316 uint32 user_rid, /* 0x0000 0000 */
5323 char newpass[516], uint32 unknown_6)
5325 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5326 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5327 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5328 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5329 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5330 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5331 int len_description = desc != NULL ? desc->uni_str_len : 0;
5332 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5333 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5334 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5336 usr->logon_time = *logon_time; /* all zeros */
5337 usr->logoff_time = *logoff_time; /* all zeros */
5338 usr->kickoff_time = *kickoff_time; /* all zeros */
5339 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5340 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5341 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5343 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5344 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5345 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5346 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5347 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5348 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5349 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5350 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5351 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5352 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5354 ZERO_STRUCT(usr->nt_pwd);
5355 ZERO_STRUCT(usr->lm_pwd);
5357 usr->user_rid = user_rid; /* 0x0000 0000 */
5358 usr->group_rid = group_rid;
5359 usr->acb_info = acb_info;
5360 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5362 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5363 usr->ptr_logon_hrs = hrs ? 1 : 0;
5365 ZERO_STRUCT(usr->padding1);
5367 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5369 memcpy(usr->pass, newpass, sizeof(usr->pass));
5371 copy_unistr2(&usr->uni_user_name, user_name);
5372 copy_unistr2(&usr->uni_full_name, full_name);
5373 copy_unistr2(&usr->uni_home_dir, home_dir);
5374 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5375 copy_unistr2(&usr->uni_logon_script, log_scr);
5376 copy_unistr2(&usr->uni_profile_path, prof_path);
5377 copy_unistr2(&usr->uni_acct_desc, desc);
5378 copy_unistr2(&usr->uni_workstations, wkstas);
5379 copy_unistr2(&usr->uni_unknown_str, unk_str);
5380 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5382 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5385 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5388 /*************************************************************************
5389 init_sam_user_info23
5391 unknown_3 = 0x09f8 27fa
5392 unknown_5 = 0x0001 0000
5393 unknown_6 = 0x0000 04ec
5395 *************************************************************************/
5397 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5398 NTTIME * logoff_time, /* all zeros */
5399 NTTIME * kickoff_time, /* all zeros */
5400 NTTIME * pass_last_set_time, /* all zeros */
5401 NTTIME * pass_can_change_time, /* all zeros */
5402 NTTIME * pass_must_change_time, /* all zeros */
5403 char *user_name, /* NULL */
5405 char *home_dir, char *dir_drive, char *log_scr,
5406 char *prof_path, char *desc, char *wkstas,
5407 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5408 uint32 group_rid, uint32 acb_info,
5409 uint32 unknown_3, uint16 logon_divs,
5410 LOGON_HRS * hrs, uint32 unknown_5,
5411 char newpass[516], uint32 unknown_6)
5413 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5414 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5415 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5416 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5417 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5418 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5419 int len_description = desc != NULL ? strlen(desc) : 0;
5420 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5421 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5422 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5424 usr->logon_time = *logon_time; /* all zeros */
5425 usr->logoff_time = *logoff_time; /* all zeros */
5426 usr->kickoff_time = *kickoff_time; /* all zeros */
5427 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5428 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5429 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5431 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5432 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5433 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5434 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5435 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5436 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5437 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5438 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5439 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5440 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5442 ZERO_STRUCT(usr->nt_pwd);
5443 ZERO_STRUCT(usr->lm_pwd);
5445 usr->user_rid = user_rid; /* 0x0000 0000 */
5446 usr->group_rid = group_rid;
5447 usr->acb_info = acb_info;
5448 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5450 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5451 usr->ptr_logon_hrs = hrs ? 1 : 0;
5453 ZERO_STRUCT(usr->padding1);
5455 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5457 memcpy(usr->pass, newpass, sizeof(usr->pass));
5459 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5460 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5461 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5462 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5463 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5464 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5465 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5466 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5467 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5468 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5470 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5473 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5476 /*******************************************************************
5477 reads or writes a structure.
5478 ********************************************************************/
5480 static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
5481 prs_struct *ps, int depth)
5486 prs_debug(ps, depth, desc, "sam_io_user_info23");
5492 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5494 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5496 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5498 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5500 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5502 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5505 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5507 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5509 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5511 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5513 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5515 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5517 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5519 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5521 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5523 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5526 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5528 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5531 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5533 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5535 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5538 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5540 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5544 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5546 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5548 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5551 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5554 /* here begins pointed-to data */
5556 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5559 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5562 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5565 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5568 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5571 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5574 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5577 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5580 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5583 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5586 /* ok, this is only guess-work (as usual) */
5587 if (usr->ptr_logon_hrs) {
5588 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5590 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5592 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5594 } else if (UNMARSHALLING(ps)) {
5602 /*******************************************************************
5603 reads or writes a structure.
5604 NB. This structure is *definately* incorrect. It's my best guess
5605 currently for W2K SP2. The password field is encrypted in a different
5606 way than normal... And there are definately other problems. JRA.
5607 ********************************************************************/
5609 static BOOL sam_io_user_info25(char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5614 prs_debug(ps, depth, desc, "sam_io_user_info23");
5620 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5622 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5624 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5626 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5628 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5630 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5633 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5635 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5637 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5639 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5641 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5643 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5645 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5647 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5649 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5651 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5654 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5656 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5659 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5661 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5663 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5666 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5669 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5672 /* here begins pointed-to data */
5674 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5677 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5680 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5683 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5686 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5689 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5692 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5695 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5698 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5701 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5704 #if 0 /* JRA - unknown... */
5705 /* ok, this is only guess-work (as usual) */
5706 if (usr->ptr_logon_hrs) {
5707 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5709 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5711 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5713 } else if (UNMARSHALLING(ps)) {
5723 /*************************************************************************
5724 init_sam_user_info21W
5726 unknown_3 = 0x00ff ffff
5727 unknown_5 = 0x0002 0000
5728 unknown_6 = 0x0000 04ec
5730 *************************************************************************/
5732 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5733 NTTIME * logon_time,
5734 NTTIME * logoff_time,
5735 NTTIME * kickoff_time,
5736 NTTIME * pass_last_set_time,
5737 NTTIME * pass_can_change_time,
5738 NTTIME * pass_must_change_time,
5757 uint32 unknown_5, uint32 unknown_6)
5759 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5760 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5761 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5762 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5763 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5764 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5765 int len_description = desc != NULL ? desc->uni_str_len : 0;
5766 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5767 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5768 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5770 usr->logon_time = *logon_time;
5771 usr->logoff_time = *logoff_time;
5772 usr->kickoff_time = *kickoff_time;
5773 usr->pass_last_set_time = *pass_last_set_time;
5774 usr->pass_can_change_time = *pass_can_change_time;
5775 usr->pass_must_change_time = *pass_must_change_time;
5777 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5778 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5779 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5780 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5781 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5782 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5783 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5784 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5785 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5786 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5788 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5789 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5791 usr->user_rid = user_rid;
5792 usr->group_rid = group_rid;
5793 usr->acb_info = acb_info;
5794 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5796 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5797 usr->ptr_logon_hrs = hrs ? 1 : 0;
5798 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5800 ZERO_STRUCT(usr->padding1);
5802 copy_unistr2(&usr->uni_user_name, user_name);
5803 copy_unistr2(&usr->uni_full_name, full_name);
5804 copy_unistr2(&usr->uni_home_dir, home_dir);
5805 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5806 copy_unistr2(&usr->uni_logon_script, log_scr);
5807 copy_unistr2(&usr->uni_profile_path, prof_path);
5808 copy_unistr2(&usr->uni_acct_desc, desc);
5809 copy_unistr2(&usr->uni_workstations, wkstas);
5810 copy_unistr2(&usr->uni_unknown_str, unk_str);
5811 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5813 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5816 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5819 /*************************************************************************
5820 init_sam_user_info21
5822 unknown_3 = 0x00ff ffff
5823 unknown_5 = 0x0002 0000
5824 unknown_6 = 0x0000 04ec
5826 *************************************************************************/
5828 void init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw)
5830 NTTIME logon_time, logoff_time, kickoff_time,
5831 pass_last_set_time, pass_can_change_time,
5832 pass_must_change_time;
5834 int len_user_name, len_full_name, len_home_dir,
5835 len_dir_drive, len_logon_script, len_profile_path,
5836 len_description, len_workstations, len_unknown_str,
5839 const char* user_name = pdb_get_username(pw);
5840 const char* full_name = pdb_get_fullname(pw);
5841 const char* home_dir = pdb_get_homedir(pw);
5842 const char* dir_drive = pdb_get_dirdrive(pw);
5843 const char* logon_script = pdb_get_logon_script(pw);
5844 const char* profile_path = pdb_get_profile_path(pw);
5845 const char* description = pdb_get_acct_desc(pw);
5846 const char* workstations = pdb_get_workstations(pw);
5847 const char* munged_dial = pdb_get_munged_dial(pw);
5849 len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
5850 len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
5851 len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
5852 len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
5853 len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
5854 len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
5855 len_description = description != NULL ? strlen(description )+1 : 0;
5856 len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
5857 len_unknown_str = 0;
5858 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
5861 /* Create NTTIME structs */
5862 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5863 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5864 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5865 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5866 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
5867 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
5869 /* structure assignment */
5870 usr->logon_time = logon_time;
5871 usr->logoff_time = logoff_time;
5872 usr->kickoff_time = kickoff_time;
5873 usr->pass_last_set_time = pass_last_set_time;
5874 usr->pass_can_change_time = pass_can_change_time;
5875 usr->pass_must_change_time = pass_must_change_time;
5877 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5878 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5879 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5880 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5881 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5882 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5883 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5884 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5885 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5886 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5888 ZERO_STRUCT(usr->nt_pwd);
5889 ZERO_STRUCT(usr->lm_pwd);
5891 usr->user_rid = pdb_get_user_rid(pw);
5892 usr->group_rid = pdb_get_group_rid(pw);
5893 usr->acb_info = pdb_get_acct_ctrl(pw);
5894 usr->unknown_3 = pdb_get_unknown3(pw);
5896 usr->logon_divs = pdb_get_logon_divs(pw);
5897 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
5898 usr->unknown_5 = pdb_get_unknown5(pw); /* 0x0002 0000 */
5900 ZERO_STRUCT(usr->padding1);
5902 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
5903 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5904 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5905 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5906 init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
5907 init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
5908 init_unistr2(&usr->uni_acct_desc, description, len_description);
5909 init_unistr2(&usr->uni_workstations, workstations, len_workstations);
5910 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
5911 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
5913 usr->unknown_6 = pdb_get_unknown6(pw);
5916 if (pdb_get_hours(pw)) {
5917 usr->logon_hrs.len = pdb_get_hours_len(pw);
5918 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
5920 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
5923 /*******************************************************************
5924 reads or writes a structure.
5925 ********************************************************************/
5927 static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
5928 prs_struct *ps, int depth)
5933 prs_debug(ps, depth, desc, "sam_io_user_info21");
5939 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5941 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5943 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
5945 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5947 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
5949 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5952 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5954 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5956 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5958 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5960 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5962 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5964 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5966 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5968 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5970 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5973 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5975 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5978 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5980 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5982 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5985 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5987 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5991 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5993 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5996 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5999 /* here begins pointed-to data */
6001 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6003 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6005 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6007 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6009 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6011 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6013 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6015 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6017 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6019 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6022 /* ok, this is only guess-work (as usual) */
6023 if (usr->ptr_logon_hrs) {
6026 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6028 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6030 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6032 } else if (UNMARSHALLING(ps)) {
6040 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6042 int len_munged_dial;
6043 const char* munged_dial = pdb_get_munged_dial(pw);
6045 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6046 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6047 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6051 /*******************************************************************
6052 reads or writes a structure.
6053 ********************************************************************/
6055 static BOOL sam_io_user_info20(char *desc, SAM_USER_INFO_20 *usr,
6056 prs_struct *ps, int depth)
6061 prs_debug(ps, depth, desc, "sam_io_user_info20");
6067 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6070 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6076 /*******************************************************************
6077 inits a SAM_USERINFO_CTR structure.
6078 ********************************************************************/
6080 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6081 uint16 switch_value,
6082 SAM_USER_INFO_21 * usr)
6084 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6086 ctr->switch_value = switch_value;
6087 ctr->info.id = NULL;
6089 switch (switch_value) {
6091 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
6092 if (ctr->info.id10 == NULL)
6093 return NT_STATUS_NO_MEMORY;
6095 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6098 /* whoops - got this wrong. i think. or don't understand what's happening. */
6102 info = (void *)&id11;
6104 expire.low = 0xffffffff;
6105 expire.high = 0x7fffffff;
6107 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
6108 init_sam_user_info11(ctr->info.id11, &expire,
6109 "BROOKFIELDS$", /* name */
6110 0x03ef, /* user rid */
6111 0x201, /* group rid */
6112 0x0080); /* acb info */
6118 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
6119 if (ctr->info.id12 == NULL)
6120 return NT_STATUS_NO_MEMORY;
6122 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6126 SAM_USER_INFO_21 *cusr;
6127 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
6128 ctr->info.id21 = cusr;
6129 if (ctr->info.id21 == NULL)
6130 return NT_STATUS_NO_MEMORY;
6131 memcpy(cusr, usr, sizeof(*usr));
6132 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6133 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6137 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6138 return NT_STATUS_INVALID_INFO_CLASS;
6141 return NT_STATUS_OK;
6144 /*******************************************************************
6145 inits a SAM_USERINFO_CTR structure.
6146 ********************************************************************/
6148 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
6149 uint16 switch_value, void *info)
6151 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6153 ctr->switch_value = switch_value;
6154 ctr->info.id = info;
6156 switch (switch_value) {
6158 SamOEMhash(ctr->info.id24->pass, sess_key, 516);
6159 dump_data(100, (char *)sess_key, 16);
6160 dump_data(100, (char *)ctr->info.id24->pass, 516);
6163 SamOEMhash(ctr->info.id23->pass, sess_key, 516);
6164 dump_data(100, (char *)sess_key, 16);
6165 dump_data(100, (char *)ctr->info.id23->pass, 516);
6168 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6172 /*******************************************************************
6173 reads or writes a structure.
6174 ********************************************************************/
6176 static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR **ppctr,
6177 prs_struct *ps, int depth)
6180 SAM_USERINFO_CTR *ctr;
6182 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6185 if (UNMARSHALLING(ps)) {
6186 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
6194 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6196 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6203 switch (ctr->switch_value) {
6205 if (UNMARSHALLING(ps))
6206 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
6207 if (ctr->info.id10 == NULL) {
6208 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6211 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6214 if (UNMARSHALLING(ps))
6215 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
6217 if (ctr->info.id11 == NULL) {
6218 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6221 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6224 if (UNMARSHALLING(ps))
6225 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
6227 if (ctr->info.id12 == NULL) {
6228 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6231 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6234 if (UNMARSHALLING(ps))
6235 ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20));
6237 if (ctr->info.id20 == NULL) {
6238 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6241 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6244 if (UNMARSHALLING(ps))
6245 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
6247 if (ctr->info.id21 == NULL) {
6248 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6251 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6254 if (UNMARSHALLING(ps))
6255 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
6257 if (ctr->info.id23 == NULL) {
6258 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6261 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6264 if (UNMARSHALLING(ps))
6265 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
6267 if (ctr->info.id24 == NULL) {
6268 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6271 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6274 if (UNMARSHALLING(ps))
6275 ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25));
6277 if (ctr->info.id25 == NULL) {
6278 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6281 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6284 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6292 /*******************************************************************
6293 inits a SAMR_R_QUERY_USERINFO structure.
6294 ********************************************************************/
6296 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6297 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6299 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6304 if (NT_STATUS_IS_OK(status)) {
6309 r_u->status = status; /* return status */
6312 /*******************************************************************
6313 reads or writes a structure.
6314 ********************************************************************/
6316 BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
6317 prs_struct *ps, int depth)
6322 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6328 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6331 if (r_u->ptr != 0) {
6332 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6338 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6344 /*******************************************************************
6345 inits a SAMR_Q_SET_USERINFO structure.
6346 ********************************************************************/
6348 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6349 POLICY_HND *hnd, unsigned char sess_key[16],
6350 uint16 switch_value, void *info)
6352 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6355 q_u->switch_value = switch_value;
6356 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6359 /*******************************************************************
6360 reads or writes a structure.
6361 ********************************************************************/
6363 BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
6364 prs_struct *ps, int depth)
6369 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6375 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6377 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6379 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6385 /*******************************************************************
6386 inits a SAMR_R_SET_USERINFO structure.
6387 ********************************************************************/
6389 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6391 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6393 r_u->status = status; /* return status */
6396 /*******************************************************************
6397 reads or writes a structure.
6398 ********************************************************************/
6400 BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
6401 prs_struct *ps, int depth)
6406 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6412 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6418 /*******************************************************************
6419 inits a SAMR_Q_SET_USERINFO2 structure.
6420 ********************************************************************/
6422 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6423 POLICY_HND *hnd, unsigned char sess_key[16],
6424 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6426 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6429 q_u->switch_value = switch_value;
6432 if (q_u->ctr != NULL)
6433 q_u->ctr->switch_value = switch_value;
6435 switch (switch_value) {
6437 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16);
6438 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16);
6439 dump_data(100, (char *)sess_key, 16);
6440 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6441 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6446 /*******************************************************************
6447 reads or writes a structure.
6448 ********************************************************************/
6450 BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6451 prs_struct *ps, int depth)
6456 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6462 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6465 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6467 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6473 /*******************************************************************
6474 inits a SAMR_R_SET_USERINFO2 structure.
6475 ********************************************************************/
6477 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6479 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6481 r_u->status = status; /* return status */
6484 /*******************************************************************
6485 reads or writes a structure.
6486 ********************************************************************/
6488 BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
6489 prs_struct *ps, int depth)
6494 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6500 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6506 /*******************************************************************
6507 inits a SAMR_Q_CONNECT structure.
6508 ********************************************************************/
6510 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6511 char *srv_name, uint32 access_mask)
6513 int len_srv_name = strlen(srv_name);
6515 DEBUG(5, ("init_samr_q_connect\n"));
6517 /* make PDC server name \\server */
6518 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6519 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6521 /* example values: 0x0000 0002 */
6522 q_u->access_mask = access_mask;
6525 /*******************************************************************
6526 reads or writes a structure.
6527 ********************************************************************/
6529 BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
6530 prs_struct *ps, int depth)
6535 prs_debug(ps, depth, desc, "samr_io_q_connect");
6541 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6543 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6548 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6554 /*******************************************************************
6555 reads or writes a structure.
6556 ********************************************************************/
6558 BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
6559 prs_struct *ps, int depth)
6564 prs_debug(ps, depth, desc, "samr_io_r_connect");
6570 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6573 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6579 /*******************************************************************
6580 inits a SAMR_Q_CONNECT_ANON structure.
6581 ********************************************************************/
6583 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6585 DEBUG(5, ("init_samr_q_connect_anon\n"));
6588 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6589 q_u->unknown_1 = 0x01;
6590 q_u->access_mask = 0x20;
6593 /*******************************************************************
6594 reads or writes a structure.
6595 ********************************************************************/
6597 BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
6598 prs_struct *ps, int depth)
6603 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6609 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6611 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6613 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6615 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6621 /*******************************************************************
6622 reads or writes a structure.
6623 ********************************************************************/
6625 BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
6626 prs_struct *ps, int depth)
6631 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6637 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6640 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6646 /*******************************************************************
6647 inits a SAMR_Q_GET_DOM_PWINFO structure.
6648 ********************************************************************/
6650 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6653 int len_srv_name = strlen(srv_name);
6655 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6658 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6659 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6662 /*******************************************************************
6663 reads or writes a structure.
6664 ********************************************************************/
6666 BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6667 prs_struct *ps, int depth)
6672 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6678 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6680 if (q_u->ptr != 0) {
6681 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6683 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6690 /*******************************************************************
6691 reads or writes a structure.
6692 ********************************************************************/
6694 BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6695 prs_struct *ps, int depth)
6700 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6706 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
6710 if(!prs_uint16("unk_1", ps, depth, &r_u->unk_1))
6714 if(!prs_uint16("unk_2", ps, depth, &r_u->unk_2))
6719 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6725 /*******************************************************************
6726 make a SAMR_ENC_PASSWD structure.
6727 ********************************************************************/
6729 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
6737 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6741 /*******************************************************************
6742 reads or writes a SAMR_ENC_PASSWD structure.
6743 ********************************************************************/
6745 BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
6746 prs_struct *ps, int depth)
6751 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6757 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
6760 if (pwd->ptr != 0) {
6761 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
6768 /*******************************************************************
6769 inits a SAMR_ENC_HASH structure.
6770 ********************************************************************/
6772 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
6780 memcpy(hsh->hash, hash, sizeof(hsh->hash));
6784 /*******************************************************************
6785 reads or writes a SAMR_ENC_HASH structure.
6786 ********************************************************************/
6788 BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
6789 prs_struct *ps, int depth)
6794 prs_debug(ps, depth, desc, "samr_io_enc_hash");
6800 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
6802 if (hsh->ptr != 0) {
6803 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
6810 /*******************************************************************
6811 inits a SAMR_R_GET_DOM_PWINFO structure.
6812 ********************************************************************/
6814 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
6815 char *dest_host, char *user_name,
6816 char nt_newpass[516],
6817 uchar nt_oldhash[16],
6818 char lm_newpass[516],
6819 uchar lm_oldhash[16])
6821 int len_dest_host = strlen(dest_host);
6822 int len_user_name = strlen(user_name);
6824 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
6827 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
6828 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
6829 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
6830 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
6832 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
6833 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
6835 q_u->unknown = 0x01;
6837 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
6838 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
6841 /*******************************************************************
6842 reads or writes a structure.
6843 ********************************************************************/
6845 BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
6846 prs_struct *ps, int depth)
6851 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
6857 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
6860 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
6862 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
6867 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
6869 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
6872 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
6874 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
6877 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
6880 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
6882 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
6888 /*******************************************************************
6889 inits a SAMR_R_CHGPASSWD_USER structure.
6890 ********************************************************************/
6892 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
6894 DEBUG(5, ("init_r_chgpasswd_user\n"));
6896 r_u->status = status;
6899 /*******************************************************************
6900 reads or writes a structure.
6901 ********************************************************************/
6903 BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
6904 prs_struct *ps, int depth)
6909 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
6915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6921 /*******************************************************************
6922 reads or writes a structure.
6923 ********************************************************************/
6925 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
6926 POLICY_HND *domain_pol, uint16 switch_value)
6928 DEBUG(5, ("init_samr_q_unknown_2e\n"));
6930 q_u->domain_pol = *domain_pol;
6931 q_u->switch_value = switch_value;
6934 /*******************************************************************
6935 reads or writes a structure.
6936 ********************************************************************/
6938 BOOL samr_io_q_unknown_2e(char *desc, SAMR_Q_UNKNOWN_2E *q_u,
6939 prs_struct *ps, int depth)
6944 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
6950 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
6953 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6959 /*******************************************************************
6960 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
6961 ********************************************************************/
6963 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
6964 uint16 switch_value, SAM_UNK_CTR * ctr,
6967 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
6970 r_u->switch_value = 0;
6971 r_u->status = status; /* return status */
6973 if (NT_STATUS_IS_OK(status)) {
6974 r_u->switch_value = switch_value;
6980 /*******************************************************************
6981 reads or writes a structure.
6982 ********************************************************************/
6984 BOOL samr_io_r_samr_unknown_2e(char *desc, SAMR_R_UNKNOWN_2E * r_u,
6985 prs_struct *ps, int depth)
6990 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
6996 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
6999 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7000 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7005 switch (r_u->switch_value) {
7007 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7011 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7015 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7019 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7023 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7027 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7031 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7035 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7036 r_u->switch_value));
7037 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7045 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7052 /*******************************************************************
7053 reads or writes a structure.
7054 ********************************************************************/
7056 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7057 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7059 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7061 q_u->domain_pol = *domain_pol;
7062 q_u->switch_value0 = switch_value;
7064 q_u->switch_value = switch_value;
7069 /*******************************************************************
7070 reads or writes a structure.
7071 ********************************************************************/
7073 BOOL samr_io_q_set_domain_info(char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7074 prs_struct *ps, int depth)
7079 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7085 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7088 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7091 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7097 if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL)
7100 switch (q_u->switch_value) {
7103 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7107 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7111 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7115 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7119 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7123 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7127 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7131 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7132 q_u->switch_value));
7139 /*******************************************************************
7140 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7141 ********************************************************************/
7143 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7145 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7147 r_u->status = status; /* return status */
7150 /*******************************************************************
7151 reads or writes a structure.
7152 ********************************************************************/
7154 BOOL samr_io_r_set_domain_info(char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7155 prs_struct *ps, int depth)
7160 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7166 if(!prs_ntstatus("status", ps, depth, &r_u->status))