2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Paul Ashton 1997-2000,
7 * Copyright (C) Elrond 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Jean François Micouleau 1998-2001,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #define DBGC_CLASS DBGC_RPC_PARSE
32 /*******************************************************************
33 inits a SAMR_Q_CLOSE_HND structure.
34 ********************************************************************/
36 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
38 DEBUG(5, ("init_samr_q_close_hnd\n"));
43 /*******************************************************************
44 reads or writes a structure.
45 ********************************************************************/
47 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
48 prs_struct *ps, int depth)
53 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
59 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
62 /*******************************************************************
63 reads or writes a structure.
64 ********************************************************************/
66 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
67 prs_struct *ps, int depth)
72 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
78 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
81 if(!prs_ntstatus("status", ps, depth, &r_u->status))
87 /*******************************************************************
88 inits a SAMR_Q_LOOKUP_DOMAIN structure.
89 ********************************************************************/
91 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
92 POLICY_HND *pol, char *dom_name)
94 DEBUG(5, ("init_samr_q_lookup_domain\n"));
96 q_u->connect_pol = *pol;
98 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
99 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
102 /*******************************************************************
103 reads or writes a structure.
104 ********************************************************************/
105 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
106 prs_struct *ps, int depth)
111 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
117 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
120 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
123 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
129 /*******************************************************************
130 inits a SAMR_R_LOOKUP_DOMAIN structure.
131 ********************************************************************/
133 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
134 DOM_SID *dom_sid, NTSTATUS status)
136 DEBUG(5, ("init_samr_r_lookup_domain\n"));
138 r_u->status = status;
140 if (NT_STATUS_IS_OK(status)) {
142 init_dom_sid2(&r_u->dom_sid, dom_sid);
146 /*******************************************************************
147 reads or writes a structure.
148 ********************************************************************/
150 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
151 prs_struct *ps, int depth)
156 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
162 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
165 if (r_u->ptr_sid != 0) {
166 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
172 if(!prs_ntstatus("status", ps, depth, &r_u->status))
178 /*******************************************************************
179 reads or writes a structure.
180 ********************************************************************/
182 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
184 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
186 q_u->dom_pol = *dom_pol;
187 init_dom_sid2(&q_u->sid, sid);
190 /*******************************************************************
191 reads or writes a structure.
192 ********************************************************************/
194 BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
195 prs_struct *ps, int depth)
200 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
206 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
209 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
218 /*******************************************************************
219 reads or writes a structure.
220 ********************************************************************/
222 BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
223 prs_struct *ps, int depth)
228 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
234 if(!prs_ntstatus("status", ps, depth, &r_u->status))
240 /*******************************************************************
241 reads or writes a structure.
242 ********************************************************************/
244 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
245 POLICY_HND *pol, uint32 flags,
248 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
252 init_dom_sid2(&q_u->dom_sid, sid);
255 /*******************************************************************
256 reads or writes a structure.
257 ********************************************************************/
259 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
260 prs_struct *ps, int depth)
265 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
271 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
274 if(!prs_uint32("flags", ps, depth, &q_u->flags))
277 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
283 /*******************************************************************
284 reads or writes a structure.
285 ********************************************************************/
287 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
288 prs_struct *ps, int depth)
293 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
299 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
302 if(!prs_ntstatus("status", ps, depth, &r_u->status))
308 /*******************************************************************
309 reads or writes a structure.
310 ********************************************************************/
312 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
313 POLICY_HND *user_pol)
315 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
317 q_u->user_pol = *user_pol;
320 /*******************************************************************
321 reads or writes a structure.
322 ********************************************************************/
324 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
325 prs_struct *ps, int depth)
330 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
336 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
339 /*******************************************************************
341 ********************************************************************/
343 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
345 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
347 r_u->min_pwd_length = 0x0000;
351 * r_u->unknown_1 = 0x0015;
354 r_u->unknown_1 = 0x01D1;
355 r_u->unknown_1 = 0x0015;
357 r_u->password_properties = 0x00000000;
359 r_u->status = status;
362 /*******************************************************************
363 reads or writes a structure.
364 ********************************************************************/
366 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
367 prs_struct *ps, int depth)
372 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
378 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
380 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
382 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
385 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
392 /*******************************************************************
393 reads or writes a structure.
394 ********************************************************************/
396 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
397 prs_struct *ps, int depth)
402 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
408 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
411 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
414 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
421 /*******************************************************************
422 reads or writes a structure.
423 ********************************************************************/
425 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
426 POLICY_HND *user_pol, uint32 sec_info)
428 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
430 q_u->user_pol = *user_pol;
431 q_u->sec_info = sec_info;
435 /*******************************************************************
436 reads or writes a structure.
437 ********************************************************************/
439 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
440 prs_struct *ps, int depth)
445 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
451 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
454 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
460 /*******************************************************************
461 reads or writes a structure.
462 ********************************************************************/
464 void init_samr_q_query_domain_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
465 POLICY_HND *domain_pol, uint16 switch_value)
467 DEBUG(5, ("samr_init_samr_q_query_domain_info\n"));
469 q_u->domain_pol = *domain_pol;
470 q_u->switch_value = switch_value;
473 /*******************************************************************
474 reads or writes a structure.
475 ********************************************************************/
477 BOOL samr_io_q_query_domain_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
478 prs_struct *ps, int depth)
483 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info");
489 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
492 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
498 /*******************************************************************
500 ********************************************************************/
502 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
503 uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
505 u_1->min_length_password = min_pass_len;
506 u_1->password_history = pass_hist;
508 if (lp_check_password_script() && *lp_check_password_script()) {
509 password_properties |= DOMAIN_PASSWORD_COMPLEX;
511 u_1->password_properties = password_properties;
513 /* password never expire */
514 u_1->expire = nt_expire;
516 /* can change the password now */
517 u_1->min_passwordage = nt_min_age;
521 /*******************************************************************
522 reads or writes a structure.
523 ********************************************************************/
525 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
526 prs_struct *ps, int depth)
531 prs_debug(ps, depth, desc, "sam_io_unk_info1");
534 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
536 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
538 if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
540 if(!smb_io_time("expire", &u_1->expire, ps, depth))
542 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
548 /*******************************************************************
550 ********************************************************************/
552 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
553 const char *comment, const char *domain, const char *server,
554 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
556 u_2->logout = nt_logout;
558 u_2->seq_num = seq_num;
561 u_2->unknown_4 = 0x00000001;
562 u_2->server_role = server_role;
563 u_2->unknown_6 = 0x00000001;
564 u_2->num_domain_usrs = num_users;
565 u_2->num_domain_grps = num_groups;
566 u_2->num_local_grps = num_alias;
568 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
569 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
570 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
571 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
572 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
573 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
576 /*******************************************************************
577 reads or writes a structure.
578 ********************************************************************/
580 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
581 prs_struct *ps, int depth)
586 prs_debug(ps, depth, desc, "sam_io_unk_info2");
589 if(!smb_io_time("logout", &u_2->logout, ps, depth))
591 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
593 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
595 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
598 /* put all the data in here, at the moment, including what the above
599 pointer is referring to
602 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
605 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
607 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
609 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
611 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
613 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
615 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
618 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
620 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
622 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
628 /*******************************************************************
630 ********************************************************************/
632 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
634 u_3->logout = nt_logout;
637 /*******************************************************************
638 reads or writes a structure.
639 ********************************************************************/
641 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
642 prs_struct *ps, int depth)
647 prs_debug(ps, depth, desc, "sam_io_unk_info3");
650 if(!smb_io_time("logout", &u_3->logout, ps, depth))
656 /*******************************************************************
658 ********************************************************************/
660 void init_unk_info4(SAM_UNK_INFO_4 * u_4,const char *comment)
662 init_unistr2(&u_4->uni_comment, comment, UNI_FLAGS_NONE);
663 init_uni_hdr(&u_4->hdr_comment, &u_4->uni_comment);
666 /*******************************************************************
667 reads or writes a structure.
668 ********************************************************************/
670 static BOOL sam_io_unk_info4(const char *desc, SAM_UNK_INFO_4 * u_4,
671 prs_struct *ps, int depth)
676 prs_debug(ps, depth, desc, "sam_io_unk_info4");
679 if(!smb_io_unihdr("hdr_comment", &u_4->hdr_comment, ps, depth))
682 if(!smb_io_unistr2("uni_comment", &u_4->uni_comment, u_4->hdr_comment.buffer, ps, depth))
688 /*******************************************************************
690 ********************************************************************/
692 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *domain)
694 init_unistr2(&u_5->uni_domain, domain, UNI_FLAGS_NONE);
695 init_uni_hdr(&u_5->hdr_domain, &u_5->uni_domain);
698 /*******************************************************************
699 reads or writes a structure.
700 ********************************************************************/
702 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
703 prs_struct *ps, int depth)
708 prs_debug(ps, depth, desc, "sam_io_unk_info5");
711 if(!smb_io_unihdr("hdr_domain", &u_5->hdr_domain, ps, depth))
714 if(!smb_io_unistr2("uni_domain", &u_5->uni_domain, u_5->hdr_domain.buffer, ps, depth))
720 /*******************************************************************
722 ********************************************************************/
724 void init_unk_info6(SAM_UNK_INFO_6 * u_6, const char *server)
726 init_unistr2(&u_6->uni_server, server, UNI_FLAGS_NONE);
727 init_uni_hdr(&u_6->hdr_server, &u_6->uni_server);
730 /*******************************************************************
731 reads or writes a structure.
732 ********************************************************************/
734 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
735 prs_struct *ps, int depth)
740 prs_debug(ps, depth, desc, "sam_io_unk_info6");
743 if(!smb_io_unihdr("hdr_server", &u_6->hdr_server, ps, depth))
746 if(!smb_io_unistr2("uni_server", &u_6->uni_server, u_6->hdr_server.buffer, ps, depth))
752 /*******************************************************************
754 ********************************************************************/
756 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
758 u_7->server_role = server_role;
761 /*******************************************************************
762 reads or writes a structure.
763 ********************************************************************/
765 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
766 prs_struct *ps, int depth)
771 prs_debug(ps, depth, desc, "sam_io_unk_info7");
774 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
780 /*******************************************************************
782 ********************************************************************/
784 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
786 unix_to_nt_time(&u_8->domain_create_time, 0);
787 u_8->seq_num = seq_num;
790 /*******************************************************************
791 reads or writes a structure.
792 ********************************************************************/
794 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
795 prs_struct *ps, int depth)
800 prs_debug(ps, depth, desc, "sam_io_unk_info8");
803 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
806 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
812 /*******************************************************************
814 ********************************************************************/
816 void init_unk_info9(SAM_UNK_INFO_9 * u_9, uint32 unknown)
818 u_9->unknown = unknown;
821 /*******************************************************************
822 reads or writes a structure.
823 ********************************************************************/
825 static BOOL sam_io_unk_info9(const char *desc, SAM_UNK_INFO_9 * u_9,
826 prs_struct *ps, int depth)
831 prs_debug(ps, depth, desc, "sam_io_unk_info9");
834 if (!prs_uint32("unknown", ps, depth, &u_9->unknown))
840 /*******************************************************************
842 ********************************************************************/
844 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
846 u_12->duration = nt_lock_duration;
847 u_12->reset_count = nt_reset_time;
849 u_12->bad_attempt_lockout = lockout;
852 /*******************************************************************
853 reads or writes a structure.
854 ********************************************************************/
856 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
857 prs_struct *ps, int depth)
862 prs_debug(ps, depth, desc, "sam_io_unk_info12");
865 if(!smb_io_time("duration", &u_12->duration, ps, depth))
867 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
869 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
875 /*******************************************************************
877 ********************************************************************/
879 void init_unk_info13(SAM_UNK_INFO_13 * u_13, uint32 seq_num)
881 unix_to_nt_time(&u_13->domain_create_time, 0);
882 u_13->seq_num = seq_num;
887 /*******************************************************************
888 reads or writes a structure.
889 ********************************************************************/
891 static BOOL sam_io_unk_info13(const char *desc, SAM_UNK_INFO_13 * u_13,
892 prs_struct *ps, int depth)
897 prs_debug(ps, depth, desc, "sam_io_unk_info13");
900 if (!prs_uint64("seq_num", ps, depth, &u_13->seq_num))
903 if(!smb_io_time("domain_create_time", &u_13->domain_create_time, ps, depth))
906 if (!prs_uint32("unknown1", ps, depth, &u_13->unknown1))
908 if (!prs_uint32("unknown2", ps, depth, &u_13->unknown2))
914 /*******************************************************************
915 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
916 ********************************************************************/
918 void init_samr_r_query_domain_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
919 uint16 switch_value, SAM_UNK_CTR * ctr,
922 DEBUG(5, ("init_samr_r_query_domain_info\n"));
925 r_u->switch_value = 0;
926 r_u->status = status; /* return status */
928 if (NT_STATUS_IS_OK(status)) {
929 r_u->switch_value = switch_value;
935 /*******************************************************************
936 reads or writes a structure.
937 ********************************************************************/
939 BOOL samr_io_r_query_domain_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
940 prs_struct *ps, int depth)
945 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info");
951 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
954 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
955 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
960 switch (r_u->switch_value) {
962 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
966 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
970 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
974 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
978 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
982 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
986 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
990 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
994 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
998 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
1002 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
1006 DEBUG(0, ("samr_io_r_query_domain_info: unknown switch level 0x%x\n",
1007 r_u->switch_value));
1008 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
1016 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1022 /*******************************************************************
1023 reads or writes a structure.
1024 ********************************************************************/
1026 void init_samr_q_set_sec_obj(SAMR_Q_SET_SEC_OBJ * q_u,
1027 POLICY_HND *pol, uint32 sec_info, SEC_DESC_BUF *buf)
1029 DEBUG(5, ("samr_init_samr_q_set_sec_obj\n"));
1032 q_u->sec_info = sec_info;
1037 /*******************************************************************
1038 reads or writes a SAMR_R_SET_SEC_OBJ structure.
1039 ********************************************************************/
1041 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
1042 prs_struct *ps, int depth)
1047 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
1053 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1059 /*******************************************************************
1060 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
1061 ********************************************************************/
1063 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
1064 prs_struct *ps, int depth)
1069 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
1075 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
1077 if (r_u->ptr != 0) {
1078 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
1082 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1088 /*******************************************************************
1089 reads or writes a SAM_STR1 structure.
1090 ********************************************************************/
1092 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
1093 uint32 name_buf, uint32 desc_buf,
1094 prs_struct *ps, int depth)
1099 prs_debug(ps, depth, desc, "sam_io_sam_str1");
1104 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
1107 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
1110 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1116 /*******************************************************************
1117 inits a SAM_ENTRY1 structure.
1118 ********************************************************************/
1120 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1121 UNISTR2 *sam_name, UNISTR2 *sam_full,
1122 UNISTR2 *sam_desc, uint32 rid_user,
1125 DEBUG(5, ("init_sam_entry1\n"));
1129 sam->user_idx = user_idx;
1130 sam->rid_user = rid_user;
1131 sam->acb_info = acb_info;
1133 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1134 init_uni_hdr(&sam->hdr_user_name, sam_full);
1135 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1138 /*******************************************************************
1139 reads or writes a SAM_ENTRY1 structure.
1140 ********************************************************************/
1142 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1143 prs_struct *ps, int depth)
1148 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1154 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1157 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1159 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1162 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1164 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1166 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1172 /*******************************************************************
1173 reads or writes a SAM_STR2 structure.
1174 ********************************************************************/
1176 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1177 uint32 desc_buf, prs_struct *ps, int depth)
1182 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1188 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1190 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1196 /*******************************************************************
1197 inits a SAM_ENTRY2 structure.
1198 ********************************************************************/
1199 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1200 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1201 uint32 rid_user, uint32 acb_info)
1203 DEBUG(5, ("init_sam_entry2\n"));
1205 sam->user_idx = user_idx;
1206 sam->rid_user = rid_user;
1207 sam->acb_info = acb_info;
1209 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1210 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1213 /*******************************************************************
1214 reads or writes a SAM_ENTRY2 structure.
1215 ********************************************************************/
1217 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1218 prs_struct *ps, int depth)
1223 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1229 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1232 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1234 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1237 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1239 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1245 /*******************************************************************
1246 reads or writes a SAM_STR3 structure.
1247 ********************************************************************/
1249 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1250 uint32 desc_buf, prs_struct *ps, int depth)
1255 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1261 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1263 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1269 /*******************************************************************
1270 inits a SAM_ENTRY3 structure.
1271 ********************************************************************/
1273 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1274 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1277 DEBUG(5, ("init_sam_entry3\n"));
1279 sam->grp_idx = grp_idx;
1280 sam->rid_grp = rid_grp;
1281 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1283 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1284 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1287 /*******************************************************************
1288 reads or writes a SAM_ENTRY3 structure.
1289 ********************************************************************/
1291 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1292 prs_struct *ps, int depth)
1297 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1303 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1306 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1308 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1311 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1313 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1319 /*******************************************************************
1320 inits a SAM_ENTRY4 structure.
1321 ********************************************************************/
1323 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1324 uint32 len_acct_name)
1326 DEBUG(5, ("init_sam_entry4\n"));
1328 sam->user_idx = user_idx;
1329 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1332 /*******************************************************************
1333 reads or writes a SAM_ENTRY4 structure.
1334 ********************************************************************/
1336 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1337 prs_struct *ps, int depth)
1342 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1348 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1350 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1356 /*******************************************************************
1357 inits a SAM_ENTRY5 structure.
1358 ********************************************************************/
1360 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1361 uint32 len_grp_name)
1363 DEBUG(5, ("init_sam_entry5\n"));
1365 sam->grp_idx = grp_idx;
1366 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1370 /*******************************************************************
1371 reads or writes a SAM_ENTRY5 structure.
1372 ********************************************************************/
1374 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1375 prs_struct *ps, int depth)
1380 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1386 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1388 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1394 /*******************************************************************
1395 inits a SAM_ENTRY structure.
1396 ********************************************************************/
1398 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1400 DEBUG(10, ("init_sam_entry: %d\n", rid));
1403 init_uni_hdr(&sam->hdr_name, uni2);
1406 /*******************************************************************
1407 reads or writes a SAM_ENTRY structure.
1408 ********************************************************************/
1410 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1411 prs_struct *ps, int depth)
1416 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1421 if(!prs_uint32("rid", ps, depth, &sam->rid))
1423 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1429 /*******************************************************************
1430 inits a SAMR_Q_ENUM_DOM_USERS structure.
1431 ********************************************************************/
1433 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1435 uint32 acb_mask, uint32 size)
1437 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1441 q_e->start_idx = start_idx; /* zero indicates lots */
1442 q_e->acb_mask = acb_mask;
1443 q_e->max_size = size;
1446 /*******************************************************************
1447 reads or writes a structure.
1448 ********************************************************************/
1450 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1451 prs_struct *ps, int depth)
1456 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1462 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1465 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1467 if(!prs_uint32("acb_mask ", ps, depth, &q_e->acb_mask))
1470 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1477 /*******************************************************************
1478 inits a SAMR_R_ENUM_DOM_USERS structure.
1479 ********************************************************************/
1481 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1482 uint32 next_idx, uint32 num_sam_entries)
1484 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1486 r_u->next_idx = next_idx;
1488 if (num_sam_entries != 0) {
1489 r_u->ptr_entries1 = 1;
1490 r_u->ptr_entries2 = 1;
1491 r_u->num_entries2 = num_sam_entries;
1492 r_u->num_entries3 = num_sam_entries;
1494 r_u->num_entries4 = num_sam_entries;
1496 r_u->ptr_entries1 = 0;
1497 r_u->num_entries2 = num_sam_entries;
1498 r_u->ptr_entries2 = 1;
1502 /*******************************************************************
1503 reads or writes a structure.
1504 ********************************************************************/
1506 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1507 prs_struct *ps, int depth)
1514 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1520 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1522 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1525 if (r_u->ptr_entries1 != 0) {
1526 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1528 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1530 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1533 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1534 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1535 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1538 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1539 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1540 r_u->num_entries4 = 0;
1541 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1545 for (i = 0; i < r_u->num_entries2; i++) {
1546 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1550 for (i = 0; i < r_u->num_entries2; i++) {
1551 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1560 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1562 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1568 /*******************************************************************
1569 inits a SAMR_Q_QUERY_DISPINFO structure.
1570 ********************************************************************/
1572 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1573 uint16 switch_level, uint32 start_idx,
1574 uint32 max_entries, uint32 max_size)
1576 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1578 q_e->domain_pol = *pol;
1580 q_e->switch_level = switch_level;
1582 q_e->start_idx = start_idx;
1583 q_e->max_entries = max_entries;
1584 q_e->max_size = max_size;
1587 /*******************************************************************
1588 reads or writes a structure.
1589 ********************************************************************/
1591 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1592 prs_struct *ps, int depth)
1597 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1603 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1606 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1611 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1613 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1615 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1621 /*******************************************************************
1622 inits a SAM_DISPINFO_1 structure.
1623 ********************************************************************/
1625 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1626 uint32 num_entries, uint32 start_idx,
1627 struct samr_displayentry *entries)
1631 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1634 return NT_STATUS_OK;
1636 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1638 return NT_STATUS_NO_MEMORY;
1640 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1641 if ((*sam)->sam == NULL)
1642 return NT_STATUS_NO_MEMORY;
1644 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1645 if ((*sam)->str == NULL)
1646 return NT_STATUS_NO_MEMORY;
1648 for (i = 0; i < num_entries ; i++) {
1649 init_unistr2(&(*sam)->str[i].uni_acct_name,
1650 entries[i].account_name, UNI_FLAGS_NONE);
1651 init_unistr2(&(*sam)->str[i].uni_full_name,
1652 entries[i].fullname, UNI_FLAGS_NONE);
1653 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1654 entries[i].description, UNI_FLAGS_NONE);
1656 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1657 &(*sam)->str[i].uni_acct_name,
1658 &(*sam)->str[i].uni_full_name,
1659 &(*sam)->str[i].uni_acct_desc,
1660 entries[i].rid, entries[i].acct_flags);
1663 return NT_STATUS_OK;
1666 /*******************************************************************
1667 reads or writes a structure.
1668 ********************************************************************/
1670 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1672 prs_struct *ps, int depth)
1676 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1682 if (UNMARSHALLING(ps) && num_entries > 0) {
1684 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1685 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1689 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1690 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1695 for (i = 0; i < num_entries; i++) {
1696 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1700 for (i = 0; i < num_entries; i++) {
1701 if(!sam_io_sam_str1("", &sam->str[i],
1702 sam->sam[i].hdr_acct_name.buffer,
1703 sam->sam[i].hdr_user_name.buffer,
1704 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1711 /*******************************************************************
1712 inits a SAM_DISPINFO_2 structure.
1713 ********************************************************************/
1715 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1716 uint32 num_entries, uint32 start_idx,
1717 struct samr_displayentry *entries)
1721 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1724 return NT_STATUS_OK;
1726 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1728 return NT_STATUS_NO_MEMORY;
1730 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1731 if ((*sam)->sam == NULL)
1732 return NT_STATUS_NO_MEMORY;
1734 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1735 if ((*sam)->str == NULL)
1736 return NT_STATUS_NO_MEMORY;
1738 for (i = 0; i < num_entries; i++) {
1739 init_unistr2(&(*sam)->str[i].uni_srv_name,
1740 entries[i].account_name, UNI_FLAGS_NONE);
1741 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1742 entries[i].description, UNI_FLAGS_NONE);
1744 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1745 &(*sam)->str[i].uni_srv_name,
1746 &(*sam)->str[i].uni_srv_desc,
1747 entries[i].rid, entries[i].acct_flags);
1750 return NT_STATUS_OK;
1753 /*******************************************************************
1754 reads or writes a structure.
1755 ********************************************************************/
1757 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1759 prs_struct *ps, int depth)
1766 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1772 if (UNMARSHALLING(ps) && num_entries > 0) {
1774 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1775 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1779 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1780 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1785 for (i = 0; i < num_entries; i++) {
1786 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1790 for (i = 0; i < num_entries; i++) {
1791 if(!sam_io_sam_str2("", &sam->str[i],
1792 sam->sam[i].hdr_srv_name.buffer,
1793 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1800 /*******************************************************************
1801 inits a SAM_DISPINFO_3 structure.
1802 ********************************************************************/
1804 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1805 uint32 num_entries, uint32 start_idx,
1806 struct samr_displayentry *entries)
1810 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1813 return NT_STATUS_OK;
1815 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1817 return NT_STATUS_NO_MEMORY;
1819 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1820 return NT_STATUS_NO_MEMORY;
1822 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1823 return NT_STATUS_NO_MEMORY;
1825 for (i = 0; i < num_entries; i++) {
1826 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1828 init_unistr2(&(*sam)->str[i].uni_grp_name,
1829 entries[i].account_name, UNI_FLAGS_NONE);
1830 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1831 entries[i].description, UNI_FLAGS_NONE);
1833 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1834 &(*sam)->str[i].uni_grp_name,
1835 &(*sam)->str[i].uni_grp_desc,
1839 return NT_STATUS_OK;
1842 /*******************************************************************
1843 reads or writes a structure.
1844 ********************************************************************/
1846 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1848 prs_struct *ps, int depth)
1855 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1861 if (UNMARSHALLING(ps) && num_entries > 0) {
1863 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1864 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1868 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1869 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1874 for (i = 0; i < num_entries; i++) {
1875 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1879 for (i = 0; i < num_entries; i++) {
1880 if(!sam_io_sam_str3("", &sam->str[i],
1881 sam->sam[i].hdr_grp_name.buffer,
1882 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1889 /*******************************************************************
1890 inits a SAM_DISPINFO_4 structure.
1891 ********************************************************************/
1893 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1894 uint32 num_entries, uint32 start_idx,
1895 struct samr_displayentry *entries)
1899 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1902 return NT_STATUS_OK;
1904 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1906 return NT_STATUS_NO_MEMORY;
1908 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1909 if ((*sam)->sam == NULL)
1910 return NT_STATUS_NO_MEMORY;
1912 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1913 if ((*sam)->str == NULL)
1914 return NT_STATUS_NO_MEMORY;
1916 for (i = 0; i < num_entries; i++) {
1917 size_t len_sam_name = strlen(entries[i].account_name);
1919 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1921 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1924 init_string2(&(*sam)->str[i].acct_name,
1925 entries[i].account_name, len_sam_name+1,
1929 return NT_STATUS_OK;
1932 /*******************************************************************
1933 reads or writes a structure.
1934 ********************************************************************/
1936 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1938 prs_struct *ps, int depth)
1945 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1951 if (UNMARSHALLING(ps) && num_entries > 0) {
1953 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1954 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1958 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1959 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1964 for (i = 0; i < num_entries; i++) {
1965 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1969 for (i = 0; i < num_entries; i++) {
1970 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1971 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1978 /*******************************************************************
1979 inits a SAM_DISPINFO_5 structure.
1980 ********************************************************************/
1982 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1983 uint32 num_entries, uint32 start_idx,
1984 struct samr_displayentry *entries)
1986 uint32 len_sam_name;
1989 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1992 return NT_STATUS_OK;
1994 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1996 return NT_STATUS_NO_MEMORY;
1998 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1999 return NT_STATUS_NO_MEMORY;
2001 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
2002 return NT_STATUS_NO_MEMORY;
2004 for (i = 0; i < num_entries; i++) {
2005 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
2007 len_sam_name = strlen(entries[i].account_name);
2009 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
2010 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
2011 len_sam_name+1, len_sam_name);
2014 return NT_STATUS_OK;
2017 /*******************************************************************
2018 reads or writes a structure.
2019 ********************************************************************/
2021 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
2023 prs_struct *ps, int depth)
2030 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
2036 if (UNMARSHALLING(ps) && num_entries > 0) {
2038 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
2039 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
2043 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
2044 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2049 for (i = 0; i < num_entries; i++) {
2050 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2054 for (i = 0; i < num_entries; i++) {
2055 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
2056 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2063 /*******************************************************************
2064 inits a SAMR_R_QUERY_DISPINFO structure.
2065 ********************************************************************/
2067 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2068 uint32 num_entries, uint32 total_size, uint32 data_size,
2069 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2072 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2074 r_u->total_size = total_size;
2076 r_u->data_size = data_size;
2078 r_u->switch_level = switch_level;
2079 r_u->num_entries = num_entries;
2082 r_u->ptr_entries = 0;
2084 r_u->ptr_entries = 1;
2086 r_u->num_entries2 = num_entries;
2089 r_u->status = status;
2092 /*******************************************************************
2093 reads or writes a structure.
2094 ********************************************************************/
2096 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2097 prs_struct *ps, int depth)
2102 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2108 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2110 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2112 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2117 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2119 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2122 if (r_u->ptr_entries==0) {
2125 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2131 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2134 switch (r_u->switch_level) {
2136 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2137 r_u->num_entries, ps, depth))
2141 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2142 r_u->num_entries, ps, depth))
2146 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2147 r_u->num_entries, ps, depth))
2151 if(!sam_io_sam_dispinfo_4("user list",
2152 r_u->ctr->sam.info4,
2153 r_u->num_entries, ps, depth))
2157 if(!sam_io_sam_dispinfo_5("group list",
2158 r_u->ctr->sam.info5,
2159 r_u->num_entries, ps, depth))
2163 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2169 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2175 /*******************************************************************
2176 inits a SAMR_Q_GET_DISPENUM_INDEX structure.
2177 ********************************************************************/
2179 void init_samr_q_get_dispenum_index(SAMR_Q_GET_DISPENUM_INDEX * q_e, POLICY_HND *pol,
2180 uint16 switch_level, const char *name)
2182 DEBUG(5, ("init_samr_q_get_dispenum_index\n"));
2184 q_e->domain_pol = *pol;
2186 q_e->switch_level = switch_level;
2188 init_lsa_string(&q_e->name, name);
2191 /*******************************************************************
2192 reads or writes a structure.
2193 ********************************************************************/
2195 BOOL samr_io_q_get_dispenum_index(const char *desc, SAMR_Q_GET_DISPENUM_INDEX * q_e,
2196 prs_struct *ps, int depth)
2201 prs_debug(ps, depth, desc, "samr_io_q_get_dispenum_index");
2207 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
2210 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2213 if (!smb_io_lsa_string("name", &q_e->name, ps, depth))
2219 /*******************************************************************
2220 reads or writes a structure.
2221 ********************************************************************/
2223 BOOL samr_io_r_get_dispenum_index(const char *desc, SAMR_R_GET_DISPENUM_INDEX * r_u,
2224 prs_struct *ps, int depth)
2229 prs_debug(ps, depth, desc, "samr_io_r_get_dispenum_index");
2235 if(!prs_uint32("idx", ps, depth, &r_u->idx))
2238 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2245 /*******************************************************************
2246 inits a SAMR_Q_OPEN_GROUP structure.
2247 ********************************************************************/
2249 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2251 uint32 access_mask, uint32 rid)
2253 DEBUG(5, ("init_samr_q_open_group\n"));
2255 q_c->domain_pol = *hnd;
2256 q_c->access_mask = access_mask;
2257 q_c->rid_group = rid;
2260 /*******************************************************************
2261 reads or writes a structure.
2262 ********************************************************************/
2264 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2265 prs_struct *ps, int depth)
2270 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2276 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2279 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2281 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2287 /*******************************************************************
2288 reads or writes a structure.
2289 ********************************************************************/
2291 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2292 prs_struct *ps, int depth)
2297 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2303 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2306 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2312 /*******************************************************************
2313 inits a GROUP_INFO1 structure.
2314 ********************************************************************/
2316 void init_samr_group_info1(GROUP_INFO1 * gr1,
2317 char *acct_name, char *acct_desc,
2320 DEBUG(5, ("init_samr_group_info1\n"));
2322 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2323 gr1->num_members = num_members;
2325 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2326 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2327 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2328 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2331 /*******************************************************************
2332 reads or writes a structure.
2333 ********************************************************************/
2335 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2336 prs_struct *ps, int depth)
2343 prs_debug(ps, depth, desc, "samr_io_group_info1");
2346 if(!prs_uint16("level", ps, depth, &dummy))
2352 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2355 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2357 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2360 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2363 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2364 gr1->hdr_acct_name.buffer, ps, depth))
2367 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2368 gr1->hdr_acct_desc.buffer, ps, depth))
2374 /*******************************************************************
2375 inits a GROUP_INFO2 structure.
2376 ********************************************************************/
2378 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2380 DEBUG(5, ("init_samr_group_info2\n"));
2383 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2384 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2387 /*******************************************************************
2388 reads or writes a structure.
2389 ********************************************************************/
2391 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2396 prs_debug(ps, depth, desc, "samr_io_group_info2");
2399 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2402 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2404 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2405 gr2->hdr_acct_name.buffer, ps, depth))
2411 /*******************************************************************
2412 inits a GROUP_INFO3 structure.
2413 ********************************************************************/
2415 void init_samr_group_info3(GROUP_INFO3 *gr3)
2417 DEBUG(5, ("init_samr_group_info3\n"));
2419 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2422 /*******************************************************************
2423 reads or writes a structure.
2424 ********************************************************************/
2426 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2431 prs_debug(ps, depth, desc, "samr_io_group_info3");
2437 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2443 /*******************************************************************
2444 inits a GROUP_INFO4 structure.
2445 ********************************************************************/
2447 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2449 DEBUG(5, ("init_samr_group_info4\n"));
2452 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2453 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2456 /*******************************************************************
2457 reads or writes a structure.
2458 ********************************************************************/
2460 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2461 prs_struct *ps, int depth)
2466 prs_debug(ps, depth, desc, "samr_io_group_info4");
2469 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2471 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2473 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2474 gr4->hdr_acct_desc.buffer, ps, depth))
2480 /*******************************************************************
2481 inits a GROUP_INFO5 structure.
2482 ********************************************************************/
2484 void init_samr_group_info5(GROUP_INFO5 * gr5,
2485 char *acct_name, char *acct_desc,
2488 DEBUG(5, ("init_samr_group_info5\n"));
2490 gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2491 gr5->num_members = num_members;
2493 init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2494 init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
2495 init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2496 init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
2499 /*******************************************************************
2500 reads or writes a structure.
2501 ********************************************************************/
2503 BOOL samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
2504 prs_struct *ps, int depth)
2511 prs_debug(ps, depth, desc, "samr_io_group_info5");
2514 if(!prs_uint16("level", ps, depth, &dummy))
2520 if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
2523 if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
2525 if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
2528 if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
2531 if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
2532 gr5->hdr_acct_name.buffer, ps, depth))
2535 if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
2536 gr5->hdr_acct_desc.buffer, ps, depth))
2543 /*******************************************************************
2544 reads or writes a structure.
2545 ********************************************************************/
2547 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2548 prs_struct *ps, int depth)
2550 if (UNMARSHALLING(ps))
2551 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2556 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2559 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2562 switch ((*ctr)->switch_value1) {
2564 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2568 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2572 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2576 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2580 if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
2584 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2591 /*******************************************************************
2592 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2593 ********************************************************************/
2595 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2596 POLICY_HND *pol, const char *acct_desc,
2599 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2603 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2604 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2606 q_e->access_mask = access_mask;
2609 /*******************************************************************
2610 reads or writes a structure.
2611 ********************************************************************/
2613 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2614 prs_struct *ps, int depth)
2619 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2625 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2628 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2630 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2631 q_e->hdr_acct_desc.buffer, ps, depth))
2636 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2642 /*******************************************************************
2643 reads or writes a structure.
2644 ********************************************************************/
2646 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2647 prs_struct *ps, int depth)
2652 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2658 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2661 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2663 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2669 /*******************************************************************
2670 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2671 ********************************************************************/
2673 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2676 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2678 q_c->group_pol = *hnd;
2681 /*******************************************************************
2682 reads or writes a structure.
2683 ********************************************************************/
2685 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2686 prs_struct *ps, int depth)
2691 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2697 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2703 /*******************************************************************
2704 reads or writes a structure.
2705 ********************************************************************/
2707 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2708 prs_struct *ps, int depth)
2713 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2719 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2722 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2728 /*******************************************************************
2729 inits a SAMR_Q_DEL_GROUPMEM structure.
2730 ********************************************************************/
2732 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2733 POLICY_HND *pol, uint32 rid)
2735 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2741 /*******************************************************************
2742 reads or writes a structure.
2743 ********************************************************************/
2745 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2746 prs_struct *ps, int depth)
2751 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2757 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2760 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2766 /*******************************************************************
2767 inits a SAMR_R_DEL_GROUPMEM structure.
2768 ********************************************************************/
2770 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2773 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2775 r_u->status = status;
2778 /*******************************************************************
2779 reads or writes a structure.
2780 ********************************************************************/
2782 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2783 prs_struct *ps, int depth)
2788 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2794 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2800 /*******************************************************************
2801 inits a SAMR_Q_ADD_GROUPMEM structure.
2802 ********************************************************************/
2804 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2805 POLICY_HND *pol, uint32 rid)
2807 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2811 q_e->unknown = 0x0005;
2814 /*******************************************************************
2815 reads or writes a structure.
2816 ********************************************************************/
2818 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2819 prs_struct *ps, int depth)
2824 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2830 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2833 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2835 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2841 /*******************************************************************
2842 inits a SAMR_R_ADD_GROUPMEM structure.
2843 ********************************************************************/
2845 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2848 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2850 r_u->status = status;
2853 /*******************************************************************
2854 reads or writes a structure.
2855 ********************************************************************/
2857 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2858 prs_struct *ps, int depth)
2863 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2869 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2875 /*******************************************************************
2876 inits a SAMR_Q_SET_GROUPINFO structure.
2877 ********************************************************************/
2879 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2880 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2882 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2888 /*******************************************************************
2889 reads or writes a structure.
2890 ********************************************************************/
2892 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2893 prs_struct *ps, int depth)
2898 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2904 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2907 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2913 /*******************************************************************
2914 inits a SAMR_R_SET_GROUPINFO structure.
2915 ********************************************************************/
2917 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2919 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2921 r_u->status = status;
2924 /*******************************************************************
2925 reads or writes a structure.
2926 ********************************************************************/
2928 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2929 prs_struct *ps, int depth)
2934 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2940 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2946 /*******************************************************************
2947 inits a SAMR_Q_QUERY_GROUPINFO structure.
2948 ********************************************************************/
2950 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2951 POLICY_HND *pol, uint16 switch_level)
2953 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2957 q_e->switch_level = switch_level;
2960 /*******************************************************************
2961 reads or writes a structure.
2962 ********************************************************************/
2964 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2965 prs_struct *ps, int depth)
2970 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2976 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2979 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2985 /*******************************************************************
2986 inits a SAMR_R_QUERY_GROUPINFO structure.
2987 ********************************************************************/
2989 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2990 GROUP_INFO_CTR * ctr, NTSTATUS status)
2992 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2994 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2996 r_u->status = status;
2999 /*******************************************************************
3000 reads or writes a structure.
3001 ********************************************************************/
3003 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
3004 prs_struct *ps, int depth)
3009 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
3015 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3018 if (r_u->ptr != 0) {
3019 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
3025 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3031 /*******************************************************************
3032 inits a SAMR_Q_QUERY_GROUPMEM structure.
3033 ********************************************************************/
3035 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
3037 DEBUG(5, ("init_samr_q_query_groupmem\n"));
3039 q_c->group_pol = *hnd;
3042 /*******************************************************************
3043 reads or writes a structure.
3044 ********************************************************************/
3046 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
3047 prs_struct *ps, int depth)
3052 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
3058 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
3064 /*******************************************************************
3065 inits a SAMR_R_QUERY_GROUPMEM structure.
3066 ********************************************************************/
3068 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
3069 uint32 num_entries, uint32 *rid,
3070 uint32 *attr, NTSTATUS status)
3072 DEBUG(5, ("init_samr_r_query_groupmem\n"));
3074 if (NT_STATUS_IS_OK(status)) {
3076 r_u->num_entries = num_entries;
3078 r_u->ptr_attrs = attr != NULL ? 1 : 0;
3079 r_u->ptr_rids = rid != NULL ? 1 : 0;
3081 r_u->num_rids = num_entries;
3084 r_u->num_attrs = num_entries;
3088 r_u->num_entries = 0;
3091 r_u->status = status;
3094 /*******************************************************************
3095 reads or writes a structure.
3096 ********************************************************************/
3098 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
3099 prs_struct *ps, int depth)
3106 if (UNMARSHALLING(ps))
3109 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
3115 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3117 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3120 if (r_u->ptr != 0) {
3121 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
3123 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
3126 if (r_u->ptr_rids != 0) {
3127 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
3129 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
3130 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
3131 if (r_u->rid == NULL)
3135 for (i = 0; i < r_u->num_rids; i++) {
3136 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
3141 if (r_u->ptr_attrs != 0) {
3142 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
3145 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
3146 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
3147 if (r_u->attr == NULL)
3151 for (i = 0; i < r_u->num_attrs; i++) {
3152 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
3158 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3164 /*******************************************************************
3165 inits a SAMR_Q_QUERY_USERGROUPS structure.
3166 ********************************************************************/
3168 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
3171 DEBUG(5, ("init_samr_q_query_usergroups\n"));
3176 /*******************************************************************
3177 reads or writes a structure.
3178 ********************************************************************/
3180 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
3181 prs_struct *ps, int depth)
3186 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
3192 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3198 /*******************************************************************
3199 inits a SAMR_R_QUERY_USERGROUPS structure.
3200 ********************************************************************/
3202 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3203 uint32 num_gids, DOM_GID * gid,
3206 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3208 if (NT_STATUS_IS_OK(status)) {
3210 r_u->num_entries = num_gids;
3211 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3212 r_u->num_entries2 = num_gids;
3217 r_u->num_entries = 0;
3222 r_u->status = status;
3225 /*******************************************************************
3226 reads or writes a structure.
3227 ********************************************************************/
3229 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3230 prs_struct *ps, int depth)
3236 prs_debug(ps, depth, desc, "samr_io_gids");
3242 if(!prs_uint32("num_gids", ps, depth, num_gids))
3245 if ((*num_gids) != 0) {
3246 if (UNMARSHALLING(ps)) {
3247 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3250 if ((*gid) == NULL) {
3254 for (i = 0; i < (*num_gids); i++) {
3255 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3263 /*******************************************************************
3264 reads or writes a structure.
3265 ********************************************************************/
3267 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3268 prs_struct *ps, int depth)
3273 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3279 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3282 if (r_u->ptr_0 != 0) {
3283 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3285 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3288 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3289 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3296 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3302 /*******************************************************************
3303 inits a SAMR_Q_ENUM_DOMAINS structure.
3304 ********************************************************************/
3306 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3308 uint32 start_idx, uint32 size)
3310 DEBUG(5, ("init_samr_q_enum_domains\n"));
3314 q_e->start_idx = start_idx;
3315 q_e->max_size = size;
3318 /*******************************************************************
3319 reads or writes a structure.
3320 ********************************************************************/
3322 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3323 prs_struct *ps, int depth)
3328 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3334 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3337 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3339 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3345 /*******************************************************************
3346 inits a SAMR_R_ENUM_DOMAINS structure.
3347 ********************************************************************/
3349 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3350 uint32 next_idx, uint32 num_sam_entries)
3352 DEBUG(5, ("init_samr_r_enum_domains\n"));
3354 r_u->next_idx = next_idx;
3356 if (num_sam_entries != 0) {
3357 r_u->ptr_entries1 = 1;
3358 r_u->ptr_entries2 = 1;
3359 r_u->num_entries2 = num_sam_entries;
3360 r_u->num_entries3 = num_sam_entries;
3362 r_u->num_entries4 = num_sam_entries;
3364 r_u->ptr_entries1 = 0;
3365 r_u->num_entries2 = num_sam_entries;
3366 r_u->ptr_entries2 = 1;
3370 /*******************************************************************
3371 reads or writes a structure.
3372 ********************************************************************/
3374 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3375 prs_struct *ps, int depth)
3382 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3388 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3390 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3393 if (r_u->ptr_entries1 != 0) {
3394 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3396 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3398 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3401 if (UNMARSHALLING(ps)) {
3402 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3403 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3406 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3407 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3408 r_u->num_entries4 = 0;
3409 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3413 for (i = 0; i < r_u->num_entries2; i++) {
3415 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3416 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3420 for (i = 0; i < r_u->num_entries2; i++) {
3422 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3423 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3424 r_u->sam[i].hdr_name.buffer, ps,
3433 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3435 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3441 /*******************************************************************
3442 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3443 ********************************************************************/
3445 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3447 uint32 start_idx, uint32 size)
3449 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3453 q_e->start_idx = start_idx;
3454 q_e->max_size = size;
3457 /*******************************************************************
3458 reads or writes a structure.
3459 ********************************************************************/
3461 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3462 prs_struct *ps, int depth)
3467 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3473 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3476 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3478 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3484 /*******************************************************************
3485 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3486 ********************************************************************/
3488 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3489 uint32 next_idx, uint32 num_sam_entries)
3491 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3493 r_u->next_idx = next_idx;
3495 if (num_sam_entries != 0) {
3496 r_u->ptr_entries1 = 1;
3497 r_u->ptr_entries2 = 1;
3498 r_u->num_entries2 = num_sam_entries;
3499 r_u->num_entries3 = num_sam_entries;
3501 r_u->num_entries4 = num_sam_entries;
3503 r_u->ptr_entries1 = 0;
3504 r_u->num_entries2 = num_sam_entries;
3505 r_u->ptr_entries2 = 1;
3509 /*******************************************************************
3510 reads or writes a structure.
3511 ********************************************************************/
3513 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3514 prs_struct *ps, int depth)
3521 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3527 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3529 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3532 if (r_u->ptr_entries1 != 0) {
3533 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3535 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3537 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3540 if (UNMARSHALLING(ps)) {
3541 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3542 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3545 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3547 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3548 r_u->num_entries4 = 0;
3549 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3553 for (i = 0; i < r_u->num_entries2; i++) {
3554 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3558 for (i = 0; i < r_u->num_entries2; i++) {
3559 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3560 r_u->sam[i].hdr_name.buffer, ps, depth))
3567 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3569 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3575 /*******************************************************************
3576 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3577 ********************************************************************/
3579 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3580 POLICY_HND *pol, uint32 start_idx,
3583 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3587 q_e->start_idx = start_idx;
3588 q_e->max_size = size;
3592 /*******************************************************************
3593 reads or writes a structure.
3594 ********************************************************************/
3596 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3597 prs_struct *ps, int depth)
3602 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3608 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3611 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3613 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3619 /*******************************************************************
3620 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3621 ********************************************************************/
3623 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3625 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3627 r_u->next_idx = next_idx;
3629 if (num_sam_entries != 0) {
3630 r_u->ptr_entries1 = 1;
3631 r_u->ptr_entries2 = 1;
3632 r_u->num_entries2 = num_sam_entries;
3633 r_u->num_entries3 = num_sam_entries;
3635 r_u->num_entries4 = num_sam_entries;
3637 r_u->ptr_entries1 = 0;
3638 r_u->num_entries2 = num_sam_entries;
3639 r_u->ptr_entries2 = 1;
3643 /*******************************************************************
3644 reads or writes a structure.
3645 ********************************************************************/
3647 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3648 prs_struct *ps, int depth)
3655 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3661 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3663 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3666 if (r_u->ptr_entries1 != 0) {
3667 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3669 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3671 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3674 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3675 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3676 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3679 if (r_u->num_entries2 != 0 &&
3680 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3681 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3682 r_u->num_entries4 = 0;
3683 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3687 for (i = 0; i < r_u->num_entries2; i++) {
3688 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3692 for (i = 0; i < r_u->num_entries2; i++) {
3693 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3694 r_u->sam[i].hdr_name.buffer, ps,
3702 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3704 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3710 /*******************************************************************
3711 inits a ALIAS_INFO1 structure.
3712 ********************************************************************/
3714 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3716 DEBUG(5, ("init_samr_alias_info1\n"));
3718 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3719 al1->num_member = num_member;
3720 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3723 /*******************************************************************
3724 reads or writes a structure.
3725 ********************************************************************/
3727 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3728 prs_struct *ps, int depth)
3733 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3739 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3741 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3743 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3746 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3748 if ( !prs_align(ps) )
3750 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3752 if ( !prs_align(ps) )
3758 /*******************************************************************
3759 inits a ALIAS_INFO3 structure.
3760 ********************************************************************/
3762 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3764 DEBUG(5, ("init_samr_alias_info3\n"));
3766 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3769 /*******************************************************************
3770 reads or writes a structure.
3771 ********************************************************************/
3773 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3774 prs_struct *ps, int depth)
3779 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3785 if (!prs_unistr4("description", ps, depth, &al3->description))
3791 /*******************************************************************
3792 reads or writes a structure.
3793 ********************************************************************/
3795 BOOL samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
3796 prs_struct *ps, int depth)
3801 prs_debug(ps, depth, desc, "samr_io_alias_info2");
3807 if (!prs_unistr4("name", ps, depth, &al2->name))
3813 /*******************************************************************
3814 reads or writes a structure.
3815 ********************************************************************/
3817 BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3822 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3825 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3830 switch (ctr->level) {
3832 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3836 if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
3840 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3844 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3851 /*******************************************************************
3852 inits a SAMR_Q_QUERY_ALIASINFO structure.
3853 ********************************************************************/
3855 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3856 POLICY_HND *pol, uint32 switch_level)
3858 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3861 q_e->level = switch_level;
3864 /*******************************************************************
3865 reads or writes a structure.
3866 ********************************************************************/
3868 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3869 prs_struct *ps, int depth)
3874 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3880 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3883 if ( !prs_uint16("level", ps, depth, &in->level) )
3889 /*******************************************************************
3890 inits a SAMR_R_QUERY_ALIASINFO structure.
3891 ********************************************************************/
3893 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3894 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3896 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3899 out->status = status;
3902 /*******************************************************************
3903 reads or writes a structure.
3904 ********************************************************************/
3906 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3907 prs_struct *ps, int depth)
3912 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3918 if ( !prs_pointer("alias", ps, depth, (void*)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3923 if(!prs_ntstatus("status", ps, depth, &out->status))
3929 /*******************************************************************
3930 inits a SAMR_Q_SET_ALIASINFO structure.
3931 ********************************************************************/
3933 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3934 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3936 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3938 q_u->alias_pol = *hnd;
3942 /*******************************************************************
3943 reads or writes a structure.
3944 ********************************************************************/
3946 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3947 prs_struct *ps, int depth)
3952 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3958 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3960 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3966 /*******************************************************************
3967 reads or writes a structure.
3968 ********************************************************************/
3970 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3971 prs_struct *ps, int depth)
3976 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3981 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3987 /*******************************************************************
3988 inits a SAMR_Q_QUERY_USERALIASES structure.
3989 ********************************************************************/
3991 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3994 uint32 *ptr_sid, DOM_SID2 * sid)
3996 DEBUG(5, ("init_samr_q_query_useraliases\n"));
4000 q_u->num_sids1 = num_sids;
4002 q_u->num_sids2 = num_sids;
4004 q_u->ptr_sid = ptr_sid;
4008 /*******************************************************************
4009 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
4010 ********************************************************************/
4012 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
4013 prs_struct *ps, int depth)
4021 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
4027 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4030 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
4032 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4038 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
4041 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
4042 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
4043 if (q_u->ptr_sid == NULL)
4046 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
4047 if (q_u->sid == NULL)
4051 for (i = 0; i < q_u->num_sids2; i++) {
4052 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
4053 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
4057 for (i = 0; i < q_u->num_sids2; i++) {
4058 if (q_u->ptr_sid[i] != 0) {
4059 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
4060 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
4068 /*******************************************************************
4069 inits a SAMR_R_QUERY_USERALIASES structure.
4070 ********************************************************************/
4072 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
4073 uint32 num_rids, uint32 *rid,
4076 DEBUG(5, ("init_samr_r_query_useraliases\n"));
4078 if (NT_STATUS_IS_OK(status)) {
4079 r_u->num_entries = num_rids;
4081 r_u->num_entries2 = num_rids;
4085 r_u->num_entries = 0;
4087 r_u->num_entries2 = 0;
4090 r_u->status = status;
4093 /*******************************************************************
4094 reads or writes a structure.
4095 ********************************************************************/
4097 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
4098 prs_struct *ps, int depth)
4105 prs_debug(ps, depth, desc, "samr_io_rids");
4111 if(!prs_uint32("num_rids", ps, depth, num_rids))
4114 if ((*num_rids) != 0) {
4115 if (UNMARSHALLING(ps)) {
4117 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
4122 for (i = 0; i < (*num_rids); i++) {
4123 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
4124 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
4132 /*******************************************************************
4133 reads or writes a structure.
4134 ********************************************************************/
4136 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
4137 prs_struct *ps, int depth)
4142 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
4148 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
4150 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
4153 if (r_u->ptr != 0) {
4154 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
4160 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4166 /*******************************************************************
4167 inits a SAMR_Q_OPEN_ALIAS structure.
4168 ********************************************************************/
4170 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
4171 uint32 access_mask, uint32 rid)
4173 DEBUG(5, ("init_samr_q_open_alias\n"));
4175 q_u->dom_pol = *pol;
4176 q_u->access_mask = access_mask;
4177 q_u->rid_alias = rid;
4180 /*******************************************************************
4181 reads or writes a structure.
4182 ********************************************************************/
4184 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
4185 prs_struct *ps, int depth)
4190 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
4196 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
4199 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4201 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
4207 /*******************************************************************
4208 reads or writes a structure.
4209 ********************************************************************/
4211 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4212 prs_struct *ps, int depth)
4217 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4223 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4226 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4232 /*******************************************************************
4233 inits a SAMR_Q_LOOKUP_RIDS structure.
4234 ********************************************************************/
4236 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4237 POLICY_HND *pol, uint32 flags,
4238 uint32 num_rids, uint32 *rid)
4240 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4244 q_u->num_rids1 = num_rids;
4247 q_u->num_rids2 = num_rids;
4249 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4253 if (q_u->rid == NULL) {
4257 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4261 /*******************************************************************
4262 reads or writes a structure.
4263 ********************************************************************/
4265 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4266 prs_struct *ps, int depth)
4274 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4277 if (UNMARSHALLING(ps))
4283 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4286 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4288 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4290 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4292 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4295 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4296 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4297 if (q_u->rid == NULL)
4301 for (i = 0; i < q_u->num_rids2; i++) {
4302 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4303 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4310 /*******************************************************************
4311 inits a SAMR_R_LOOKUP_RIDS structure.
4312 ********************************************************************/
4314 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4315 uint32 num_names, UNIHDR * hdr_name,
4316 UNISTR2 *uni_name, uint32 *type)
4318 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4320 r_u->hdr_name = NULL;
4321 r_u->uni_name = NULL;
4324 if (num_names != 0) {
4325 r_u->num_names1 = num_names;
4327 r_u->num_names2 = num_names;
4329 r_u->num_types1 = num_names;
4331 r_u->num_types2 = num_names;
4333 r_u->hdr_name = hdr_name;
4334 r_u->uni_name = uni_name;
4337 r_u->num_names1 = num_names;
4339 r_u->num_names2 = num_names;
4341 r_u->num_types1 = num_names;
4343 r_u->num_types2 = num_names;
4347 /*******************************************************************
4348 reads or writes a structure.
4349 ********************************************************************/
4351 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4352 prs_struct *ps, int depth)
4359 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4365 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4367 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4370 if (r_u->ptr_names != 0) {
4372 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4376 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4377 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4378 if (r_u->hdr_name == NULL)
4381 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4382 if (r_u->uni_name == NULL)
4386 for (i = 0; i < r_u->num_names2; i++) {
4387 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4388 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4391 for (i = 0; i < r_u->num_names2; i++) {
4392 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4393 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4401 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4403 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4406 if (r_u->ptr_types != 0) {
4408 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4411 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4412 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4413 if (r_u->type == NULL)
4417 for (i = 0; i < r_u->num_types2; i++) {
4418 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4419 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4424 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4430 /*******************************************************************
4431 inits a SAMR_Q_OPEN_ALIAS structure.
4432 ********************************************************************/
4434 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4436 DEBUG(5, ("init_samr_q_delete_alias\n"));
4438 q_u->alias_pol = *hnd;
4441 /*******************************************************************
4442 reads or writes a structure.
4443 ********************************************************************/
4445 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4446 prs_struct *ps, int depth)
4451 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4457 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4463 /*******************************************************************
4464 reads or writes a structure.
4465 ********************************************************************/
4467 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4468 prs_struct *ps, int depth)
4473 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4479 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4481 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4487 /*******************************************************************
4488 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4489 ********************************************************************/
4491 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4492 POLICY_HND *hnd, const char *acct_desc)
4494 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4496 q_u->dom_pol = *hnd;
4498 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4499 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4501 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4504 /*******************************************************************
4505 reads or writes a structure.
4506 ********************************************************************/
4508 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4509 prs_struct *ps, int depth)
4514 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4520 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4523 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4525 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4526 q_u->hdr_acct_desc.buffer, ps, depth))
4531 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4537 /*******************************************************************
4538 reads or writes a structure.
4539 ********************************************************************/
4541 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4542 prs_struct *ps, int depth)
4547 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4553 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4556 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4559 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4565 /*******************************************************************
4566 inits a SAMR_Q_ADD_ALIASMEM structure.
4567 ********************************************************************/
4569 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4572 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4574 q_u->alias_pol = *hnd;
4575 init_dom_sid2(&q_u->sid, sid);
4578 /*******************************************************************
4579 reads or writes a structure.
4580 ********************************************************************/
4582 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4583 prs_struct *ps, int depth)
4588 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4594 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4596 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4602 /*******************************************************************
4603 reads or writes a structure.
4604 ********************************************************************/
4606 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4607 prs_struct *ps, int depth)
4612 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4618 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4624 /*******************************************************************
4625 inits a SAMR_Q_DEL_ALIASMEM structure.
4626 ********************************************************************/
4628 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4631 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4633 q_u->alias_pol = *hnd;
4634 init_dom_sid2(&q_u->sid, sid);
4637 /*******************************************************************
4638 reads or writes a structure.
4639 ********************************************************************/
4641 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4642 prs_struct *ps, int depth)
4647 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4653 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4655 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4661 /*******************************************************************
4662 reads or writes a structure.
4663 ********************************************************************/
4665 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4666 prs_struct *ps, int depth)
4671 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4677 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4683 /*******************************************************************
4684 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4685 ********************************************************************/
4687 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4690 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4692 q_c->alias_pol = *hnd;
4695 /*******************************************************************
4696 reads or writes a structure.
4697 ********************************************************************/
4699 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4700 prs_struct *ps, int depth)
4705 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4711 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4717 /*******************************************************************
4718 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4719 ********************************************************************/
4721 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4724 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4726 r_u->status = status;
4729 /*******************************************************************
4730 reads or writes a structure.
4731 ********************************************************************/
4733 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4734 prs_struct *ps, int depth)
4739 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4745 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4748 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4754 /*******************************************************************
4755 inits a SAMR_Q_QUERY_ALIASMEM structure.
4756 ********************************************************************/
4758 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4761 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4763 q_c->alias_pol = *hnd;
4766 /*******************************************************************
4767 reads or writes a structure.
4768 ********************************************************************/
4770 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4771 prs_struct *ps, int depth)
4776 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4782 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4788 /*******************************************************************
4789 inits a SAMR_R_QUERY_ALIASMEM structure.
4790 ********************************************************************/
4792 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4793 uint32 num_sids, DOM_SID2 * sid,
4796 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4798 if (NT_STATUS_IS_OK(status)) {
4799 r_u->num_sids = num_sids;
4800 r_u->ptr = (num_sids != 0) ? 1 : 0;
4801 r_u->num_sids1 = num_sids;
4809 r_u->status = status;
4812 /*******************************************************************
4813 reads or writes a structure.
4814 ********************************************************************/
4816 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4817 prs_struct *ps, int depth)
4824 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4830 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4832 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4835 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4836 uint32 *ptr_sid = NULL;
4838 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4841 /* We must always use talloc here even when marshalling. */
4842 if (r_u->num_sids1) {
4843 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4851 for (i = 0; i < r_u->num_sids1; i++) {
4853 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4857 if (UNMARSHALLING(ps)) {
4858 if (r_u->num_sids1) {
4859 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4868 for (i = 0; i < r_u->num_sids1; i++) {
4869 if (ptr_sid[i] != 0) {
4870 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4878 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4884 /*******************************************************************
4885 inits a SAMR_Q_LOOKUP_NAMES structure.
4886 ********************************************************************/
4888 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4889 POLICY_HND *pol, uint32 flags,
4890 uint32 num_names, const char **name)
4894 DEBUG(5, ("init_samr_q_lookup_names\n"));
4898 q_u->num_names1 = num_names;
4901 q_u->num_names2 = num_names;
4904 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4905 return NT_STATUS_NO_MEMORY;
4907 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4908 return NT_STATUS_NO_MEMORY;
4910 q_u->hdr_name = NULL;
4911 q_u->uni_name = NULL;
4914 for (i = 0; i < num_names; i++) {
4915 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4916 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4919 return NT_STATUS_OK;
4922 /*******************************************************************
4923 reads or writes a structure.
4924 ********************************************************************/
4926 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4927 prs_struct *ps, int depth)
4934 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4937 if (UNMARSHALLING(ps))
4943 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4946 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4948 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4950 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4952 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4955 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4956 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4957 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4958 if (!q_u->hdr_name || !q_u->uni_name)
4962 for (i = 0; i < q_u->num_names2; i++) {
4963 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4967 for (i = 0; i < q_u->num_names2; i++) {
4968 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4975 /*******************************************************************
4976 inits a SAMR_R_LOOKUP_NAMES structure.
4977 ********************************************************************/
4979 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4981 uint32 *rid, enum lsa_SidType *type,
4984 DEBUG(5, ("init_samr_r_lookup_names\n"));
4986 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4989 r_u->num_types1 = num_rids;
4991 r_u->num_types2 = num_rids;
4993 r_u->num_rids1 = num_rids;
4995 r_u->num_rids2 = num_rids;
4998 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4999 return NT_STATUS_NO_MEMORY;
5000 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
5001 return NT_STATUS_NO_MEMORY;
5007 if (!r_u->rids || !r_u->types)
5010 for (i = 0; i < num_rids; i++) {
5011 r_u->rids[i] = rid[i];
5012 r_u->types[i] = type[i];
5017 r_u->num_types1 = 0;
5019 r_u->num_types2 = 0;
5029 r_u->status = status;
5031 return NT_STATUS_OK;
5034 /*******************************************************************
5035 reads or writes a structure.
5036 ********************************************************************/
5038 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
5039 prs_struct *ps, int depth)
5047 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
5050 if (UNMARSHALLING(ps))
5056 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
5058 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
5061 if (r_u->ptr_rids != 0) {
5062 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
5065 if (r_u->num_rids2 != r_u->num_rids1) {
5070 if (UNMARSHALLING(ps))
5071 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
5074 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
5078 for (i = 0; i < r_u->num_rids2; i++) {
5079 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
5080 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
5085 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
5087 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
5090 if (r_u->ptr_types != 0) {
5091 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
5094 if (r_u->num_types2 != r_u->num_types1) {
5099 if (UNMARSHALLING(ps))
5100 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
5103 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
5107 for (i = 0; i < r_u->num_types2; i++) {
5108 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
5109 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
5114 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5120 /*******************************************************************
5121 inits a SAMR_Q_DELETE_DOM_USER structure.
5122 ********************************************************************/
5124 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
5127 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
5129 q_c->user_pol = *hnd;
5132 /*******************************************************************
5133 reads or writes a structure.
5134 ********************************************************************/
5136 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
5137 prs_struct *ps, int depth)
5142 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
5148 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
5154 /*******************************************************************
5155 reads or writes a structure.
5156 ********************************************************************/
5158 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
5159 prs_struct *ps, int depth)
5164 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
5170 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
5172 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5178 /*******************************************************************
5179 reads or writes a structure.
5180 ********************************************************************/
5182 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
5184 uint32 access_mask, uint32 rid)
5186 DEBUG(5, ("samr_init_samr_q_open_user\n"));
5188 q_u->domain_pol = *pol;
5189 q_u->access_mask = access_mask;
5190 q_u->user_rid = rid;
5193 /*******************************************************************
5194 reads or writes a structure.
5195 ********************************************************************/
5197 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
5198 prs_struct *ps, int depth)
5203 prs_debug(ps, depth, desc, "samr_io_q_open_user");
5209 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5212 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5214 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
5220 /*******************************************************************
5221 reads or writes a structure.
5222 ********************************************************************/
5224 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
5225 prs_struct *ps, int depth)
5230 prs_debug(ps, depth, desc, "samr_io_r_open_user");
5236 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5239 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5246 /*******************************************************************
5247 reads or writes a structure.
5248 ********************************************************************/
5250 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5253 uint32 acb_info, uint32 access_mask)
5255 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5257 q_u->domain_pol = *pol;
5259 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5260 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5262 q_u->acb_info = acb_info;
5263 q_u->access_mask = access_mask;
5266 /*******************************************************************
5267 reads or writes a structure.
5268 ********************************************************************/
5270 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5271 prs_struct *ps, int depth)
5276 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5282 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5285 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5287 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5292 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5294 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5300 /*******************************************************************
5301 reads or writes a structure.
5302 ********************************************************************/
5304 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5305 prs_struct *ps, int depth)
5310 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5316 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5319 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5321 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5323 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5329 /*******************************************************************
5330 inits a SAMR_Q_QUERY_USERINFO structure.
5331 ********************************************************************/
5333 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5334 const POLICY_HND *hnd, uint16 switch_value)
5336 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5339 q_u->switch_value = switch_value;
5342 /*******************************************************************
5343 reads or writes a structure.
5344 ********************************************************************/
5346 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5347 prs_struct *ps, int depth)
5352 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5358 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5361 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5367 /*******************************************************************
5368 reads or writes a LOGON_HRS structure.
5369 ********************************************************************/
5371 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5372 prs_struct *ps, int depth)
5377 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5383 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5386 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5389 if(!prs_uint32("len ", ps, depth, &hrs->len))
5392 if (hrs->len > sizeof(hrs->hours)) {
5393 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5394 hrs->len = sizeof(hrs->hours);
5397 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5403 /*******************************************************************
5404 inits a SAM_USER_INFO_18 structure.
5405 ********************************************************************/
5407 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5408 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5410 DEBUG(5, ("init_sam_user_info18\n"));
5412 usr->lm_pwd_active =
5413 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5414 usr->nt_pwd_active =
5415 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5418 /*******************************************************************
5419 reads or writes a structure.
5420 ********************************************************************/
5422 static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5423 prs_struct *ps, int depth)
5428 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5434 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5436 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5439 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5441 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5447 /*******************************************************************
5448 inits a SAM_USER_INFO_7 structure.
5449 ********************************************************************/
5451 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5453 DEBUG(5, ("init_sam_user_info7\n"));
5455 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5456 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5460 /*******************************************************************
5461 reads or writes a structure.
5462 ********************************************************************/
5464 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5465 prs_struct *ps, int depth)
5470 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5476 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5479 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5485 /*******************************************************************
5486 inits a SAM_USER_INFO_9 structure.
5487 ********************************************************************/
5489 void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
5491 DEBUG(5, ("init_sam_user_info9\n"));
5493 usr->rid_group = rid_group;
5496 /*******************************************************************
5497 reads or writes a structure.
5498 ********************************************************************/
5500 static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
5501 prs_struct *ps, int depth)
5506 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
5512 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5518 /*******************************************************************
5519 inits a SAM_USER_INFO_16 structure.
5520 ********************************************************************/
5522 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5524 DEBUG(5, ("init_sam_user_info16\n"));
5526 usr->acb_info = acb_info;
5529 /*******************************************************************
5530 reads or writes a structure.
5531 ********************************************************************/
5533 static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5534 prs_struct *ps, int depth)
5539 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5545 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5551 /*******************************************************************
5552 inits a SAM_USER_INFO_17 structure.
5553 ********************************************************************/
5555 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5558 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5560 DEBUG(5, ("init_sam_user_info17\n"));
5562 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5563 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5565 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5567 usr->ptr_1 = 1; /* pointer */
5568 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5569 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5571 usr->ptr_2 = 1; /* pointer */
5572 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5574 usr->ptr_3 = 1; /* pointer */
5575 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5577 usr->rid_user = rid_user;
5578 usr->rid_group = rid_group;
5580 usr->acct_ctrl = acct_ctrl;
5581 usr->unknown_3 = 0x0000;
5583 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5584 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5586 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5587 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5589 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5590 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5593 /*******************************************************************
5594 reads or writes a structure.
5595 ********************************************************************/
5597 static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5598 prs_struct *ps, int depth)
5603 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5609 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5612 if(!smb_io_time("time", &usr->expiry, ps, depth))
5615 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5618 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5621 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5624 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5626 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5629 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5632 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5634 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5637 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5639 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5642 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5644 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5646 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5648 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5650 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5652 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5655 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5658 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5661 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5667 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5673 /*************************************************************************
5675 *************************************************************************/
5677 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516],
5680 DEBUG(10, ("init_sam_user_info24:\n"));
5681 memcpy(usr->pass, newpass, sizeof(usr->pass));
5682 usr->pw_len = pw_len;
5685 /*******************************************************************
5686 reads or writes a structure.
5687 ********************************************************************/
5689 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5690 prs_struct *ps, int depth)
5695 prs_debug(ps, depth, desc, "sam_io_user_info24");
5701 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5705 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5706 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5708 } else if (UNMARSHALLING(ps)) {
5709 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5716 /*******************************************************************
5717 reads or writes a structure.
5718 ********************************************************************/
5720 static BOOL sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
5721 prs_struct *ps, int depth)
5726 prs_debug(ps, depth, desc, "sam_io_user_info26");
5732 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5736 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5743 /*************************************************************************
5744 init_sam_user_info23
5746 unknown_6 = 0x0000 04ec
5748 *************************************************************************/
5750 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5751 NTTIME * logoff_time, /* all zeros */
5752 NTTIME * kickoff_time, /* all zeros */
5753 NTTIME * pass_last_set_time, /* all zeros */
5754 NTTIME * pass_can_change_time, /* all zeros */
5755 NTTIME * pass_must_change_time, /* all zeros */
5766 uint32 user_rid, /* 0x0000 0000 */
5769 uint32 fields_present,
5772 uint16 bad_password_count,
5776 usr->logon_time = *logon_time; /* all zeros */
5777 usr->logoff_time = *logoff_time; /* all zeros */
5778 usr->kickoff_time = *kickoff_time; /* all zeros */
5779 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5780 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5781 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5783 ZERO_STRUCT(usr->nt_pwd);
5784 ZERO_STRUCT(usr->lm_pwd);
5786 usr->user_rid = user_rid; /* 0x0000 0000 */
5787 usr->group_rid = group_rid;
5788 usr->acb_info = acb_info;
5789 usr->fields_present = fields_present; /* 09f8 27fa */
5791 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5792 usr->ptr_logon_hrs = hrs ? 1 : 0;
5794 if (nt_time_is_zero(pass_must_change_time)) {
5795 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5797 usr->passmustchange=0;
5800 ZERO_STRUCT(usr->padding1);
5801 ZERO_STRUCT(usr->padding2);
5803 usr->bad_password_count = bad_password_count;
5804 usr->logon_count = logon_count;
5806 memcpy(usr->pass, newpass, sizeof(usr->pass));
5808 copy_unistr2(&usr->uni_user_name, user_name);
5809 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5811 copy_unistr2(&usr->uni_full_name, full_name);
5812 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5814 copy_unistr2(&usr->uni_home_dir, home_dir);
5815 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5817 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5818 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5820 copy_unistr2(&usr->uni_logon_script, log_scr);
5821 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5823 copy_unistr2(&usr->uni_profile_path, prof_path);
5824 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5826 copy_unistr2(&usr->uni_acct_desc, desc);
5827 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5829 copy_unistr2(&usr->uni_workstations, wkstas);
5830 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5832 copy_unistr2(&usr->uni_comment, unk_str);
5833 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5835 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5836 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5839 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5841 ZERO_STRUCT(usr->logon_hrs);
5845 /*************************************************************************
5846 init_sam_user_info23
5848 unknown_6 = 0x0000 04ec
5850 *************************************************************************/
5852 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5853 NTTIME * logoff_time, /* all zeros */
5854 NTTIME * kickoff_time, /* all zeros */
5855 NTTIME * pass_last_set_time, /* all zeros */
5856 NTTIME * pass_can_change_time, /* all zeros */
5857 NTTIME * pass_must_change_time, /* all zeros */
5858 char *user_name, /* NULL */
5860 char *home_dir, char *dir_drive, char *log_scr,
5861 char *prof_path, const char *desc, char *wkstas,
5862 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5863 uint32 group_rid, uint32 acb_info,
5864 uint32 fields_present, uint16 logon_divs,
5865 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5868 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5870 usr->logon_time = *logon_time; /* all zeros */
5871 usr->logoff_time = *logoff_time; /* all zeros */
5872 usr->kickoff_time = *kickoff_time; /* all zeros */
5873 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5874 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5875 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5877 ZERO_STRUCT(usr->nt_pwd);
5878 ZERO_STRUCT(usr->lm_pwd);
5880 usr->user_rid = user_rid; /* 0x0000 0000 */
5881 usr->group_rid = group_rid;
5882 usr->acb_info = acb_info;
5883 usr->fields_present = fields_present; /* 09f8 27fa */
5885 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5886 usr->ptr_logon_hrs = hrs ? 1 : 0;
5888 if (nt_time_is_zero(pass_must_change_time)) {
5889 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5891 usr->passmustchange=0;
5894 ZERO_STRUCT(usr->padding1);
5895 ZERO_STRUCT(usr->padding2);
5897 usr->bad_password_count = bad_password_count;
5898 usr->logon_count = logon_count;
5900 memcpy(usr->pass, newpass, sizeof(usr->pass));
5902 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5903 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5905 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5906 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5908 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5909 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5911 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5912 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5914 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5915 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5917 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5918 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5920 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5921 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5923 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5924 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5926 init_unistr2(&usr->uni_comment, unk_str, UNI_FLAGS_NONE);
5927 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5929 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5930 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5932 data_blob_free(&blob);
5935 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5937 ZERO_STRUCT(usr->logon_hrs);
5941 /*******************************************************************
5942 reads or writes a structure.
5943 ********************************************************************/
5945 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5946 prs_struct *ps, int depth)
5951 prs_debug(ps, depth, desc, "sam_io_user_info23");
5957 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5959 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5961 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5963 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5965 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5967 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5970 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5972 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5974 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5976 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5978 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5980 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5982 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5984 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5986 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
5988 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5991 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5993 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5996 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5998 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6000 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6003 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6005 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6009 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6012 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6014 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6017 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6019 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6021 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6025 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6028 /* here begins pointed-to data */
6030 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6033 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6036 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6039 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6042 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6045 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6048 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6051 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6054 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
6057 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6060 /* ok, this is only guess-work (as usual) */
6061 if (usr->ptr_logon_hrs) {
6062 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6069 /*******************************************************************
6070 reads or writes a structure.
6071 NB. This structure is *definately* incorrect. It's my best guess
6072 currently for W2K SP2. The password field is encrypted in a different
6073 way than normal... And there are definately other problems. JRA.
6074 ********************************************************************/
6076 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
6081 prs_debug(ps, depth, desc, "sam_io_user_info25");
6087 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6089 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6091 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6093 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
6095 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
6097 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6100 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6102 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6104 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6106 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6108 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6110 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6112 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6114 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6116 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6118 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6121 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6123 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6126 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6128 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6130 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6132 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6135 if(!prs_uint32s(False, "unknown_5 ", ps, depth, usr->unknown_5, 5))
6138 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6141 /* here begins pointed-to data */
6143 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6146 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6149 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6152 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6155 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6158 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6161 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6164 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6167 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
6170 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6173 #if 0 /* JRA - unknown... */
6174 /* ok, this is only guess-work (as usual) */
6175 if (usr->ptr_logon_hrs) {
6176 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6185 /*************************************************************************
6186 init_sam_user_info21W
6188 unknown_6 = 0x0000 04ec
6190 *************************************************************************/
6192 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
6193 NTTIME * logon_time,
6194 NTTIME * logoff_time,
6195 NTTIME * kickoff_time,
6196 NTTIME * pass_last_set_time,
6197 NTTIME * pass_can_change_time,
6198 NTTIME * pass_must_change_time,
6214 uint32 fields_present,
6217 uint16 bad_password_count,
6220 usr->logon_time = *logon_time;
6221 usr->logoff_time = *logoff_time;
6222 usr->kickoff_time = *kickoff_time;
6223 usr->pass_last_set_time = *pass_last_set_time;
6224 usr->pass_can_change_time = *pass_can_change_time;
6225 usr->pass_must_change_time = *pass_must_change_time;
6227 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
6228 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
6230 usr->user_rid = user_rid;
6231 usr->group_rid = group_rid;
6232 usr->acb_info = acb_info;
6233 usr->fields_present = fields_present; /* 0x00ff ffff */
6235 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
6236 usr->ptr_logon_hrs = hrs ? 1 : 0;
6237 usr->bad_password_count = bad_password_count;
6238 usr->logon_count = logon_count;
6240 if (nt_time_is_zero(pass_must_change_time)) {
6241 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6243 usr->passmustchange=0;
6246 ZERO_STRUCT(usr->padding1);
6247 ZERO_STRUCT(usr->padding2);
6249 copy_unistr2(&usr->uni_user_name, user_name);
6250 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6252 copy_unistr2(&usr->uni_full_name, full_name);
6253 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6255 copy_unistr2(&usr->uni_home_dir, home_dir);
6256 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6258 copy_unistr2(&usr->uni_dir_drive, dir_drive);
6259 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6261 copy_unistr2(&usr->uni_logon_script, log_scr);
6262 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6264 copy_unistr2(&usr->uni_profile_path, prof_path);
6265 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6267 copy_unistr2(&usr->uni_acct_desc, desc);
6268 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6270 copy_unistr2(&usr->uni_workstations, wkstas);
6271 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6273 copy_unistr2(&usr->uni_comment, unk_str);
6274 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6276 copy_unistr2(&usr->uni_munged_dial, mung_dial);
6277 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6280 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
6282 ZERO_STRUCT(usr->logon_hrs);
6286 /*************************************************************************
6287 init_sam_user_info21
6289 unknown_6 = 0x0000 04ec
6291 *************************************************************************/
6293 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
6295 NTTIME logon_time, logoff_time, kickoff_time,
6296 pass_last_set_time, pass_can_change_time,
6297 pass_must_change_time;
6299 time_t must_change_time;
6300 const char* user_name = pdb_get_username(pw);
6301 const char* full_name = pdb_get_fullname(pw);
6302 const char* home_dir = pdb_get_homedir(pw);
6303 const char* dir_drive = pdb_get_dir_drive(pw);
6304 const char* logon_script = pdb_get_logon_script(pw);
6305 const char* profile_path = pdb_get_profile_path(pw);
6306 const char* description = pdb_get_acct_desc(pw);
6307 const char* workstations = pdb_get_workstations(pw);
6308 const char* munged_dial = pdb_get_munged_dial(pw);
6309 DATA_BLOB munged_dial_blob;
6312 const DOM_SID *user_sid;
6315 const DOM_SID *group_sid;
6318 munged_dial_blob = base64_decode_data_blob(munged_dial);
6320 munged_dial_blob = data_blob(NULL, 0);
6323 /* Create NTTIME structs */
6324 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6325 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6326 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6327 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6328 unix_to_nt_time (&pass_can_change_time,pdb_get_pass_can_change_time(pw));
6329 must_change_time = pdb_get_pass_must_change_time(pw);
6330 if (must_change_time == get_time_t_max())
6331 unix_to_nt_time_abs(&pass_must_change_time, must_change_time);
6333 unix_to_nt_time(&pass_must_change_time, must_change_time);
6335 /* structure assignment */
6336 usr->logon_time = logon_time;
6337 usr->logoff_time = logoff_time;
6338 usr->kickoff_time = kickoff_time;
6339 usr->pass_last_set_time = pass_last_set_time;
6340 usr->pass_can_change_time = pass_can_change_time;
6341 usr->pass_must_change_time = pass_must_change_time;
6343 ZERO_STRUCT(usr->nt_pwd);
6344 ZERO_STRUCT(usr->lm_pwd);
6346 user_sid = pdb_get_user_sid(pw);
6348 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6349 fstring user_sid_string;
6350 fstring domain_sid_string;
6351 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6352 "the domain sid %s. Failing operation.\n",
6354 sid_to_string(user_sid_string, user_sid),
6355 sid_to_string(domain_sid_string, domain_sid)));
6356 data_blob_free(&munged_dial_blob);
6357 return NT_STATUS_UNSUCCESSFUL;
6361 group_sid = pdb_get_group_sid(pw);
6364 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6365 fstring group_sid_string;
6366 fstring domain_sid_string;
6367 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6368 "which conflicts with the domain sid %s. Failing operation.\n",
6370 sid_to_string(group_sid_string, group_sid),
6371 sid_to_string(domain_sid_string, domain_sid)));
6372 data_blob_free(&munged_dial_blob);
6373 return NT_STATUS_UNSUCCESSFUL;
6376 usr->user_rid = user_rid;
6377 usr->group_rid = group_rid;
6378 usr->acb_info = pdb_get_acct_ctrl(pw);
6381 Look at a user on a real NT4 PDC with usrmgr, press
6382 'ok'. Then you will see that fields_present is set to
6383 0x08f827fa. Look at the user immediately after that again,
6384 and you will see that 0x00fffff is returned. This solves
6385 the problem that you get access denied after having looked
6389 usr->fields_present = pdb_build_fields_present(pw);
6391 usr->logon_divs = pdb_get_logon_divs(pw);
6392 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6393 usr->bad_password_count = pdb_get_bad_password_count(pw);
6394 usr->logon_count = pdb_get_logon_count(pw);
6396 if (pdb_get_pass_must_change_time(pw) == 0) {
6397 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6399 usr->passmustchange=0;
6402 ZERO_STRUCT(usr->padding1);
6403 ZERO_STRUCT(usr->padding2);
6405 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6406 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6408 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6409 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6411 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6412 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6414 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6415 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6417 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6418 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6420 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6421 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6423 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6424 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6426 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6427 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6429 init_unistr2(&usr->uni_comment, NULL, UNI_STR_TERMINATE);
6430 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6432 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6433 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6434 data_blob_free(&munged_dial_blob);
6436 if (pdb_get_hours(pw)) {
6437 usr->logon_hrs.max_len = 1260;
6438 usr->logon_hrs.offset = 0;
6439 usr->logon_hrs.len = pdb_get_hours_len(pw);
6440 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6442 usr->logon_hrs.max_len = 1260;
6443 usr->logon_hrs.offset = 0;
6444 usr->logon_hrs.len = 0;
6445 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6448 return NT_STATUS_OK;
6451 /*******************************************************************
6452 reads or writes a structure.
6453 ********************************************************************/
6455 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6456 prs_struct *ps, int depth)
6461 prs_debug(ps, depth, desc, "sam_io_user_info21");
6467 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6469 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6471 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6473 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6475 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6477 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6480 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6482 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6484 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6486 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6488 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6490 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6492 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6494 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6496 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6498 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6501 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6503 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6506 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6508 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6510 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6513 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6515 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6519 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6522 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6524 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6527 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6529 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6531 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6534 /* here begins pointed-to data */
6536 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth))
6538 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth))
6540 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth))
6542 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth))
6544 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth))
6546 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth))
6548 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth))
6550 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth))
6552 if(!smb_io_unistr2("uni_comment", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth))
6554 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth))
6557 /* ok, this is only guess-work (as usual) */
6558 if (usr->ptr_logon_hrs) {
6559 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6566 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
6568 const char *munged_dial = pdb_get_munged_dial(pw);
6572 blob = base64_decode_data_blob(munged_dial);
6574 blob = data_blob(NULL, 0);
6577 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6578 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6579 data_blob_free(&blob);
6582 /*******************************************************************
6583 reads or writes a structure.
6584 ********************************************************************/
6586 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6587 prs_struct *ps, int depth)
6592 prs_debug(ps, depth, desc, "sam_io_user_info20");
6598 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6601 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6607 /*******************************************************************
6608 inits a SAM_USERINFO_CTR structure.
6609 ********************************************************************/
6611 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6612 uint16 switch_value,
6613 SAM_USER_INFO_21 * usr)
6615 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6617 ctr->switch_value = switch_value;
6618 ctr->info.id = NULL;
6620 switch (switch_value) {
6622 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6623 if (ctr->info.id16 == NULL)
6624 return NT_STATUS_NO_MEMORY;
6626 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6629 /* whoops - got this wrong. i think. or don't understand what's happening. */
6633 info = (void *)&id11;
6635 expire.low = 0xffffffff;
6636 expire.high = 0x7fffffff;
6638 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6639 init_sam_user_info11(ctr->info.id17, &expire,
6640 "BROOKFIELDS$", /* name */
6641 0x03ef, /* user rid */
6642 0x201, /* group rid */
6643 0x0080); /* acb info */
6649 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6650 if (ctr->info.id18 == NULL)
6651 return NT_STATUS_NO_MEMORY;
6653 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6657 SAM_USER_INFO_21 *cusr;
6658 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6659 ctr->info.id21 = cusr;
6660 if (ctr->info.id21 == NULL)
6661 return NT_STATUS_NO_MEMORY;
6662 memcpy(cusr, usr, sizeof(*usr));
6663 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6664 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6668 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6669 return NT_STATUS_INVALID_INFO_CLASS;
6672 return NT_STATUS_OK;
6675 /*******************************************************************
6676 inits a SAM_USERINFO_CTR structure.
6677 ********************************************************************/
6679 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6680 uint16 switch_value, void *info)
6682 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6684 ctr->switch_value = switch_value;
6685 ctr->info.id = info;
6687 switch (switch_value) {
6689 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6690 dump_data(100, sess_key->data, sess_key->length);
6691 dump_data(100, ctr->info.id24->pass, 516);
6694 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6695 dump_data(100, sess_key->data, sess_key->length);
6696 dump_data(100, ctr->info.id23->pass, 516);
6701 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6705 /*******************************************************************
6706 reads or writes a structure.
6707 ********************************************************************/
6709 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6710 prs_struct *ps, int depth)
6713 SAM_USERINFO_CTR *ctr;
6715 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6718 if (UNMARSHALLING(ps)) {
6719 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6727 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6729 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6736 switch (ctr->switch_value) {
6738 if (UNMARSHALLING(ps))
6739 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6740 if (ctr->info.id7 == NULL) {
6741 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6744 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6747 if (UNMARSHALLING(ps))
6748 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
6749 if (ctr->info.id9 == NULL) {
6750 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6753 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
6756 if (UNMARSHALLING(ps))
6757 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6758 if (ctr->info.id16 == NULL) {
6759 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6762 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6765 if (UNMARSHALLING(ps))
6766 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6768 if (ctr->info.id17 == NULL) {
6769 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6772 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6775 if (UNMARSHALLING(ps))
6776 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6778 if (ctr->info.id18 == NULL) {
6779 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6782 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6785 if (UNMARSHALLING(ps))
6786 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6788 if (ctr->info.id20 == NULL) {
6789 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6792 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6795 if (UNMARSHALLING(ps))
6796 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6798 if (ctr->info.id21 == NULL) {
6799 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6802 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6805 if (UNMARSHALLING(ps))
6806 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6808 if (ctr->info.id23 == NULL) {
6809 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6812 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6815 if (UNMARSHALLING(ps))
6816 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6818 if (ctr->info.id24 == NULL) {
6819 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6822 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6825 if (UNMARSHALLING(ps))
6826 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6828 if (ctr->info.id25 == NULL) {
6829 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6832 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6835 if (UNMARSHALLING(ps))
6836 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6838 if (ctr->info.id26 == NULL) {
6839 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6842 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6845 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6853 /*******************************************************************
6854 inits a SAMR_R_QUERY_USERINFO structure.
6855 ********************************************************************/
6857 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6858 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6860 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6865 if (NT_STATUS_IS_OK(status)) {
6870 r_u->status = status; /* return status */
6873 /*******************************************************************
6874 reads or writes a structure.
6875 ********************************************************************/
6877 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6878 prs_struct *ps, int depth)
6883 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6889 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6892 if (r_u->ptr != 0) {
6893 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6899 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6905 /*******************************************************************
6906 inits a SAMR_Q_SET_USERINFO structure.
6907 ********************************************************************/
6909 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6910 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6911 uint16 switch_value, void *info)
6913 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6916 q_u->switch_value = switch_value;
6917 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6920 /*******************************************************************
6921 reads or writes a structure.
6922 ********************************************************************/
6924 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6925 prs_struct *ps, int depth)
6930 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6936 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6938 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6940 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6946 /*******************************************************************
6947 inits a SAMR_R_SET_USERINFO structure.
6948 ********************************************************************/
6950 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6952 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6954 r_u->status = status; /* return status */
6957 /*******************************************************************
6958 reads or writes a structure.
6959 ********************************************************************/
6961 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6962 prs_struct *ps, int depth)
6967 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6973 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6979 /*******************************************************************
6980 inits a SAMR_Q_SET_USERINFO2 structure.
6981 ********************************************************************/
6983 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6984 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6985 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6987 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6990 q_u->switch_value = switch_value;
6993 q_u->ctr->switch_value = switch_value;
6995 switch (switch_value) {
6997 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
6998 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
6999 dump_data(100, sess_key->data, sess_key->length);
7000 dump_data(100, ctr->info.id18->lm_pwd, 16);
7001 dump_data(100, ctr->info.id18->nt_pwd, 16);
7006 /*******************************************************************
7007 reads or writes a structure.
7008 ********************************************************************/
7010 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
7011 prs_struct *ps, int depth)
7016 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
7022 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
7025 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7027 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
7033 /*******************************************************************
7034 inits a SAMR_R_SET_USERINFO2 structure.
7035 ********************************************************************/
7037 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
7039 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
7041 r_u->status = status; /* return status */
7044 /*******************************************************************
7045 reads or writes a structure.
7046 ********************************************************************/
7048 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
7049 prs_struct *ps, int depth)
7054 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
7060 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7066 /*******************************************************************
7067 inits a SAMR_Q_CONNECT structure.
7068 ********************************************************************/
7070 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
7071 char *srv_name, uint32 access_mask)
7073 DEBUG(5, ("init_samr_q_connect\n"));
7075 /* make PDC server name \\server */
7076 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7077 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7079 /* example values: 0x0000 0002 */
7080 q_u->access_mask = access_mask;
7083 /*******************************************************************
7084 reads or writes a structure.
7085 ********************************************************************/
7087 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
7088 prs_struct *ps, int depth)
7093 prs_debug(ps, depth, desc, "samr_io_q_connect");
7099 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7101 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7106 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7112 /*******************************************************************
7113 reads or writes a structure.
7114 ********************************************************************/
7116 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
7117 prs_struct *ps, int depth)
7122 prs_debug(ps, depth, desc, "samr_io_r_connect");
7128 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7131 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7137 /*******************************************************************
7138 inits a SAMR_Q_CONNECT4 structure.
7139 ********************************************************************/
7141 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
7142 char *srv_name, uint32 access_mask)
7144 DEBUG(5, ("init_samr_q_connect4\n"));
7146 /* make PDC server name \\server */
7147 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7148 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7150 /* Only value we've seen, possibly an address type ? */
7153 /* example values: 0x0000 0002 */
7154 q_u->access_mask = access_mask;
7157 /*******************************************************************
7158 reads or writes a structure.
7159 ********************************************************************/
7161 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
7162 prs_struct *ps, int depth)
7167 prs_debug(ps, depth, desc, "samr_io_q_connect4");
7173 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7175 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7180 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
7182 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7188 /*******************************************************************
7189 reads or writes a structure.
7190 ********************************************************************/
7192 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
7193 prs_struct *ps, int depth)
7198 prs_debug(ps, depth, desc, "samr_io_r_connect4");
7204 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7207 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7213 /*******************************************************************
7214 inits a SAMR_Q_CONNECT5 structure.
7215 ********************************************************************/
7217 void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
7218 char *srv_name, uint32 access_mask)
7220 DEBUG(5, ("init_samr_q_connect5\n"));
7222 /* make PDC server name \\server */
7223 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7224 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7226 /* example values: 0x0000 0002 */
7227 q_u->access_mask = access_mask;
7230 q_u->info1_unk1 = 3;
7231 q_u->info1_unk2 = 0;
7234 /*******************************************************************
7235 inits a SAMR_R_CONNECT5 structure.
7236 ********************************************************************/
7238 void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
7240 DEBUG(5, ("init_samr_q_connect5\n"));
7243 r_u->info1_unk1 = 3;
7244 r_u->info1_unk2 = 0;
7246 r_u->connect_pol = *pol;
7247 r_u->status = status;
7250 /*******************************************************************
7251 reads or writes a structure.
7252 ********************************************************************/
7254 BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
7255 prs_struct *ps, int depth)
7260 prs_debug(ps, depth, desc, "samr_io_q_connect5");
7266 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7268 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7273 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7276 if(!prs_uint32("level", ps, depth, &q_u->level))
7278 if(!prs_uint32("level", ps, depth, &q_u->level))
7281 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
7283 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
7289 /*******************************************************************
7290 reads or writes a structure.
7291 ********************************************************************/
7293 BOOL samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
7294 prs_struct *ps, int depth)
7299 prs_debug(ps, depth, desc, "samr_io_r_connect5");
7305 if(!prs_uint32("level", ps, depth, &r_u->level))
7307 if(!prs_uint32("level", ps, depth, &r_u->level))
7309 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
7311 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
7314 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7317 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7323 /*******************************************************************
7324 inits a SAMR_Q_CONNECT_ANON structure.
7325 ********************************************************************/
7327 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
7329 DEBUG(5, ("init_samr_q_connect_anon\n"));
7332 q_u->unknown_0 = 0x5c; /* server name (?!!) */
7333 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
7336 /*******************************************************************
7337 reads or writes a structure.
7338 ********************************************************************/
7340 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
7341 prs_struct *ps, int depth)
7346 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
7352 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
7355 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
7360 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7366 /*******************************************************************
7367 reads or writes a structure.
7368 ********************************************************************/
7370 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
7371 prs_struct *ps, int depth)
7376 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
7382 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7385 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7391 /*******************************************************************
7392 inits a SAMR_Q_GET_DOM_PWINFO structure.
7393 ********************************************************************/
7395 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
7398 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7401 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
7402 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
7405 /*******************************************************************
7406 reads or writes a structure.
7407 ********************************************************************/
7409 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
7410 prs_struct *ps, int depth)
7415 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
7421 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
7423 if (q_u->ptr != 0) {
7424 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7426 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7433 /*******************************************************************
7434 reads or writes a structure.
7435 ********************************************************************/
7437 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7438 prs_struct *ps, int depth)
7443 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7449 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
7453 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
7456 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7462 /*******************************************************************
7463 make a SAMR_ENC_PASSWD structure.
7464 ********************************************************************/
7466 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7474 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7478 /*******************************************************************
7479 reads or writes a SAMR_ENC_PASSWD structure.
7480 ********************************************************************/
7482 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7483 prs_struct *ps, int depth)
7488 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7494 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7497 if (pwd->ptr != 0) {
7498 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7505 /*******************************************************************
7506 inits a SAMR_ENC_HASH structure.
7507 ********************************************************************/
7509 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7517 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7521 /*******************************************************************
7522 reads or writes a SAMR_ENC_HASH structure.
7523 ********************************************************************/
7525 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7526 prs_struct *ps, int depth)
7531 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7537 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7539 if (hsh->ptr != 0) {
7540 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7547 /*******************************************************************
7548 inits a SAMR_Q_CHGPASSWD_USER structure.
7549 ********************************************************************/
7551 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7552 const char *dest_host, const char *user_name,
7553 const uchar nt_newpass[516],
7554 const uchar nt_oldhash[16],
7555 const uchar lm_newpass[516],
7556 const uchar lm_oldhash[16])
7558 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7561 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7562 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7564 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7565 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7567 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7568 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7570 q_u->unknown = 0x01;
7572 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7573 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7576 /*******************************************************************
7577 reads or writes a structure.
7578 ********************************************************************/
7580 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7581 prs_struct *ps, int depth)
7586 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7592 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7595 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7597 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7602 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7604 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7607 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7609 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7612 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7615 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7617 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7623 /*******************************************************************
7624 inits a SAMR_R_CHGPASSWD_USER structure.
7625 ********************************************************************/
7627 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7629 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7631 r_u->status = status;
7634 /*******************************************************************
7635 reads or writes a structure.
7636 ********************************************************************/
7638 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7639 prs_struct *ps, int depth)
7644 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7650 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7656 /*******************************************************************
7657 inits a SAMR_Q_CHGPASSWD3 structure.
7658 ********************************************************************/
7660 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
7661 const char *dest_host, const char *user_name,
7662 const uchar nt_newpass[516],
7663 const uchar nt_oldhash[16],
7664 const uchar lm_newpass[516],
7665 const uchar lm_oldhash[16])
7667 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7670 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7671 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7673 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7674 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7676 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7677 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7679 q_u->lm_change = 0x01;
7681 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7682 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7684 init_enc_passwd(&q_u->password3, NULL);
7687 /*******************************************************************
7688 reads or writes a structure.
7689 ********************************************************************/
7691 BOOL samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
7692 prs_struct *ps, int depth)
7697 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
7703 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7706 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7708 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7713 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7715 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7718 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7720 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7723 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
7726 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7728 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7731 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
7737 /*******************************************************************
7738 inits a SAMR_R_CHGPASSWD_USER3 structure.
7739 ********************************************************************/
7741 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
7742 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
7744 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7746 r_u->status = status;
7750 r_u->ptr_reject = 0;
7756 if (reject && (reject->reject_reason != Undefined)) {
7757 r_u->reject = reject;
7758 r_u->ptr_reject = 1;
7762 /*******************************************************************
7763 Reads or writes an SAMR_CHANGE_REJECT structure.
7764 ********************************************************************/
7766 BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
7771 prs_debug(ps, depth, desc, "samr_io_change_reject");
7777 if(UNMARSHALLING(ps))
7778 ZERO_STRUCTP(reject);
7780 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
7783 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
7786 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
7792 /*******************************************************************
7793 reads or writes a structure.
7794 ********************************************************************/
7796 BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
7797 prs_struct *ps, int depth)
7802 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
7808 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
7811 /* special case: Windows 2000 can return stub data here saying
7812 NT_STATUS_NOT_SUPPORTED */
7814 if ( NT_STATUS_EQUAL( NT_STATUS_NOT_SUPPORTED, NT_STATUS(r_u->ptr_info)) ) {
7815 r_u->status = NT_STATUS_NOT_SUPPORTED;
7819 if (r_u->ptr_info && r_u->info != NULL) {
7820 /* SAM_UNK_INFO_1 */
7821 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
7825 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
7828 if (r_u->ptr_reject && r_u->reject != NULL) {
7829 /* SAMR_CHANGE_REJECT */
7830 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
7834 if (!prs_ntstatus("status", ps, depth, &r_u->status))
7840 /*******************************************************************
7841 reads or writes a structure.
7842 ********************************************************************/
7844 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7845 POLICY_HND *domain_pol, uint16 switch_value)
7847 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7849 q_u->domain_pol = *domain_pol;
7850 q_u->switch_value = switch_value;
7853 /*******************************************************************
7854 reads or writes a structure.
7855 ********************************************************************/
7857 BOOL samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7858 prs_struct *ps, int depth)
7863 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7869 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7872 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7878 /*******************************************************************
7879 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7880 ********************************************************************/
7882 void init_samr_r_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7883 uint16 switch_value, SAM_UNK_CTR * ctr,
7886 DEBUG(5, ("init_samr_r_query_domain_info2\n"));
7889 r_u->switch_value = 0;
7890 r_u->status = status; /* return status */
7892 if (NT_STATUS_IS_OK(status)) {
7893 r_u->switch_value = switch_value;
7899 /*******************************************************************
7900 reads or writes a structure.
7901 ********************************************************************/
7903 BOOL samr_io_r_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7904 prs_struct *ps, int depth)
7909 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info2");
7915 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7918 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7919 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7924 switch (r_u->switch_value) {
7926 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
7930 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7934 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
7938 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
7942 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7946 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7950 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7954 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
7958 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7962 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7966 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7970 DEBUG(0, ("samr_io_r_query_domain_info2: unknown switch level 0x%x\n",
7971 r_u->switch_value));
7972 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7980 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7987 /*******************************************************************
7988 reads or writes a structure.
7989 ********************************************************************/
7991 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7992 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7994 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7996 q_u->domain_pol = *domain_pol;
7997 q_u->switch_value0 = switch_value;
7999 q_u->switch_value = switch_value;
8004 /*******************************************************************
8005 reads or writes a structure.
8006 ********************************************************************/
8008 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
8009 prs_struct *ps, int depth)
8014 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
8020 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
8023 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
8026 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
8032 if (UNMARSHALLING(ps)) {
8033 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
8037 switch (q_u->switch_value) {
8040 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
8044 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
8048 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
8052 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
8056 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
8060 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
8064 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
8068 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
8069 q_u->switch_value));
8076 /*******************************************************************
8077 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
8078 ********************************************************************/
8080 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
8082 DEBUG(5, ("init_samr_r_set_domain_info\n"));
8084 r_u->status = status; /* return status */
8087 /*******************************************************************
8088 reads or writes a structure.
8089 ********************************************************************/
8091 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
8092 prs_struct *ps, int depth)
8097 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
8103 if(!prs_ntstatus("status", ps, depth, &r_u->status))