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 3 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, see <http://www.gnu.org/licenses/>.
29 #define DBGC_CLASS DBGC_RPC_PARSE
31 /*******************************************************************
32 inits a SAMR_Q_CLOSE_HND structure.
33 ********************************************************************/
35 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
37 DEBUG(5, ("init_samr_q_close_hnd\n"));
42 /*******************************************************************
43 reads or writes a structure.
44 ********************************************************************/
46 bool samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
47 prs_struct *ps, int depth)
52 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
58 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
61 /*******************************************************************
62 reads or writes a structure.
63 ********************************************************************/
65 bool samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
66 prs_struct *ps, int depth)
71 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
77 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
80 if(!prs_ntstatus("status", ps, depth, &r_u->status))
86 /*******************************************************************
87 inits a SAMR_Q_LOOKUP_DOMAIN structure.
88 ********************************************************************/
90 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
91 POLICY_HND *pol, char *dom_name)
93 DEBUG(5, ("init_samr_q_lookup_domain\n"));
95 q_u->connect_pol = *pol;
97 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
98 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
101 /*******************************************************************
102 reads or writes a structure.
103 ********************************************************************/
104 bool samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
105 prs_struct *ps, int depth)
110 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
116 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
119 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
122 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
128 /*******************************************************************
129 inits a SAMR_R_LOOKUP_DOMAIN structure.
130 ********************************************************************/
132 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
133 DOM_SID *dom_sid, NTSTATUS status)
135 DEBUG(5, ("init_samr_r_lookup_domain\n"));
137 r_u->status = status;
139 if (NT_STATUS_IS_OK(status)) {
141 init_dom_sid2(&r_u->dom_sid, dom_sid);
145 /*******************************************************************
146 reads or writes a structure.
147 ********************************************************************/
149 bool samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
150 prs_struct *ps, int depth)
155 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
161 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
164 if (r_u->ptr_sid != 0) {
165 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
171 if(!prs_ntstatus("status", ps, depth, &r_u->status))
177 /*******************************************************************
178 reads or writes a structure.
179 ********************************************************************/
181 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
183 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
185 q_u->dom_pol = *dom_pol;
186 init_dom_sid2(&q_u->sid, sid);
189 /*******************************************************************
190 reads or writes a structure.
191 ********************************************************************/
193 bool samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
194 prs_struct *ps, int depth)
199 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
205 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
208 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
217 /*******************************************************************
218 reads or writes a structure.
219 ********************************************************************/
221 bool samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
222 prs_struct *ps, int depth)
227 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
233 if(!prs_ntstatus("status", ps, depth, &r_u->status))
239 /*******************************************************************
240 reads or writes a structure.
241 ********************************************************************/
243 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
244 POLICY_HND *pol, uint32 flags,
247 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
251 init_dom_sid2(&q_u->dom_sid, sid);
254 /*******************************************************************
255 reads or writes a structure.
256 ********************************************************************/
258 bool samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
259 prs_struct *ps, int depth)
264 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
270 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
273 if(!prs_uint32("flags", ps, depth, &q_u->flags))
276 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
282 /*******************************************************************
283 reads or writes a structure.
284 ********************************************************************/
286 bool samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
287 prs_struct *ps, int depth)
292 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
298 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
301 if(!prs_ntstatus("status", ps, depth, &r_u->status))
307 /*******************************************************************
308 reads or writes a structure.
309 ********************************************************************/
311 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
312 POLICY_HND *user_pol)
314 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
316 q_u->user_pol = *user_pol;
319 /*******************************************************************
320 reads or writes a structure.
321 ********************************************************************/
323 bool samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
324 prs_struct *ps, int depth)
329 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
335 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
338 /*******************************************************************
340 ********************************************************************/
342 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
344 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
346 r_u->min_pwd_length = 0x0000;
350 * r_u->unknown_1 = 0x0015;
353 r_u->unknown_1 = 0x01D1;
354 r_u->unknown_1 = 0x0015;
356 r_u->password_properties = 0x00000000;
358 r_u->status = status;
361 /*******************************************************************
362 reads or writes a structure.
363 ********************************************************************/
365 bool samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
366 prs_struct *ps, int depth)
371 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
377 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
379 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
381 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
384 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
391 /*******************************************************************
392 reads or writes a structure.
393 ********************************************************************/
395 bool samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
396 prs_struct *ps, int depth)
401 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
407 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
410 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
413 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
420 /*******************************************************************
421 reads or writes a structure.
422 ********************************************************************/
424 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
425 POLICY_HND *user_pol, uint32 sec_info)
427 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
429 q_u->user_pol = *user_pol;
430 q_u->sec_info = sec_info;
434 /*******************************************************************
435 reads or writes a structure.
436 ********************************************************************/
438 bool samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
439 prs_struct *ps, int depth)
444 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
450 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
453 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
459 /*******************************************************************
460 reads or writes a structure.
461 ********************************************************************/
463 void init_samr_q_query_domain_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
464 POLICY_HND *domain_pol, uint16 switch_value)
466 DEBUG(5, ("samr_init_samr_q_query_domain_info\n"));
468 q_u->domain_pol = *domain_pol;
469 q_u->switch_value = switch_value;
472 /*******************************************************************
473 reads or writes a structure.
474 ********************************************************************/
476 bool samr_io_q_query_domain_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
477 prs_struct *ps, int depth)
482 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info");
488 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
491 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
497 /*******************************************************************
499 ********************************************************************/
501 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
502 uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
504 u_1->min_length_password = min_pass_len;
505 u_1->password_history = pass_hist;
507 if (lp_check_password_script() && *lp_check_password_script()) {
508 password_properties |= DOMAIN_PASSWORD_COMPLEX;
510 u_1->password_properties = password_properties;
512 /* password never expire */
513 u_1->expire = nt_expire;
515 /* can change the password now */
516 u_1->min_passwordage = nt_min_age;
520 /*******************************************************************
521 reads or writes a structure.
522 ********************************************************************/
524 static bool sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
525 prs_struct *ps, int depth)
530 prs_debug(ps, depth, desc, "sam_io_unk_info1");
533 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
535 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
537 if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
539 if(!smb_io_time("expire", &u_1->expire, ps, depth))
541 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
547 /*******************************************************************
549 ********************************************************************/
551 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
552 const char *comment, const char *domain, const char *server,
553 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
555 u_2->logout = nt_logout;
557 u_2->seq_num = seq_num;
560 u_2->unknown_4 = 0x00000001;
561 u_2->server_role = server_role;
562 u_2->unknown_6 = 0x00000001;
563 u_2->num_domain_usrs = num_users;
564 u_2->num_domain_grps = num_groups;
565 u_2->num_local_grps = num_alias;
567 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
568 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
569 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
570 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
571 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
572 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
575 /*******************************************************************
576 reads or writes a structure.
577 ********************************************************************/
579 static bool sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
580 prs_struct *ps, int depth)
585 prs_debug(ps, depth, desc, "sam_io_unk_info2");
588 if(!smb_io_time("logout", &u_2->logout, ps, depth))
590 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
592 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
594 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
597 /* put all the data in here, at the moment, including what the above
598 pointer is referring to
601 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
604 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
606 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
608 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
610 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
612 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
614 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
617 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
619 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
621 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
627 /*******************************************************************
629 ********************************************************************/
631 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
633 u_3->logout = nt_logout;
636 /*******************************************************************
637 reads or writes a structure.
638 ********************************************************************/
640 static bool sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
641 prs_struct *ps, int depth)
646 prs_debug(ps, depth, desc, "sam_io_unk_info3");
649 if(!smb_io_time("logout", &u_3->logout, ps, depth))
655 /*******************************************************************
657 ********************************************************************/
659 void init_unk_info4(SAM_UNK_INFO_4 * u_4,const char *comment)
661 init_unistr2(&u_4->uni_comment, comment, UNI_FLAGS_NONE);
662 init_uni_hdr(&u_4->hdr_comment, &u_4->uni_comment);
665 /*******************************************************************
666 reads or writes a structure.
667 ********************************************************************/
669 static bool sam_io_unk_info4(const char *desc, SAM_UNK_INFO_4 * u_4,
670 prs_struct *ps, int depth)
675 prs_debug(ps, depth, desc, "sam_io_unk_info4");
678 if(!smb_io_unihdr("hdr_comment", &u_4->hdr_comment, ps, depth))
681 if(!smb_io_unistr2("uni_comment", &u_4->uni_comment, u_4->hdr_comment.buffer, ps, depth))
687 /*******************************************************************
689 ********************************************************************/
691 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *domain)
693 init_unistr2(&u_5->uni_domain, domain, UNI_FLAGS_NONE);
694 init_uni_hdr(&u_5->hdr_domain, &u_5->uni_domain);
697 /*******************************************************************
698 reads or writes a structure.
699 ********************************************************************/
701 static bool sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
702 prs_struct *ps, int depth)
707 prs_debug(ps, depth, desc, "sam_io_unk_info5");
710 if(!smb_io_unihdr("hdr_domain", &u_5->hdr_domain, ps, depth))
713 if(!smb_io_unistr2("uni_domain", &u_5->uni_domain, u_5->hdr_domain.buffer, ps, depth))
719 /*******************************************************************
721 ********************************************************************/
723 void init_unk_info6(SAM_UNK_INFO_6 * u_6, const char *server)
725 init_unistr2(&u_6->uni_server, server, UNI_FLAGS_NONE);
726 init_uni_hdr(&u_6->hdr_server, &u_6->uni_server);
729 /*******************************************************************
730 reads or writes a structure.
731 ********************************************************************/
733 static bool sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
734 prs_struct *ps, int depth)
739 prs_debug(ps, depth, desc, "sam_io_unk_info6");
742 if(!smb_io_unihdr("hdr_server", &u_6->hdr_server, ps, depth))
745 if(!smb_io_unistr2("uni_server", &u_6->uni_server, u_6->hdr_server.buffer, ps, depth))
751 /*******************************************************************
753 ********************************************************************/
755 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
757 u_7->server_role = server_role;
760 /*******************************************************************
761 reads or writes a structure.
762 ********************************************************************/
764 static bool sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
765 prs_struct *ps, int depth)
770 prs_debug(ps, depth, desc, "sam_io_unk_info7");
773 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
779 /*******************************************************************
781 ********************************************************************/
783 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
785 unix_to_nt_time(&u_8->domain_create_time, 0);
786 u_8->seq_num = seq_num;
789 /*******************************************************************
790 reads or writes a structure.
791 ********************************************************************/
793 static bool sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
794 prs_struct *ps, int depth)
799 prs_debug(ps, depth, desc, "sam_io_unk_info8");
802 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
805 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
811 /*******************************************************************
813 ********************************************************************/
815 void init_unk_info9(SAM_UNK_INFO_9 * u_9, uint32 unknown)
817 u_9->unknown = unknown;
820 /*******************************************************************
821 reads or writes a structure.
822 ********************************************************************/
824 static bool sam_io_unk_info9(const char *desc, SAM_UNK_INFO_9 * u_9,
825 prs_struct *ps, int depth)
830 prs_debug(ps, depth, desc, "sam_io_unk_info9");
833 if (!prs_uint32("unknown", ps, depth, &u_9->unknown))
839 /*******************************************************************
841 ********************************************************************/
843 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
845 u_12->duration = nt_lock_duration;
846 u_12->reset_count = nt_reset_time;
848 u_12->bad_attempt_lockout = lockout;
851 /*******************************************************************
852 reads or writes a structure.
853 ********************************************************************/
855 static bool sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
856 prs_struct *ps, int depth)
861 prs_debug(ps, depth, desc, "sam_io_unk_info12");
864 if(!smb_io_time("duration", &u_12->duration, ps, depth))
866 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
868 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
874 /*******************************************************************
876 ********************************************************************/
878 void init_unk_info13(SAM_UNK_INFO_13 * u_13, uint32 seq_num)
880 unix_to_nt_time(&u_13->domain_create_time, 0);
881 u_13->seq_num = seq_num;
886 /*******************************************************************
887 reads or writes a structure.
888 ********************************************************************/
890 static bool sam_io_unk_info13(const char *desc, SAM_UNK_INFO_13 * u_13,
891 prs_struct *ps, int depth)
896 prs_debug(ps, depth, desc, "sam_io_unk_info13");
899 if (!prs_uint64("seq_num", ps, depth, &u_13->seq_num))
902 if(!smb_io_time("domain_create_time", &u_13->domain_create_time, ps, depth))
905 if (!prs_uint32("unknown1", ps, depth, &u_13->unknown1))
907 if (!prs_uint32("unknown2", ps, depth, &u_13->unknown2))
913 /*******************************************************************
914 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
915 ********************************************************************/
917 void init_samr_r_query_domain_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
918 uint16 switch_value, SAM_UNK_CTR * ctr,
921 DEBUG(5, ("init_samr_r_query_domain_info\n"));
924 r_u->switch_value = 0;
925 r_u->status = status; /* return status */
927 if (NT_STATUS_IS_OK(status)) {
928 r_u->switch_value = switch_value;
934 /*******************************************************************
935 reads or writes a structure.
936 ********************************************************************/
938 bool samr_io_r_query_domain_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
939 prs_struct *ps, int depth)
944 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info");
950 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
953 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
954 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
959 switch (r_u->switch_value) {
961 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
965 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
969 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
973 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
977 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
981 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
985 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
989 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
993 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
997 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
1001 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
1005 DEBUG(0, ("samr_io_r_query_domain_info: unknown switch level 0x%x\n",
1006 r_u->switch_value));
1007 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
1015 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1021 /*******************************************************************
1022 reads or writes a structure.
1023 ********************************************************************/
1025 void init_samr_q_set_sec_obj(SAMR_Q_SET_SEC_OBJ * q_u,
1026 POLICY_HND *pol, uint32 sec_info, SEC_DESC_BUF *buf)
1028 DEBUG(5, ("samr_init_samr_q_set_sec_obj\n"));
1031 q_u->sec_info = sec_info;
1036 /*******************************************************************
1037 reads or writes a SAMR_R_SET_SEC_OBJ structure.
1038 ********************************************************************/
1040 bool samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
1041 prs_struct *ps, int depth)
1046 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
1052 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1058 /*******************************************************************
1059 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
1060 ********************************************************************/
1062 bool samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
1063 prs_struct *ps, int depth)
1068 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
1074 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
1076 if (r_u->ptr != 0) {
1077 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
1081 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1087 /*******************************************************************
1088 reads or writes a SAM_STR1 structure.
1089 ********************************************************************/
1091 static bool sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
1092 uint32 name_buf, uint32 desc_buf,
1093 prs_struct *ps, int depth)
1098 prs_debug(ps, depth, desc, "sam_io_sam_str1");
1103 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
1106 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
1109 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1115 /*******************************************************************
1116 inits a SAM_ENTRY1 structure.
1117 ********************************************************************/
1119 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1120 UNISTR2 *sam_name, UNISTR2 *sam_full,
1121 UNISTR2 *sam_desc, uint32 rid_user,
1124 DEBUG(5, ("init_sam_entry1\n"));
1128 sam->user_idx = user_idx;
1129 sam->rid_user = rid_user;
1130 sam->acb_info = acb_info;
1132 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1133 init_uni_hdr(&sam->hdr_user_name, sam_full);
1134 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1137 /*******************************************************************
1138 reads or writes a SAM_ENTRY1 structure.
1139 ********************************************************************/
1141 static bool sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1142 prs_struct *ps, int depth)
1147 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1153 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1156 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1158 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1161 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1163 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1165 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1171 /*******************************************************************
1172 reads or writes a SAM_STR2 structure.
1173 ********************************************************************/
1175 static bool sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1176 uint32 desc_buf, prs_struct *ps, int depth)
1181 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1187 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1189 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1195 /*******************************************************************
1196 inits a SAM_ENTRY2 structure.
1197 ********************************************************************/
1198 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1199 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1200 uint32 rid_user, uint32 acb_info)
1202 DEBUG(5, ("init_sam_entry2\n"));
1204 sam->user_idx = user_idx;
1205 sam->rid_user = rid_user;
1206 sam->acb_info = acb_info;
1208 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1209 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1212 /*******************************************************************
1213 reads or writes a SAM_ENTRY2 structure.
1214 ********************************************************************/
1216 static bool sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1217 prs_struct *ps, int depth)
1222 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1228 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1231 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1233 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1236 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1238 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1244 /*******************************************************************
1245 reads or writes a SAM_STR3 structure.
1246 ********************************************************************/
1248 static bool sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1249 uint32 desc_buf, prs_struct *ps, int depth)
1254 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1260 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1262 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1268 /*******************************************************************
1269 inits a SAM_ENTRY3 structure.
1270 ********************************************************************/
1272 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1273 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1276 DEBUG(5, ("init_sam_entry3\n"));
1278 sam->grp_idx = grp_idx;
1279 sam->rid_grp = rid_grp;
1280 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1282 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1283 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1286 /*******************************************************************
1287 reads or writes a SAM_ENTRY3 structure.
1288 ********************************************************************/
1290 static bool sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1291 prs_struct *ps, int depth)
1296 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1302 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1305 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1307 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1310 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1312 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1318 /*******************************************************************
1319 inits a SAM_ENTRY4 structure.
1320 ********************************************************************/
1322 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1323 uint32 len_acct_name)
1325 DEBUG(5, ("init_sam_entry4\n"));
1327 sam->user_idx = user_idx;
1328 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1331 /*******************************************************************
1332 reads or writes a SAM_ENTRY4 structure.
1333 ********************************************************************/
1335 static bool sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1336 prs_struct *ps, int depth)
1341 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1347 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1349 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1355 /*******************************************************************
1356 inits a SAM_ENTRY5 structure.
1357 ********************************************************************/
1359 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1360 uint32 len_grp_name)
1362 DEBUG(5, ("init_sam_entry5\n"));
1364 sam->grp_idx = grp_idx;
1365 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1369 /*******************************************************************
1370 reads or writes a SAM_ENTRY5 structure.
1371 ********************************************************************/
1373 static bool sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1374 prs_struct *ps, int depth)
1379 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1385 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1387 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1393 /*******************************************************************
1394 inits a SAM_ENTRY structure.
1395 ********************************************************************/
1397 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1399 DEBUG(10, ("init_sam_entry: %d\n", rid));
1402 init_uni_hdr(&sam->hdr_name, uni2);
1405 /*******************************************************************
1406 reads or writes a SAM_ENTRY structure.
1407 ********************************************************************/
1409 static bool sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1410 prs_struct *ps, int depth)
1415 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1420 if(!prs_uint32("rid", ps, depth, &sam->rid))
1422 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1428 /*******************************************************************
1429 inits a SAMR_Q_ENUM_DOM_USERS structure.
1430 ********************************************************************/
1432 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1434 uint32 acb_mask, uint32 size)
1436 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1440 q_e->start_idx = start_idx; /* zero indicates lots */
1441 q_e->acb_mask = acb_mask;
1442 q_e->max_size = size;
1445 /*******************************************************************
1446 reads or writes a structure.
1447 ********************************************************************/
1449 bool samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1450 prs_struct *ps, int depth)
1455 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1461 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1464 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1466 if(!prs_uint32("acb_mask ", ps, depth, &q_e->acb_mask))
1469 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1476 /*******************************************************************
1477 inits a SAMR_R_ENUM_DOM_USERS structure.
1478 ********************************************************************/
1480 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1481 uint32 next_idx, uint32 num_sam_entries)
1483 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1485 r_u->next_idx = next_idx;
1487 if (num_sam_entries != 0) {
1488 r_u->ptr_entries1 = 1;
1489 r_u->ptr_entries2 = 1;
1490 r_u->num_entries2 = num_sam_entries;
1491 r_u->num_entries3 = num_sam_entries;
1493 r_u->num_entries4 = num_sam_entries;
1495 r_u->ptr_entries1 = 0;
1496 r_u->num_entries2 = num_sam_entries;
1497 r_u->ptr_entries2 = 1;
1501 /*******************************************************************
1502 reads or writes a structure.
1503 ********************************************************************/
1505 bool samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1506 prs_struct *ps, int depth)
1513 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1519 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1521 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1524 if (r_u->ptr_entries1 != 0) {
1525 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1527 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1529 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1532 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1533 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1534 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1537 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1538 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1539 r_u->num_entries4 = 0;
1540 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1544 for (i = 0; i < r_u->num_entries2; i++) {
1545 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1549 for (i = 0; i < r_u->num_entries2; i++) {
1550 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1559 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1561 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1567 /*******************************************************************
1568 inits a SAMR_Q_QUERY_DISPINFO structure.
1569 ********************************************************************/
1571 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1572 uint16 switch_level, uint32 start_idx,
1573 uint32 max_entries, uint32 max_size)
1575 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1577 q_e->domain_pol = *pol;
1579 q_e->switch_level = switch_level;
1581 q_e->start_idx = start_idx;
1582 q_e->max_entries = max_entries;
1583 q_e->max_size = max_size;
1586 /*******************************************************************
1587 reads or writes a structure.
1588 ********************************************************************/
1590 bool samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1591 prs_struct *ps, int depth)
1596 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1602 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1605 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1610 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1612 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1614 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1620 /*******************************************************************
1621 inits a SAM_DISPINFO_1 structure.
1622 ********************************************************************/
1624 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1625 uint32 num_entries, uint32 start_idx,
1626 struct samr_displayentry *entries)
1630 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1633 return NT_STATUS_OK;
1635 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1637 return NT_STATUS_NO_MEMORY;
1639 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1640 if ((*sam)->sam == NULL)
1641 return NT_STATUS_NO_MEMORY;
1643 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1644 if ((*sam)->str == NULL)
1645 return NT_STATUS_NO_MEMORY;
1647 for (i = 0; i < num_entries ; i++) {
1648 init_unistr2(&(*sam)->str[i].uni_acct_name,
1649 entries[i].account_name, UNI_FLAGS_NONE);
1650 init_unistr2(&(*sam)->str[i].uni_full_name,
1651 entries[i].fullname, UNI_FLAGS_NONE);
1652 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1653 entries[i].description, UNI_FLAGS_NONE);
1655 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1656 &(*sam)->str[i].uni_acct_name,
1657 &(*sam)->str[i].uni_full_name,
1658 &(*sam)->str[i].uni_acct_desc,
1659 entries[i].rid, entries[i].acct_flags);
1662 return NT_STATUS_OK;
1665 /*******************************************************************
1666 reads or writes a structure.
1667 ********************************************************************/
1669 static bool sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1671 prs_struct *ps, int depth)
1675 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1681 if (UNMARSHALLING(ps) && num_entries > 0) {
1683 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1684 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1688 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1689 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1694 for (i = 0; i < num_entries; i++) {
1695 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1699 for (i = 0; i < num_entries; i++) {
1700 if(!sam_io_sam_str1("", &sam->str[i],
1701 sam->sam[i].hdr_acct_name.buffer,
1702 sam->sam[i].hdr_user_name.buffer,
1703 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1710 /*******************************************************************
1711 inits a SAM_DISPINFO_2 structure.
1712 ********************************************************************/
1714 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1715 uint32 num_entries, uint32 start_idx,
1716 struct samr_displayentry *entries)
1720 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1723 return NT_STATUS_OK;
1725 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1727 return NT_STATUS_NO_MEMORY;
1729 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1730 if ((*sam)->sam == NULL)
1731 return NT_STATUS_NO_MEMORY;
1733 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1734 if ((*sam)->str == NULL)
1735 return NT_STATUS_NO_MEMORY;
1737 for (i = 0; i < num_entries; i++) {
1738 init_unistr2(&(*sam)->str[i].uni_srv_name,
1739 entries[i].account_name, UNI_FLAGS_NONE);
1740 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1741 entries[i].description, UNI_FLAGS_NONE);
1743 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1744 &(*sam)->str[i].uni_srv_name,
1745 &(*sam)->str[i].uni_srv_desc,
1746 entries[i].rid, entries[i].acct_flags);
1749 return NT_STATUS_OK;
1752 /*******************************************************************
1753 reads or writes a structure.
1754 ********************************************************************/
1756 static bool sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1758 prs_struct *ps, int depth)
1765 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1771 if (UNMARSHALLING(ps) && num_entries > 0) {
1773 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1774 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1778 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1779 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1784 for (i = 0; i < num_entries; i++) {
1785 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1789 for (i = 0; i < num_entries; i++) {
1790 if(!sam_io_sam_str2("", &sam->str[i],
1791 sam->sam[i].hdr_srv_name.buffer,
1792 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1799 /*******************************************************************
1800 inits a SAM_DISPINFO_3 structure.
1801 ********************************************************************/
1803 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1804 uint32 num_entries, uint32 start_idx,
1805 struct samr_displayentry *entries)
1809 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1812 return NT_STATUS_OK;
1814 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1816 return NT_STATUS_NO_MEMORY;
1818 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1819 return NT_STATUS_NO_MEMORY;
1821 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1822 return NT_STATUS_NO_MEMORY;
1824 for (i = 0; i < num_entries; i++) {
1825 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1827 init_unistr2(&(*sam)->str[i].uni_grp_name,
1828 entries[i].account_name, UNI_FLAGS_NONE);
1829 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1830 entries[i].description, UNI_FLAGS_NONE);
1832 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1833 &(*sam)->str[i].uni_grp_name,
1834 &(*sam)->str[i].uni_grp_desc,
1838 return NT_STATUS_OK;
1841 /*******************************************************************
1842 reads or writes a structure.
1843 ********************************************************************/
1845 static bool sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1847 prs_struct *ps, int depth)
1854 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1860 if (UNMARSHALLING(ps) && num_entries > 0) {
1862 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1863 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1867 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1868 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1873 for (i = 0; i < num_entries; i++) {
1874 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1878 for (i = 0; i < num_entries; i++) {
1879 if(!sam_io_sam_str3("", &sam->str[i],
1880 sam->sam[i].hdr_grp_name.buffer,
1881 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1888 /*******************************************************************
1889 inits a SAM_DISPINFO_4 structure.
1890 ********************************************************************/
1892 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1893 uint32 num_entries, uint32 start_idx,
1894 struct samr_displayentry *entries)
1898 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1901 return NT_STATUS_OK;
1903 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1905 return NT_STATUS_NO_MEMORY;
1907 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1908 if ((*sam)->sam == NULL)
1909 return NT_STATUS_NO_MEMORY;
1911 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1912 if ((*sam)->str == NULL)
1913 return NT_STATUS_NO_MEMORY;
1915 for (i = 0; i < num_entries; i++) {
1916 size_t len_sam_name = strlen(entries[i].account_name);
1918 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1920 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1923 init_string2(&(*sam)->str[i].acct_name,
1924 entries[i].account_name, len_sam_name+1,
1928 return NT_STATUS_OK;
1931 /*******************************************************************
1932 reads or writes a structure.
1933 ********************************************************************/
1935 static bool sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1937 prs_struct *ps, int depth)
1944 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1950 if (UNMARSHALLING(ps) && num_entries > 0) {
1952 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1953 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1957 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1958 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1963 for (i = 0; i < num_entries; i++) {
1964 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1968 for (i = 0; i < num_entries; i++) {
1969 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1970 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1977 /*******************************************************************
1978 inits a SAM_DISPINFO_5 structure.
1979 ********************************************************************/
1981 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1982 uint32 num_entries, uint32 start_idx,
1983 struct samr_displayentry *entries)
1985 uint32 len_sam_name;
1988 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1991 return NT_STATUS_OK;
1993 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1995 return NT_STATUS_NO_MEMORY;
1997 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1998 return NT_STATUS_NO_MEMORY;
2000 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
2001 return NT_STATUS_NO_MEMORY;
2003 for (i = 0; i < num_entries; i++) {
2004 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
2006 len_sam_name = strlen(entries[i].account_name);
2008 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
2009 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
2010 len_sam_name+1, len_sam_name);
2013 return NT_STATUS_OK;
2016 /*******************************************************************
2017 reads or writes a structure.
2018 ********************************************************************/
2020 static bool sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
2022 prs_struct *ps, int depth)
2029 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
2035 if (UNMARSHALLING(ps) && num_entries > 0) {
2037 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
2038 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
2042 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
2043 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2048 for (i = 0; i < num_entries; i++) {
2049 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2053 for (i = 0; i < num_entries; i++) {
2054 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
2055 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2062 /*******************************************************************
2063 inits a SAMR_R_QUERY_DISPINFO structure.
2064 ********************************************************************/
2066 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2067 uint32 num_entries, uint32 total_size, uint32 data_size,
2068 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2071 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2073 r_u->total_size = total_size;
2075 r_u->data_size = data_size;
2077 r_u->switch_level = switch_level;
2078 r_u->num_entries = num_entries;
2081 r_u->ptr_entries = 0;
2083 r_u->ptr_entries = 1;
2085 r_u->num_entries2 = num_entries;
2088 r_u->status = status;
2091 /*******************************************************************
2092 reads or writes a structure.
2093 ********************************************************************/
2095 bool samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2096 prs_struct *ps, int depth)
2101 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2107 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2109 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2111 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2116 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2118 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2121 if (r_u->ptr_entries==0) {
2124 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2130 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2133 switch (r_u->switch_level) {
2135 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2136 r_u->num_entries, ps, depth))
2140 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2141 r_u->num_entries, ps, depth))
2145 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2146 r_u->num_entries, ps, depth))
2150 if(!sam_io_sam_dispinfo_4("user list",
2151 r_u->ctr->sam.info4,
2152 r_u->num_entries, ps, depth))
2156 if(!sam_io_sam_dispinfo_5("group list",
2157 r_u->ctr->sam.info5,
2158 r_u->num_entries, ps, depth))
2162 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2168 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2174 /*******************************************************************
2175 inits a SAMR_Q_OPEN_GROUP structure.
2176 ********************************************************************/
2178 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2180 uint32 access_mask, uint32 rid)
2182 DEBUG(5, ("init_samr_q_open_group\n"));
2184 q_c->domain_pol = *hnd;
2185 q_c->access_mask = access_mask;
2186 q_c->rid_group = rid;
2189 /*******************************************************************
2190 reads or writes a structure.
2191 ********************************************************************/
2193 bool samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2194 prs_struct *ps, int depth)
2199 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2205 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2208 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2210 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2216 /*******************************************************************
2217 reads or writes a structure.
2218 ********************************************************************/
2220 bool samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2221 prs_struct *ps, int depth)
2226 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2232 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2235 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2241 /*******************************************************************
2242 inits a GROUP_INFO1 structure.
2243 ********************************************************************/
2245 void init_samr_group_info1(GROUP_INFO1 * gr1,
2246 char *acct_name, char *acct_desc,
2249 DEBUG(5, ("init_samr_group_info1\n"));
2251 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2252 gr1->num_members = num_members;
2254 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2255 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2256 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2257 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2260 /*******************************************************************
2261 reads or writes a structure.
2262 ********************************************************************/
2264 bool samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2265 prs_struct *ps, int depth)
2272 prs_debug(ps, depth, desc, "samr_io_group_info1");
2275 if(!prs_uint16("level", ps, depth, &dummy))
2281 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2284 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2286 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2289 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2292 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2293 gr1->hdr_acct_name.buffer, ps, depth))
2296 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2297 gr1->hdr_acct_desc.buffer, ps, depth))
2303 /*******************************************************************
2304 inits a GROUP_INFO2 structure.
2305 ********************************************************************/
2307 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2309 DEBUG(5, ("init_samr_group_info2\n"));
2312 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2313 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2316 /*******************************************************************
2317 reads or writes a structure.
2318 ********************************************************************/
2320 bool samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2325 prs_debug(ps, depth, desc, "samr_io_group_info2");
2328 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2331 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2333 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2334 gr2->hdr_acct_name.buffer, ps, depth))
2340 /*******************************************************************
2341 inits a GROUP_INFO3 structure.
2342 ********************************************************************/
2344 void init_samr_group_info3(GROUP_INFO3 *gr3)
2346 DEBUG(5, ("init_samr_group_info3\n"));
2348 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2351 /*******************************************************************
2352 reads or writes a structure.
2353 ********************************************************************/
2355 bool samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2360 prs_debug(ps, depth, desc, "samr_io_group_info3");
2366 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2372 /*******************************************************************
2373 inits a GROUP_INFO4 structure.
2374 ********************************************************************/
2376 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2378 DEBUG(5, ("init_samr_group_info4\n"));
2381 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2382 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2385 /*******************************************************************
2386 reads or writes a structure.
2387 ********************************************************************/
2389 bool samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2390 prs_struct *ps, int depth)
2395 prs_debug(ps, depth, desc, "samr_io_group_info4");
2398 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2400 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2402 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2403 gr4->hdr_acct_desc.buffer, ps, depth))
2409 /*******************************************************************
2410 inits a GROUP_INFO5 structure.
2411 ********************************************************************/
2413 void init_samr_group_info5(GROUP_INFO5 * gr5,
2414 char *acct_name, char *acct_desc,
2417 DEBUG(5, ("init_samr_group_info5\n"));
2419 gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2420 gr5->num_members = num_members;
2422 init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2423 init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
2424 init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2425 init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
2428 /*******************************************************************
2429 reads or writes a structure.
2430 ********************************************************************/
2432 bool samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
2433 prs_struct *ps, int depth)
2440 prs_debug(ps, depth, desc, "samr_io_group_info5");
2443 if(!prs_uint16("level", ps, depth, &dummy))
2449 if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
2452 if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
2454 if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
2457 if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
2460 if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
2461 gr5->hdr_acct_name.buffer, ps, depth))
2464 if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
2465 gr5->hdr_acct_desc.buffer, ps, depth))
2472 /*******************************************************************
2473 reads or writes a structure.
2474 ********************************************************************/
2476 static bool samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2477 prs_struct *ps, int depth)
2479 if (UNMARSHALLING(ps))
2480 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2485 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2488 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2491 switch ((*ctr)->switch_value1) {
2493 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2497 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2501 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2505 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2509 if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
2513 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2520 /*******************************************************************
2521 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2522 ********************************************************************/
2524 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2525 POLICY_HND *pol, const char *acct_desc,
2528 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2532 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2533 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2535 q_e->access_mask = access_mask;
2538 /*******************************************************************
2539 reads or writes a structure.
2540 ********************************************************************/
2542 bool samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2543 prs_struct *ps, int depth)
2548 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2554 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2557 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2559 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2560 q_e->hdr_acct_desc.buffer, ps, depth))
2565 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2571 /*******************************************************************
2572 reads or writes a structure.
2573 ********************************************************************/
2575 bool samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2576 prs_struct *ps, int depth)
2581 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2587 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2590 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2592 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2598 /*******************************************************************
2599 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2600 ********************************************************************/
2602 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2605 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2607 q_c->group_pol = *hnd;
2610 /*******************************************************************
2611 reads or writes a structure.
2612 ********************************************************************/
2614 bool samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2615 prs_struct *ps, int depth)
2620 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2626 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2632 /*******************************************************************
2633 reads or writes a structure.
2634 ********************************************************************/
2636 bool samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2637 prs_struct *ps, int depth)
2642 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2648 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2651 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2657 /*******************************************************************
2658 inits a SAMR_Q_DEL_GROUPMEM structure.
2659 ********************************************************************/
2661 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2662 POLICY_HND *pol, uint32 rid)
2664 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2670 /*******************************************************************
2671 reads or writes a structure.
2672 ********************************************************************/
2674 bool samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2675 prs_struct *ps, int depth)
2680 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2686 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2689 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2695 /*******************************************************************
2696 inits a SAMR_R_DEL_GROUPMEM structure.
2697 ********************************************************************/
2699 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2702 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2704 r_u->status = status;
2707 /*******************************************************************
2708 reads or writes a structure.
2709 ********************************************************************/
2711 bool samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2712 prs_struct *ps, int depth)
2717 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2723 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2729 /*******************************************************************
2730 inits a SAMR_Q_ADD_GROUPMEM structure.
2731 ********************************************************************/
2733 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2734 POLICY_HND *pol, uint32 rid)
2736 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2740 q_e->unknown = 0x0005;
2743 /*******************************************************************
2744 reads or writes a structure.
2745 ********************************************************************/
2747 bool samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2748 prs_struct *ps, int depth)
2753 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2759 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2762 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2764 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2770 /*******************************************************************
2771 inits a SAMR_R_ADD_GROUPMEM structure.
2772 ********************************************************************/
2774 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2777 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2779 r_u->status = status;
2782 /*******************************************************************
2783 reads or writes a structure.
2784 ********************************************************************/
2786 bool samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2787 prs_struct *ps, int depth)
2792 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2798 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2804 /*******************************************************************
2805 inits a SAMR_Q_SET_GROUPINFO structure.
2806 ********************************************************************/
2808 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2809 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2811 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2817 /*******************************************************************
2818 reads or writes a structure.
2819 ********************************************************************/
2821 bool samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2822 prs_struct *ps, int depth)
2827 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2833 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2836 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2842 /*******************************************************************
2843 inits a SAMR_R_SET_GROUPINFO structure.
2844 ********************************************************************/
2846 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2848 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2850 r_u->status = status;
2853 /*******************************************************************
2854 reads or writes a structure.
2855 ********************************************************************/
2857 bool samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2858 prs_struct *ps, int depth)
2863 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2869 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2875 /*******************************************************************
2876 inits a SAMR_Q_QUERY_GROUPINFO structure.
2877 ********************************************************************/
2879 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2880 POLICY_HND *pol, uint16 switch_level)
2882 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2886 q_e->switch_level = switch_level;
2889 /*******************************************************************
2890 reads or writes a structure.
2891 ********************************************************************/
2893 bool samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2894 prs_struct *ps, int depth)
2899 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2905 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2908 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2914 /*******************************************************************
2915 inits a SAMR_R_QUERY_GROUPINFO structure.
2916 ********************************************************************/
2918 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2919 GROUP_INFO_CTR * ctr, NTSTATUS status)
2921 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2923 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2925 r_u->status = status;
2928 /*******************************************************************
2929 reads or writes a structure.
2930 ********************************************************************/
2932 bool samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2933 prs_struct *ps, int depth)
2938 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2944 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2947 if (r_u->ptr != 0) {
2948 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2954 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2960 /*******************************************************************
2961 inits a SAMR_Q_QUERY_GROUPMEM structure.
2962 ********************************************************************/
2964 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2966 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2968 q_c->group_pol = *hnd;
2971 /*******************************************************************
2972 reads or writes a structure.
2973 ********************************************************************/
2975 bool samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2976 prs_struct *ps, int depth)
2981 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2987 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2993 /*******************************************************************
2994 inits a SAMR_R_QUERY_GROUPMEM structure.
2995 ********************************************************************/
2997 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2998 uint32 num_entries, uint32 *rid,
2999 uint32 *attr, NTSTATUS status)
3001 DEBUG(5, ("init_samr_r_query_groupmem\n"));
3003 if (NT_STATUS_IS_OK(status)) {
3005 r_u->num_entries = num_entries;
3007 r_u->ptr_attrs = attr != NULL ? 1 : 0;
3008 r_u->ptr_rids = rid != NULL ? 1 : 0;
3010 r_u->num_rids = num_entries;
3013 r_u->num_attrs = num_entries;
3017 r_u->num_entries = 0;
3020 r_u->status = status;
3023 /*******************************************************************
3024 reads or writes a structure.
3025 ********************************************************************/
3027 bool samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
3028 prs_struct *ps, int depth)
3035 if (UNMARSHALLING(ps))
3038 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
3044 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3046 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3049 if (r_u->ptr != 0) {
3050 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
3052 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
3055 if (r_u->ptr_rids != 0) {
3056 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
3058 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
3059 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
3060 if (r_u->rid == NULL)
3064 for (i = 0; i < r_u->num_rids; i++) {
3065 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
3070 if (r_u->ptr_attrs != 0) {
3071 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
3074 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
3075 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
3076 if (r_u->attr == NULL)
3080 for (i = 0; i < r_u->num_attrs; i++) {
3081 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
3087 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3093 /*******************************************************************
3094 inits a SAMR_Q_QUERY_USERGROUPS structure.
3095 ********************************************************************/
3097 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
3100 DEBUG(5, ("init_samr_q_query_usergroups\n"));
3105 /*******************************************************************
3106 reads or writes a structure.
3107 ********************************************************************/
3109 bool samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
3110 prs_struct *ps, int depth)
3115 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
3121 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3127 /*******************************************************************
3128 inits a SAMR_R_QUERY_USERGROUPS structure.
3129 ********************************************************************/
3131 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3132 uint32 num_gids, DOM_GID * gid,
3135 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3137 if (NT_STATUS_IS_OK(status)) {
3139 r_u->num_entries = num_gids;
3140 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3141 r_u->num_entries2 = num_gids;
3146 r_u->num_entries = 0;
3151 r_u->status = status;
3154 /*******************************************************************
3155 reads or writes a structure.
3156 ********************************************************************/
3158 bool samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3159 prs_struct *ps, int depth)
3165 prs_debug(ps, depth, desc, "samr_io_gids");
3171 if(!prs_uint32("num_gids", ps, depth, num_gids))
3174 if ((*num_gids) != 0) {
3175 if (UNMARSHALLING(ps)) {
3176 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3179 if ((*gid) == NULL) {
3183 for (i = 0; i < (*num_gids); i++) {
3184 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3192 /*******************************************************************
3193 reads or writes a structure.
3194 ********************************************************************/
3196 bool samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3197 prs_struct *ps, int depth)
3202 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3208 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3211 if (r_u->ptr_0 != 0) {
3212 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3214 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3217 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3218 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3225 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3231 /*******************************************************************
3232 inits a SAMR_Q_ENUM_DOMAINS structure.
3233 ********************************************************************/
3235 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3237 uint32 start_idx, uint32 size)
3239 DEBUG(5, ("init_samr_q_enum_domains\n"));
3243 q_e->start_idx = start_idx;
3244 q_e->max_size = size;
3247 /*******************************************************************
3248 reads or writes a structure.
3249 ********************************************************************/
3251 bool samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3252 prs_struct *ps, int depth)
3257 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3263 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3266 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3268 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3274 /*******************************************************************
3275 inits a SAMR_R_ENUM_DOMAINS structure.
3276 ********************************************************************/
3278 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3279 uint32 next_idx, uint32 num_sam_entries)
3281 DEBUG(5, ("init_samr_r_enum_domains\n"));
3283 r_u->next_idx = next_idx;
3285 if (num_sam_entries != 0) {
3286 r_u->ptr_entries1 = 1;
3287 r_u->ptr_entries2 = 1;
3288 r_u->num_entries2 = num_sam_entries;
3289 r_u->num_entries3 = num_sam_entries;
3291 r_u->num_entries4 = num_sam_entries;
3293 r_u->ptr_entries1 = 0;
3294 r_u->num_entries2 = num_sam_entries;
3295 r_u->ptr_entries2 = 1;
3299 /*******************************************************************
3300 reads or writes a structure.
3301 ********************************************************************/
3303 bool samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3304 prs_struct *ps, int depth)
3311 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3317 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3319 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3322 if (r_u->ptr_entries1 != 0) {
3323 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3325 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3327 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3330 if (UNMARSHALLING(ps) && r_u->num_entries2) {
3331 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3332 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3335 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3336 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3337 r_u->num_entries4 = 0;
3338 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3342 for (i = 0; i < r_u->num_entries2; i++) {
3344 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3345 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3349 for (i = 0; i < r_u->num_entries2; i++) {
3351 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3352 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3353 r_u->sam[i].hdr_name.buffer, ps,
3362 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3364 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3370 /*******************************************************************
3371 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3372 ********************************************************************/
3374 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3376 uint32 start_idx, uint32 size)
3378 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3382 q_e->start_idx = start_idx;
3383 q_e->max_size = size;
3386 /*******************************************************************
3387 reads or writes a structure.
3388 ********************************************************************/
3390 bool samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3391 prs_struct *ps, int depth)
3396 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3402 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3405 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3407 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3413 /*******************************************************************
3414 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3415 ********************************************************************/
3417 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3418 uint32 next_idx, uint32 num_sam_entries)
3420 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3422 r_u->next_idx = next_idx;
3424 if (num_sam_entries != 0) {
3425 r_u->ptr_entries1 = 1;
3426 r_u->ptr_entries2 = 1;
3427 r_u->num_entries2 = num_sam_entries;
3428 r_u->num_entries3 = num_sam_entries;
3430 r_u->num_entries4 = num_sam_entries;
3432 r_u->ptr_entries1 = 0;
3433 r_u->num_entries2 = num_sam_entries;
3434 r_u->ptr_entries2 = 1;
3438 /*******************************************************************
3439 reads or writes a structure.
3440 ********************************************************************/
3442 bool samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3443 prs_struct *ps, int depth)
3450 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3456 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3458 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3461 if (r_u->ptr_entries1 != 0) {
3462 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3464 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3466 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3469 if (UNMARSHALLING(ps) && r_u->num_entries2) {
3470 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3471 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3474 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3476 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3477 r_u->num_entries4 = 0;
3478 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3482 for (i = 0; i < r_u->num_entries2; i++) {
3483 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3487 for (i = 0; i < r_u->num_entries2; i++) {
3488 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3489 r_u->sam[i].hdr_name.buffer, ps, depth))
3496 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3498 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3504 /*******************************************************************
3505 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3506 ********************************************************************/
3508 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3509 POLICY_HND *pol, uint32 start_idx,
3512 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3516 q_e->start_idx = start_idx;
3517 q_e->max_size = size;
3521 /*******************************************************************
3522 reads or writes a structure.
3523 ********************************************************************/
3525 bool samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3526 prs_struct *ps, int depth)
3531 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3537 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3540 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3542 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3548 /*******************************************************************
3549 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3550 ********************************************************************/
3552 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3554 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3556 r_u->next_idx = next_idx;
3558 if (num_sam_entries != 0) {
3559 r_u->ptr_entries1 = 1;
3560 r_u->ptr_entries2 = 1;
3561 r_u->num_entries2 = num_sam_entries;
3562 r_u->num_entries3 = num_sam_entries;
3564 r_u->num_entries4 = num_sam_entries;
3566 r_u->ptr_entries1 = 0;
3567 r_u->num_entries2 = num_sam_entries;
3568 r_u->ptr_entries2 = 1;
3572 /*******************************************************************
3573 reads or writes a structure.
3574 ********************************************************************/
3576 bool samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3577 prs_struct *ps, int depth)
3584 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3590 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3592 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3595 if (r_u->ptr_entries1 != 0) {
3596 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3598 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3600 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3603 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3604 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3605 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3608 if (r_u->num_entries2 != 0 &&
3609 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3610 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3611 r_u->num_entries4 = 0;
3612 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3616 for (i = 0; i < r_u->num_entries2; i++) {
3617 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3621 for (i = 0; i < r_u->num_entries2; i++) {
3622 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3623 r_u->sam[i].hdr_name.buffer, ps,
3631 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3633 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3639 /*******************************************************************
3640 inits a ALIAS_INFO1 structure.
3641 ********************************************************************/
3643 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3645 DEBUG(5, ("init_samr_alias_info1\n"));
3647 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3648 al1->num_member = num_member;
3649 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3652 /*******************************************************************
3653 reads or writes a structure.
3654 ********************************************************************/
3656 bool samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3657 prs_struct *ps, int depth)
3662 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3668 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3670 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3672 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3675 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3677 if ( !prs_align(ps) )
3679 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3681 if ( !prs_align(ps) )
3687 /*******************************************************************
3688 inits a ALIAS_INFO3 structure.
3689 ********************************************************************/
3691 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3693 DEBUG(5, ("init_samr_alias_info3\n"));
3695 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3698 /*******************************************************************
3699 reads or writes a structure.
3700 ********************************************************************/
3702 bool samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3703 prs_struct *ps, int depth)
3708 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3714 if (!prs_unistr4("description", ps, depth, &al3->description))
3720 /*******************************************************************
3721 reads or writes a structure.
3722 ********************************************************************/
3724 bool samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
3725 prs_struct *ps, int depth)
3730 prs_debug(ps, depth, desc, "samr_io_alias_info2");
3736 if (!prs_unistr4("name", ps, depth, &al2->name))
3742 /*******************************************************************
3743 reads or writes a structure.
3744 ********************************************************************/
3746 bool samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3751 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3754 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3759 switch (ctr->level) {
3761 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3765 if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
3769 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3773 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3780 /*******************************************************************
3781 inits a SAMR_Q_QUERY_ALIASINFO structure.
3782 ********************************************************************/
3784 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3785 POLICY_HND *pol, uint32 switch_level)
3787 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3790 q_e->level = switch_level;
3793 /*******************************************************************
3794 reads or writes a structure.
3795 ********************************************************************/
3797 bool samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3798 prs_struct *ps, int depth)
3803 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3809 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3812 if ( !prs_uint16("level", ps, depth, &in->level) )
3818 /*******************************************************************
3819 inits a SAMR_R_QUERY_ALIASINFO structure.
3820 ********************************************************************/
3822 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3823 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3825 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3828 out->status = status;
3831 /*******************************************************************
3832 reads or writes a structure.
3833 ********************************************************************/
3835 bool samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3836 prs_struct *ps, int depth)
3841 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3847 if ( !prs_pointer("alias", ps, depth, (void*)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3852 if(!prs_ntstatus("status", ps, depth, &out->status))
3858 /*******************************************************************
3859 inits a SAMR_Q_SET_ALIASINFO structure.
3860 ********************************************************************/
3862 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3863 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3865 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3867 q_u->alias_pol = *hnd;
3871 /*******************************************************************
3872 reads or writes a structure.
3873 ********************************************************************/
3875 bool samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3876 prs_struct *ps, int depth)
3881 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3887 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3889 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3895 /*******************************************************************
3896 reads or writes a structure.
3897 ********************************************************************/
3899 bool samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3900 prs_struct *ps, int depth)
3905 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3910 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3916 /*******************************************************************
3917 inits a SAMR_Q_QUERY_USERALIASES structure.
3918 ********************************************************************/
3920 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3923 uint32 *ptr_sid, DOM_SID2 * sid)
3925 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3929 q_u->num_sids1 = num_sids;
3931 q_u->num_sids2 = num_sids;
3933 q_u->ptr_sid = ptr_sid;
3937 /*******************************************************************
3938 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3939 ********************************************************************/
3941 bool samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3942 prs_struct *ps, int depth)
3950 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3956 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3959 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3961 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3967 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3970 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3971 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3972 if (q_u->ptr_sid == NULL)
3975 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3976 if (q_u->sid == NULL)
3980 for (i = 0; i < q_u->num_sids2; i++) {
3981 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3982 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3986 for (i = 0; i < q_u->num_sids2; i++) {
3987 if (q_u->ptr_sid[i] != 0) {
3988 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3989 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3997 /*******************************************************************
3998 inits a SAMR_R_QUERY_USERALIASES structure.
3999 ********************************************************************/
4001 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
4002 uint32 num_rids, uint32 *rid,
4005 DEBUG(5, ("init_samr_r_query_useraliases\n"));
4007 if (NT_STATUS_IS_OK(status)) {
4008 r_u->num_entries = num_rids;
4010 r_u->num_entries2 = num_rids;
4014 r_u->num_entries = 0;
4016 r_u->num_entries2 = 0;
4019 r_u->status = status;
4022 /*******************************************************************
4023 reads or writes a structure.
4024 ********************************************************************/
4026 bool samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
4027 prs_struct *ps, int depth)
4034 prs_debug(ps, depth, desc, "samr_io_rids");
4040 if(!prs_uint32("num_rids", ps, depth, num_rids))
4043 if ((*num_rids) != 0) {
4044 if (UNMARSHALLING(ps)) {
4046 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
4051 for (i = 0; i < (*num_rids); i++) {
4052 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
4053 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
4061 /*******************************************************************
4062 reads or writes a structure.
4063 ********************************************************************/
4065 bool samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
4066 prs_struct *ps, int depth)
4071 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
4077 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
4079 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
4082 if (r_u->ptr != 0) {
4083 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
4089 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4095 /*******************************************************************
4096 inits a SAMR_Q_OPEN_ALIAS structure.
4097 ********************************************************************/
4099 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
4100 uint32 access_mask, uint32 rid)
4102 DEBUG(5, ("init_samr_q_open_alias\n"));
4104 q_u->dom_pol = *pol;
4105 q_u->access_mask = access_mask;
4106 q_u->rid_alias = rid;
4109 /*******************************************************************
4110 reads or writes a structure.
4111 ********************************************************************/
4113 bool samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
4114 prs_struct *ps, int depth)
4119 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
4125 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
4128 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4130 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
4136 /*******************************************************************
4137 reads or writes a structure.
4138 ********************************************************************/
4140 bool samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4141 prs_struct *ps, int depth)
4146 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4152 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4155 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4161 /*******************************************************************
4162 inits a SAMR_Q_LOOKUP_RIDS structure.
4163 ********************************************************************/
4165 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4166 POLICY_HND *pol, uint32 flags,
4167 uint32 num_rids, uint32 *rid)
4169 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4173 q_u->num_rids1 = num_rids;
4176 q_u->num_rids2 = num_rids;
4178 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4182 if (q_u->rid == NULL) {
4186 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4190 /*******************************************************************
4191 reads or writes a structure.
4192 ********************************************************************/
4194 bool samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4195 prs_struct *ps, int depth)
4203 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4206 if (UNMARSHALLING(ps))
4212 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4215 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4217 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4219 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4221 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4224 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4225 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4226 if (q_u->rid == NULL)
4230 for (i = 0; i < q_u->num_rids2; i++) {
4231 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4232 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4239 /*******************************************************************
4240 inits a SAMR_R_LOOKUP_RIDS structure.
4241 ********************************************************************/
4243 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4244 uint32 num_names, UNIHDR * hdr_name,
4245 UNISTR2 *uni_name, uint32 *type)
4247 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4249 r_u->hdr_name = NULL;
4250 r_u->uni_name = NULL;
4253 if (num_names != 0) {
4254 r_u->num_names1 = num_names;
4256 r_u->num_names2 = num_names;
4258 r_u->num_types1 = num_names;
4260 r_u->num_types2 = num_names;
4262 r_u->hdr_name = hdr_name;
4263 r_u->uni_name = uni_name;
4266 r_u->num_names1 = num_names;
4268 r_u->num_names2 = num_names;
4270 r_u->num_types1 = num_names;
4272 r_u->num_types2 = num_names;
4276 /*******************************************************************
4277 reads or writes a structure.
4278 ********************************************************************/
4280 bool samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4281 prs_struct *ps, int depth)
4288 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4294 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4296 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4299 if (r_u->ptr_names != 0) {
4301 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4305 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4306 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4307 if (r_u->hdr_name == NULL)
4310 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4311 if (r_u->uni_name == NULL)
4315 for (i = 0; i < r_u->num_names2; i++) {
4316 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4317 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4320 for (i = 0; i < r_u->num_names2; i++) {
4321 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4322 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4330 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4332 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4335 if (r_u->ptr_types != 0) {
4337 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4340 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4341 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4342 if (r_u->type == NULL)
4346 for (i = 0; i < r_u->num_types2; i++) {
4347 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4348 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4353 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4359 /*******************************************************************
4360 inits a SAMR_Q_OPEN_ALIAS structure.
4361 ********************************************************************/
4363 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4365 DEBUG(5, ("init_samr_q_delete_alias\n"));
4367 q_u->alias_pol = *hnd;
4370 /*******************************************************************
4371 reads or writes a structure.
4372 ********************************************************************/
4374 bool samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4375 prs_struct *ps, int depth)
4380 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4386 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4392 /*******************************************************************
4393 reads or writes a structure.
4394 ********************************************************************/
4396 bool samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4397 prs_struct *ps, int depth)
4402 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4408 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4410 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4416 /*******************************************************************
4417 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4418 ********************************************************************/
4420 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4421 POLICY_HND *hnd, const char *acct_desc)
4423 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4425 q_u->dom_pol = *hnd;
4427 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4428 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4430 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4433 /*******************************************************************
4434 reads or writes a structure.
4435 ********************************************************************/
4437 bool samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4438 prs_struct *ps, int depth)
4443 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4449 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4452 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4454 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4455 q_u->hdr_acct_desc.buffer, ps, depth))
4460 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4466 /*******************************************************************
4467 reads or writes a structure.
4468 ********************************************************************/
4470 bool samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4471 prs_struct *ps, int depth)
4476 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4482 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4485 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4488 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4494 /*******************************************************************
4495 inits a SAMR_Q_ADD_ALIASMEM structure.
4496 ********************************************************************/
4498 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4501 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4503 q_u->alias_pol = *hnd;
4504 init_dom_sid2(&q_u->sid, sid);
4507 /*******************************************************************
4508 reads or writes a structure.
4509 ********************************************************************/
4511 bool samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4512 prs_struct *ps, int depth)
4517 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4523 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4525 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4531 /*******************************************************************
4532 reads or writes a structure.
4533 ********************************************************************/
4535 bool samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4536 prs_struct *ps, int depth)
4541 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4547 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4553 /*******************************************************************
4554 inits a SAMR_Q_DEL_ALIASMEM structure.
4555 ********************************************************************/
4557 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4560 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4562 q_u->alias_pol = *hnd;
4563 init_dom_sid2(&q_u->sid, sid);
4566 /*******************************************************************
4567 reads or writes a structure.
4568 ********************************************************************/
4570 bool samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4571 prs_struct *ps, int depth)
4576 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4582 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4584 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4590 /*******************************************************************
4591 reads or writes a structure.
4592 ********************************************************************/
4594 bool samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4595 prs_struct *ps, int depth)
4600 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4606 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4612 /*******************************************************************
4613 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4614 ********************************************************************/
4616 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4619 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4621 q_c->alias_pol = *hnd;
4624 /*******************************************************************
4625 reads or writes a structure.
4626 ********************************************************************/
4628 bool samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4629 prs_struct *ps, int depth)
4634 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4640 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4646 /*******************************************************************
4647 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4648 ********************************************************************/
4650 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4653 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4655 r_u->status = status;
4658 /*******************************************************************
4659 reads or writes a structure.
4660 ********************************************************************/
4662 bool samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4663 prs_struct *ps, int depth)
4668 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4674 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4677 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4683 /*******************************************************************
4684 inits a SAMR_Q_QUERY_ALIASMEM structure.
4685 ********************************************************************/
4687 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4690 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4692 q_c->alias_pol = *hnd;
4695 /*******************************************************************
4696 reads or writes a structure.
4697 ********************************************************************/
4699 bool samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4700 prs_struct *ps, int depth)
4705 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4711 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4717 /*******************************************************************
4718 inits a SAMR_R_QUERY_ALIASMEM structure.
4719 ********************************************************************/
4721 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4722 uint32 num_sids, DOM_SID2 * sid,
4725 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4727 if (NT_STATUS_IS_OK(status)) {
4728 r_u->num_sids = num_sids;
4729 r_u->ptr = (num_sids != 0) ? 1 : 0;
4730 r_u->num_sids1 = num_sids;
4738 r_u->status = status;
4741 /*******************************************************************
4742 reads or writes a structure.
4743 ********************************************************************/
4745 bool samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4746 prs_struct *ps, int depth)
4753 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4759 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4761 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4764 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4765 uint32 *ptr_sid = NULL;
4767 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4770 /* We must always use talloc here even when marshalling. */
4771 if (r_u->num_sids1) {
4772 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4780 for (i = 0; i < r_u->num_sids1; i++) {
4782 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4786 if (UNMARSHALLING(ps)) {
4787 if (r_u->num_sids1) {
4788 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4797 for (i = 0; i < r_u->num_sids1; i++) {
4798 if (ptr_sid[i] != 0) {
4799 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4807 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4813 /*******************************************************************
4814 inits a SAMR_Q_LOOKUP_NAMES structure.
4815 ********************************************************************/
4817 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4818 POLICY_HND *pol, uint32 flags,
4819 uint32 num_names, const char **name)
4823 DEBUG(5, ("init_samr_q_lookup_names\n"));
4827 q_u->num_names1 = num_names;
4830 q_u->num_names2 = num_names;
4833 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4834 return NT_STATUS_NO_MEMORY;
4836 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4837 return NT_STATUS_NO_MEMORY;
4839 q_u->hdr_name = NULL;
4840 q_u->uni_name = NULL;
4843 for (i = 0; i < num_names; i++) {
4844 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4845 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4848 return NT_STATUS_OK;
4851 /*******************************************************************
4852 reads or writes a structure.
4853 ********************************************************************/
4855 bool samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4856 prs_struct *ps, int depth)
4863 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4866 if (UNMARSHALLING(ps))
4872 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4875 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4877 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4879 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4881 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4884 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4885 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4886 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4887 if (!q_u->hdr_name || !q_u->uni_name)
4891 for (i = 0; i < q_u->num_names2; i++) {
4892 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4896 for (i = 0; i < q_u->num_names2; i++) {
4897 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4904 /*******************************************************************
4905 inits a SAMR_R_LOOKUP_NAMES structure.
4906 ********************************************************************/
4908 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4910 uint32 *rid, enum lsa_SidType *type,
4913 DEBUG(5, ("init_samr_r_lookup_names\n"));
4915 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4918 r_u->num_types1 = num_rids;
4920 r_u->num_types2 = num_rids;
4922 r_u->num_rids1 = num_rids;
4924 r_u->num_rids2 = num_rids;
4926 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4927 return NT_STATUS_NO_MEMORY;
4928 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4929 return NT_STATUS_NO_MEMORY;
4931 for (i = 0; i < num_rids; i++) {
4932 r_u->rids[i] = rid[i];
4933 r_u->types[i] = type[i];
4937 r_u->num_types1 = 0;
4939 r_u->num_types2 = 0;
4949 r_u->status = status;
4951 return NT_STATUS_OK;
4954 /*******************************************************************
4955 reads or writes a structure.
4956 ********************************************************************/
4958 bool samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4959 prs_struct *ps, int depth)
4967 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4970 if (UNMARSHALLING(ps))
4976 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4978 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4981 if (r_u->ptr_rids != 0) {
4982 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4985 if (r_u->num_rids2 != r_u->num_rids1) {
4990 if (UNMARSHALLING(ps) && r_u->num_rids2) {
4991 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4994 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4999 for (i = 0; i < r_u->num_rids2; i++) {
5000 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
5001 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
5006 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
5008 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
5011 if (r_u->ptr_types != 0) {
5012 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
5015 if (r_u->num_types2 != r_u->num_types1) {
5020 if (UNMARSHALLING(ps) && r_u->num_types2) {
5021 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
5024 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
5029 for (i = 0; i < r_u->num_types2; i++) {
5030 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
5031 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
5036 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5042 /*******************************************************************
5043 inits a SAMR_Q_DELETE_DOM_USER structure.
5044 ********************************************************************/
5046 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
5049 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
5051 q_c->user_pol = *hnd;
5054 /*******************************************************************
5055 reads or writes a structure.
5056 ********************************************************************/
5058 bool samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
5059 prs_struct *ps, int depth)
5064 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
5070 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
5076 /*******************************************************************
5077 reads or writes a structure.
5078 ********************************************************************/
5080 bool samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
5081 prs_struct *ps, int depth)
5086 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
5092 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
5094 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5100 /*******************************************************************
5101 reads or writes a structure.
5102 ********************************************************************/
5104 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
5106 uint32 access_mask, uint32 rid)
5108 DEBUG(5, ("samr_init_samr_q_open_user\n"));
5110 q_u->domain_pol = *pol;
5111 q_u->access_mask = access_mask;
5112 q_u->user_rid = rid;
5115 /*******************************************************************
5116 reads or writes a structure.
5117 ********************************************************************/
5119 bool samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
5120 prs_struct *ps, int depth)
5125 prs_debug(ps, depth, desc, "samr_io_q_open_user");
5131 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5134 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5136 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
5142 /*******************************************************************
5143 reads or writes a structure.
5144 ********************************************************************/
5146 bool samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
5147 prs_struct *ps, int depth)
5152 prs_debug(ps, depth, desc, "samr_io_r_open_user");
5158 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5161 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5168 /*******************************************************************
5169 reads or writes a structure.
5170 ********************************************************************/
5172 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5175 uint32 acb_info, uint32 access_mask)
5177 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5179 q_u->domain_pol = *pol;
5181 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5182 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5184 q_u->acb_info = acb_info;
5185 q_u->access_mask = access_mask;
5188 /*******************************************************************
5189 reads or writes a structure.
5190 ********************************************************************/
5192 bool samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5193 prs_struct *ps, int depth)
5198 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5204 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5207 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5209 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5214 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5216 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5222 /*******************************************************************
5223 reads or writes a structure.
5224 ********************************************************************/
5226 bool samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5227 prs_struct *ps, int depth)
5232 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5238 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5241 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5243 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5245 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5251 /*******************************************************************
5252 inits a SAMR_Q_QUERY_USERINFO structure.
5253 ********************************************************************/
5255 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5256 const POLICY_HND *hnd, uint16 switch_value)
5258 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5261 q_u->switch_value = switch_value;
5264 /*******************************************************************
5265 reads or writes a structure.
5266 ********************************************************************/
5268 bool samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5269 prs_struct *ps, int depth)
5274 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5280 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5283 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5289 /*******************************************************************
5290 reads or writes a LOGON_HRS structure.
5291 ********************************************************************/
5293 static bool sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5294 prs_struct *ps, int depth)
5299 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5305 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5308 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5311 if(!prs_uint32("len ", ps, depth, &hrs->len))
5314 if (hrs->len > sizeof(hrs->hours)) {
5315 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5316 hrs->len = sizeof(hrs->hours);
5319 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5325 /*******************************************************************
5326 inits a SAM_USER_INFO_18 structure.
5327 ********************************************************************/
5329 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5330 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5332 DEBUG(5, ("init_sam_user_info18\n"));
5334 usr->lm_pwd_active =
5335 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5336 usr->nt_pwd_active =
5337 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5340 /*******************************************************************
5341 reads or writes a structure.
5342 ********************************************************************/
5344 static bool sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5345 prs_struct *ps, int depth)
5350 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5356 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5358 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5361 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5363 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5369 /*******************************************************************
5370 inits a SAM_USER_INFO_7 structure.
5371 ********************************************************************/
5373 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5375 DEBUG(5, ("init_sam_user_info7\n"));
5377 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5378 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5382 /*******************************************************************
5383 reads or writes a structure.
5384 ********************************************************************/
5386 static bool sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5387 prs_struct *ps, int depth)
5392 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5398 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5401 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5407 /*******************************************************************
5408 inits a SAM_USER_INFO_9 structure.
5409 ********************************************************************/
5411 void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
5413 DEBUG(5, ("init_sam_user_info9\n"));
5415 usr->rid_group = rid_group;
5418 /*******************************************************************
5419 reads or writes a structure.
5420 ********************************************************************/
5422 static bool sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
5423 prs_struct *ps, int depth)
5428 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
5434 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5440 /*******************************************************************
5441 inits a SAM_USER_INFO_16 structure.
5442 ********************************************************************/
5444 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5446 DEBUG(5, ("init_sam_user_info16\n"));
5448 usr->acb_info = acb_info;
5451 /*******************************************************************
5452 reads or writes a structure.
5453 ********************************************************************/
5455 static bool sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5456 prs_struct *ps, int depth)
5461 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5467 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5473 /*******************************************************************
5474 inits a SAM_USER_INFO_17 structure.
5475 ********************************************************************/
5477 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5480 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5482 DEBUG(5, ("init_sam_user_info17\n"));
5484 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5485 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5487 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5489 usr->ptr_1 = 1; /* pointer */
5490 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5491 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5493 usr->ptr_2 = 1; /* pointer */
5494 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5496 usr->ptr_3 = 1; /* pointer */
5497 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5499 usr->rid_user = rid_user;
5500 usr->rid_group = rid_group;
5502 usr->acct_ctrl = acct_ctrl;
5503 usr->unknown_3 = 0x0000;
5505 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5506 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5508 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5509 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5511 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5512 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5515 /*******************************************************************
5516 reads or writes a structure.
5517 ********************************************************************/
5519 static bool sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5520 prs_struct *ps, int depth)
5525 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5531 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5534 if(!smb_io_time("time", &usr->expiry, ps, depth))
5537 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5540 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5543 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5546 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5548 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5551 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5554 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5556 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5559 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5561 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5564 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5566 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5568 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5570 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5572 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5574 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5577 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5580 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5583 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5589 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5595 /*************************************************************************
5597 *************************************************************************/
5599 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516],
5602 DEBUG(10, ("init_sam_user_info24:\n"));
5603 memcpy(usr->pass, newpass, sizeof(usr->pass));
5604 usr->pw_len = pw_len;
5607 /*******************************************************************
5608 reads or writes a structure.
5609 ********************************************************************/
5611 static bool sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5612 prs_struct *ps, int depth)
5617 prs_debug(ps, depth, desc, "sam_io_user_info24");
5623 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5627 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5628 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5630 } else if (UNMARSHALLING(ps)) {
5631 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5638 /*******************************************************************
5639 reads or writes a structure.
5640 ********************************************************************/
5642 static bool sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
5643 prs_struct *ps, int depth)
5648 prs_debug(ps, depth, desc, "sam_io_user_info26");
5654 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5658 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5665 /*************************************************************************
5666 init_sam_user_info23
5668 unknown_6 = 0x0000 04ec
5670 *************************************************************************/
5672 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5673 NTTIME * logoff_time, /* all zeros */
5674 NTTIME * kickoff_time, /* all zeros */
5675 NTTIME * pass_last_set_time, /* all zeros */
5676 NTTIME * pass_can_change_time, /* all zeros */
5677 NTTIME * pass_must_change_time, /* all zeros */
5688 uint32 user_rid, /* 0x0000 0000 */
5691 uint32 fields_present,
5694 uint16 bad_password_count,
5698 usr->logon_time = *logon_time; /* all zeros */
5699 usr->logoff_time = *logoff_time; /* all zeros */
5700 usr->kickoff_time = *kickoff_time; /* all zeros */
5701 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5702 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5703 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5705 ZERO_STRUCT(usr->nt_pwd);
5706 ZERO_STRUCT(usr->lm_pwd);
5708 usr->user_rid = user_rid; /* 0x0000 0000 */
5709 usr->group_rid = group_rid;
5710 usr->acb_info = acb_info;
5711 usr->fields_present = fields_present; /* 09f8 27fa */
5713 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5714 usr->ptr_logon_hrs = hrs ? 1 : 0;
5716 if (nt_time_is_zero(pass_must_change_time)) {
5717 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5719 usr->passmustchange=0;
5722 ZERO_STRUCT(usr->padding1);
5723 ZERO_STRUCT(usr->padding2);
5725 usr->bad_password_count = bad_password_count;
5726 usr->logon_count = logon_count;
5728 memcpy(usr->pass, newpass, sizeof(usr->pass));
5730 copy_unistr2(&usr->uni_user_name, user_name);
5731 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5733 copy_unistr2(&usr->uni_full_name, full_name);
5734 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5736 copy_unistr2(&usr->uni_home_dir, home_dir);
5737 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5739 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5740 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5742 copy_unistr2(&usr->uni_logon_script, log_scr);
5743 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5745 copy_unistr2(&usr->uni_profile_path, prof_path);
5746 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5748 copy_unistr2(&usr->uni_acct_desc, desc);
5749 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5751 copy_unistr2(&usr->uni_workstations, wkstas);
5752 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5754 copy_unistr2(&usr->uni_comment, unk_str);
5755 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5757 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5758 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5761 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5763 ZERO_STRUCT(usr->logon_hrs);
5767 /*************************************************************************
5768 init_sam_user_info23
5770 unknown_6 = 0x0000 04ec
5772 *************************************************************************/
5774 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5775 NTTIME * logoff_time, /* all zeros */
5776 NTTIME * kickoff_time, /* all zeros */
5777 NTTIME * pass_last_set_time, /* all zeros */
5778 NTTIME * pass_can_change_time, /* all zeros */
5779 NTTIME * pass_must_change_time, /* all zeros */
5780 char *user_name, /* NULL */
5782 char *home_dir, char *dir_drive, char *log_scr,
5783 char *prof_path, const char *desc, char *wkstas,
5784 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5785 uint32 group_rid, uint32 acb_info,
5786 uint32 fields_present, uint16 logon_divs,
5787 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5790 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5792 usr->logon_time = *logon_time; /* all zeros */
5793 usr->logoff_time = *logoff_time; /* all zeros */
5794 usr->kickoff_time = *kickoff_time; /* all zeros */
5795 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5796 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5797 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5799 ZERO_STRUCT(usr->nt_pwd);
5800 ZERO_STRUCT(usr->lm_pwd);
5802 usr->user_rid = user_rid; /* 0x0000 0000 */
5803 usr->group_rid = group_rid;
5804 usr->acb_info = acb_info;
5805 usr->fields_present = fields_present; /* 09f8 27fa */
5807 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5808 usr->ptr_logon_hrs = hrs ? 1 : 0;
5810 if (nt_time_is_zero(pass_must_change_time)) {
5811 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5813 usr->passmustchange=0;
5816 ZERO_STRUCT(usr->padding1);
5817 ZERO_STRUCT(usr->padding2);
5819 usr->bad_password_count = bad_password_count;
5820 usr->logon_count = logon_count;
5822 memcpy(usr->pass, newpass, sizeof(usr->pass));
5824 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5825 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5827 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5828 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5830 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5831 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5833 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5834 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5836 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5837 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5839 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5840 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5842 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5843 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5845 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5846 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5848 init_unistr2(&usr->uni_comment, unk_str, UNI_FLAGS_NONE);
5849 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5851 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5852 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5854 data_blob_free(&blob);
5857 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5859 ZERO_STRUCT(usr->logon_hrs);
5864 /*************************************************************************
5865 init_samr_user_info25P
5866 fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | ACCT_FLAGS
5867 *************************************************************************/
5869 void init_sam_user_info25P(SAM_USER_INFO_25 * usr,
5870 uint32 fields_present, uint32 acb_info,
5873 usr->fields_present = fields_present;
5874 ZERO_STRUCT(usr->padding1);
5875 ZERO_STRUCT(usr->padding2);
5877 usr->acb_info = acb_info;
5878 memcpy(usr->pass, newpass, sizeof(usr->pass));
5882 /*******************************************************************
5883 reads or writes a structure.
5884 ********************************************************************/
5886 static bool sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5887 prs_struct *ps, int depth)
5892 prs_debug(ps, depth, desc, "sam_io_user_info23");
5898 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5900 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5902 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5904 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5906 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5908 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5911 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5913 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5915 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5917 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5919 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5921 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5923 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5925 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5927 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
5929 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5932 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5934 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5937 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5939 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5941 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5944 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5946 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5950 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5953 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5955 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5958 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5960 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5962 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5966 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5969 /* here begins pointed-to data */
5971 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5974 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5977 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5980 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5983 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5986 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5989 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5992 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5995 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
5998 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6001 /* ok, this is only guess-work (as usual) */
6002 if (usr->ptr_logon_hrs) {
6003 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6010 /*******************************************************************
6011 reads or writes a structure.
6012 NB. This structure is *definately* incorrect. It's my best guess
6013 currently for W2K SP2. The password field is encrypted in a different
6014 way than normal... And there are definately other problems. JRA.
6015 ********************************************************************/
6017 static bool sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
6022 prs_debug(ps, depth, desc, "sam_io_user_info25");
6028 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6030 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6032 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6034 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
6036 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
6038 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6041 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6043 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6045 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6047 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6049 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6051 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6053 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6055 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6057 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6059 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6062 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6064 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6067 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6069 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6071 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6073 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6076 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6080 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6083 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6085 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6088 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6090 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6092 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6096 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6099 /* here begins pointed-to data */
6101 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6104 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6107 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6110 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6113 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6116 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6119 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6122 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6125 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
6128 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6131 /* ok, this is only guess-work (as usual) */
6132 if (usr->ptr_logon_hrs) {
6133 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6141 /*************************************************************************
6142 init_sam_user_info21W
6144 unknown_6 = 0x0000 04ec
6146 *************************************************************************/
6148 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
6149 NTTIME * logon_time,
6150 NTTIME * logoff_time,
6151 NTTIME * kickoff_time,
6152 NTTIME * pass_last_set_time,
6153 NTTIME * pass_can_change_time,
6154 NTTIME * pass_must_change_time,
6170 uint32 fields_present,
6173 uint16 bad_password_count,
6176 usr->logon_time = *logon_time;
6177 usr->logoff_time = *logoff_time;
6178 usr->kickoff_time = *kickoff_time;
6179 usr->pass_last_set_time = *pass_last_set_time;
6180 usr->pass_can_change_time = *pass_can_change_time;
6181 usr->pass_must_change_time = *pass_must_change_time;
6183 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
6184 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
6186 usr->user_rid = user_rid;
6187 usr->group_rid = group_rid;
6188 usr->acb_info = acb_info;
6189 usr->fields_present = fields_present; /* 0x00ff ffff */
6191 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
6192 usr->ptr_logon_hrs = hrs ? 1 : 0;
6193 usr->bad_password_count = bad_password_count;
6194 usr->logon_count = logon_count;
6196 if (nt_time_is_zero(pass_must_change_time)) {
6197 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6199 usr->passmustchange=0;
6202 ZERO_STRUCT(usr->padding1);
6203 ZERO_STRUCT(usr->padding2);
6205 copy_unistr2(&usr->uni_user_name, user_name);
6206 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6208 copy_unistr2(&usr->uni_full_name, full_name);
6209 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6211 copy_unistr2(&usr->uni_home_dir, home_dir);
6212 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6214 copy_unistr2(&usr->uni_dir_drive, dir_drive);
6215 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6217 copy_unistr2(&usr->uni_logon_script, log_scr);
6218 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6220 copy_unistr2(&usr->uni_profile_path, prof_path);
6221 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6223 copy_unistr2(&usr->uni_acct_desc, desc);
6224 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6226 copy_unistr2(&usr->uni_workstations, wkstas);
6227 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6229 copy_unistr2(&usr->uni_comment, unk_str);
6230 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6232 copy_unistr2(&usr->uni_munged_dial, mung_dial);
6233 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6236 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
6238 ZERO_STRUCT(usr->logon_hrs);
6242 /*************************************************************************
6243 init_sam_user_info21
6245 unknown_6 = 0x0000 04ec
6247 *************************************************************************/
6249 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
6251 NTTIME logon_time, logoff_time, kickoff_time,
6252 pass_last_set_time, pass_can_change_time,
6253 pass_must_change_time;
6255 time_t must_change_time;
6256 const char* user_name = pdb_get_username(pw);
6257 const char* full_name = pdb_get_fullname(pw);
6258 const char* home_dir = pdb_get_homedir(pw);
6259 const char* dir_drive = pdb_get_dir_drive(pw);
6260 const char* logon_script = pdb_get_logon_script(pw);
6261 const char* profile_path = pdb_get_profile_path(pw);
6262 const char* description = pdb_get_acct_desc(pw);
6263 const char* workstations = pdb_get_workstations(pw);
6264 const char* munged_dial = pdb_get_munged_dial(pw);
6265 DATA_BLOB munged_dial_blob;
6268 const DOM_SID *user_sid;
6271 const DOM_SID *group_sid;
6274 munged_dial_blob = base64_decode_data_blob(munged_dial);
6276 munged_dial_blob = data_blob_null;
6279 /* Create NTTIME structs */
6280 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6281 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6282 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6283 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6284 unix_to_nt_time (&pass_can_change_time,pdb_get_pass_can_change_time(pw));
6285 must_change_time = pdb_get_pass_must_change_time(pw);
6286 if (must_change_time == get_time_t_max())
6287 unix_to_nt_time_abs(&pass_must_change_time, must_change_time);
6289 unix_to_nt_time(&pass_must_change_time, must_change_time);
6291 /* structure assignment */
6292 usr->logon_time = logon_time;
6293 usr->logoff_time = logoff_time;
6294 usr->kickoff_time = kickoff_time;
6295 usr->pass_last_set_time = pass_last_set_time;
6296 usr->pass_can_change_time = pass_can_change_time;
6297 usr->pass_must_change_time = pass_must_change_time;
6299 ZERO_STRUCT(usr->nt_pwd);
6300 ZERO_STRUCT(usr->lm_pwd);
6302 user_sid = pdb_get_user_sid(pw);
6304 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6305 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6306 "the domain sid %s. Failing operation.\n",
6307 user_name, sid_string_dbg(user_sid),
6308 sid_string_dbg(domain_sid)));
6309 data_blob_free(&munged_dial_blob);
6310 return NT_STATUS_UNSUCCESSFUL;
6314 group_sid = pdb_get_group_sid(pw);
6317 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6318 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6319 "which conflicts with the domain sid %s. Failing operation.\n",
6320 user_name, sid_string_dbg(group_sid),
6321 sid_string_dbg(domain_sid)));
6322 data_blob_free(&munged_dial_blob);
6323 return NT_STATUS_UNSUCCESSFUL;
6326 usr->user_rid = user_rid;
6327 usr->group_rid = group_rid;
6328 usr->acb_info = pdb_get_acct_ctrl(pw);
6331 Look at a user on a real NT4 PDC with usrmgr, press
6332 'ok'. Then you will see that fields_present is set to
6333 0x08f827fa. Look at the user immediately after that again,
6334 and you will see that 0x00fffff is returned. This solves
6335 the problem that you get access denied after having looked
6339 usr->fields_present = pdb_build_fields_present(pw);
6341 usr->logon_divs = pdb_get_logon_divs(pw);
6342 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6343 usr->bad_password_count = pdb_get_bad_password_count(pw);
6344 usr->logon_count = pdb_get_logon_count(pw);
6346 if (pdb_get_pass_must_change_time(pw) == 0) {
6347 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6349 usr->passmustchange=0;
6352 ZERO_STRUCT(usr->padding1);
6353 ZERO_STRUCT(usr->padding2);
6355 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6356 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6358 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6359 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6361 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6362 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6364 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6365 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6367 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6368 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6370 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6371 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6373 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6374 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6376 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6377 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6379 init_unistr2(&usr->uni_comment, NULL, UNI_STR_TERMINATE);
6380 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6382 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6383 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6384 data_blob_free(&munged_dial_blob);
6386 if (pdb_get_hours(pw)) {
6387 usr->logon_hrs.max_len = 1260;
6388 usr->logon_hrs.offset = 0;
6389 usr->logon_hrs.len = pdb_get_hours_len(pw);
6390 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6392 usr->logon_hrs.max_len = 1260;
6393 usr->logon_hrs.offset = 0;
6394 usr->logon_hrs.len = 0;
6395 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6398 return NT_STATUS_OK;
6401 /*******************************************************************
6402 reads or writes a structure.
6403 ********************************************************************/
6405 static bool sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6406 prs_struct *ps, int depth)
6411 prs_debug(ps, depth, desc, "sam_io_user_info21");
6417 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6419 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6421 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6423 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6425 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6427 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6430 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6432 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6434 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6436 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6438 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6440 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6442 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6444 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6446 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6448 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6451 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6453 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6456 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6458 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6460 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6463 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6465 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6469 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6472 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6474 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6477 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6479 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6481 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6484 /* here begins pointed-to data */
6486 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth))
6488 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth))
6490 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth))
6492 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth))
6494 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth))
6496 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth))
6498 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth))
6500 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth))
6502 if(!smb_io_unistr2("uni_comment", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth))
6504 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth))
6507 /* ok, this is only guess-work (as usual) */
6508 if (usr->ptr_logon_hrs) {
6509 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6516 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
6518 const char *munged_dial = pdb_get_munged_dial(pw);
6522 blob = base64_decode_data_blob(munged_dial);
6524 blob = data_blob_null;
6527 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6528 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6529 data_blob_free(&blob);
6532 /*******************************************************************
6533 reads or writes a structure.
6534 ********************************************************************/
6536 static bool sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6537 prs_struct *ps, int depth)
6542 prs_debug(ps, depth, desc, "sam_io_user_info20");
6548 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6551 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6557 /*******************************************************************
6558 inits a SAM_USERINFO_CTR structure.
6559 ********************************************************************/
6561 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6562 uint16 switch_value,
6563 SAM_USER_INFO_21 * usr)
6565 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6567 ctr->switch_value = switch_value;
6568 ctr->info.id = NULL;
6570 switch (switch_value) {
6572 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6573 if (ctr->info.id16 == NULL)
6574 return NT_STATUS_NO_MEMORY;
6576 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6579 /* whoops - got this wrong. i think. or don't understand what's happening. */
6583 info = (void *)&id11;
6585 expire.low = 0xffffffff;
6586 expire.high = 0x7fffffff;
6588 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6589 init_sam_user_info11(ctr->info.id17, &expire,
6590 "BROOKFIELDS$", /* name */
6591 0x03ef, /* user rid */
6592 0x201, /* group rid */
6593 0x0080); /* acb info */
6599 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6600 if (ctr->info.id18 == NULL)
6601 return NT_STATUS_NO_MEMORY;
6603 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6607 SAM_USER_INFO_21 *cusr;
6608 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6609 ctr->info.id21 = cusr;
6610 if (ctr->info.id21 == NULL)
6611 return NT_STATUS_NO_MEMORY;
6612 memcpy(cusr, usr, sizeof(*usr));
6613 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6614 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6618 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6619 return NT_STATUS_INVALID_INFO_CLASS;
6622 return NT_STATUS_OK;
6625 /*******************************************************************
6626 inits a SAM_USERINFO_CTR structure.
6627 ********************************************************************/
6629 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6630 uint16 switch_value, void *info)
6632 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6634 ctr->switch_value = switch_value;
6635 ctr->info.id = info;
6637 switch (switch_value) {
6639 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6640 dump_data(100, sess_key->data, sess_key->length);
6641 dump_data(100, ctr->info.id24->pass, 516);
6644 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6645 dump_data(100, sess_key->data, sess_key->length);
6646 dump_data(100, ctr->info.id23->pass, 516);
6651 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6655 /*******************************************************************
6656 reads or writes a structure.
6657 ********************************************************************/
6659 static bool samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6660 prs_struct *ps, int depth)
6663 SAM_USERINFO_CTR *ctr;
6665 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6668 if (UNMARSHALLING(ps)) {
6669 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6677 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6679 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6686 switch (ctr->switch_value) {
6688 if (UNMARSHALLING(ps))
6689 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6690 if (ctr->info.id7 == NULL) {
6691 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6694 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6697 if (UNMARSHALLING(ps))
6698 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
6699 if (ctr->info.id9 == NULL) {
6700 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6703 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
6706 if (UNMARSHALLING(ps))
6707 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6708 if (ctr->info.id16 == NULL) {
6709 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6712 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6715 if (UNMARSHALLING(ps))
6716 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6718 if (ctr->info.id17 == NULL) {
6719 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6722 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6725 if (UNMARSHALLING(ps))
6726 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6728 if (ctr->info.id18 == NULL) {
6729 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6732 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6735 if (UNMARSHALLING(ps))
6736 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6738 if (ctr->info.id20 == NULL) {
6739 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6742 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6745 if (UNMARSHALLING(ps))
6746 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6748 if (ctr->info.id21 == NULL) {
6749 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6752 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6755 if (UNMARSHALLING(ps))
6756 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6758 if (ctr->info.id23 == NULL) {
6759 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6762 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6765 if (UNMARSHALLING(ps))
6766 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6768 if (ctr->info.id24 == NULL) {
6769 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6772 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6775 if (UNMARSHALLING(ps))
6776 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6778 if (ctr->info.id25 == NULL) {
6779 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6782 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6785 if (UNMARSHALLING(ps))
6786 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6788 if (ctr->info.id26 == NULL) {
6789 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6792 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6795 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6803 /*******************************************************************
6804 inits a SAMR_R_QUERY_USERINFO structure.
6805 ********************************************************************/
6807 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6808 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6810 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6815 if (NT_STATUS_IS_OK(status)) {
6820 r_u->status = status; /* return status */
6823 /*******************************************************************
6824 reads or writes a structure.
6825 ********************************************************************/
6827 bool samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6828 prs_struct *ps, int depth)
6833 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6839 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6842 if (r_u->ptr != 0) {
6843 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6849 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6855 /*******************************************************************
6856 inits a SAMR_Q_SET_USERINFO structure.
6857 ********************************************************************/
6859 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6860 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6861 uint16 switch_value, void *info)
6863 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6866 q_u->switch_value = switch_value;
6867 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6870 /*******************************************************************
6871 reads or writes a structure.
6872 ********************************************************************/
6874 bool samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6875 prs_struct *ps, int depth)
6880 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6886 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6888 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6890 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6896 /*******************************************************************
6897 inits a SAMR_R_SET_USERINFO structure.
6898 ********************************************************************/
6900 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6902 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6904 r_u->status = status; /* return status */
6907 /*******************************************************************
6908 reads or writes a structure.
6909 ********************************************************************/
6911 bool samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6912 prs_struct *ps, int depth)
6917 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6923 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6929 /*******************************************************************
6930 inits a SAMR_Q_SET_USERINFO2 structure.
6931 ********************************************************************/
6933 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6934 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6935 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6937 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6940 q_u->switch_value = switch_value;
6943 q_u->ctr->switch_value = switch_value;
6945 switch (switch_value) {
6947 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
6948 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
6949 dump_data(100, sess_key->data, sess_key->length);
6950 dump_data(100, ctr->info.id18->lm_pwd, 16);
6951 dump_data(100, ctr->info.id18->nt_pwd, 16);
6956 /*******************************************************************
6957 reads or writes a structure.
6958 ********************************************************************/
6960 bool samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6961 prs_struct *ps, int depth)
6966 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6972 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6975 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6977 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6983 /*******************************************************************
6984 inits a SAMR_R_SET_USERINFO2 structure.
6985 ********************************************************************/
6987 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6989 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6991 r_u->status = status; /* return status */
6994 /*******************************************************************
6995 reads or writes a structure.
6996 ********************************************************************/
6998 bool samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6999 prs_struct *ps, int depth)
7004 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
7010 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7016 /*******************************************************************
7017 inits a SAMR_Q_CONNECT structure.
7018 ********************************************************************/
7020 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
7021 char *srv_name, uint32 access_mask)
7023 DEBUG(5, ("init_samr_q_connect\n"));
7025 /* make PDC server name \\server */
7026 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7027 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7029 /* example values: 0x0000 0002 */
7030 q_u->access_mask = access_mask;
7033 /*******************************************************************
7034 reads or writes a structure.
7035 ********************************************************************/
7037 bool samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
7038 prs_struct *ps, int depth)
7043 prs_debug(ps, depth, desc, "samr_io_q_connect");
7049 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7051 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7056 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7062 /*******************************************************************
7063 reads or writes a structure.
7064 ********************************************************************/
7066 bool samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
7067 prs_struct *ps, int depth)
7072 prs_debug(ps, depth, desc, "samr_io_r_connect");
7078 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7081 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7087 /*******************************************************************
7088 inits a SAMR_Q_CONNECT4 structure.
7089 ********************************************************************/
7091 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
7092 char *srv_name, uint32 access_mask)
7094 DEBUG(5, ("init_samr_q_connect4\n"));
7096 /* make PDC server name \\server */
7097 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7098 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7100 /* Only value we've seen, possibly an address type ? */
7103 /* example values: 0x0000 0002 */
7104 q_u->access_mask = access_mask;
7107 /*******************************************************************
7108 reads or writes a structure.
7109 ********************************************************************/
7111 bool samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
7112 prs_struct *ps, int depth)
7117 prs_debug(ps, depth, desc, "samr_io_q_connect4");
7123 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7125 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7130 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
7132 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7138 /*******************************************************************
7139 reads or writes a structure.
7140 ********************************************************************/
7142 bool samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
7143 prs_struct *ps, int depth)
7148 prs_debug(ps, depth, desc, "samr_io_r_connect4");
7154 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7157 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7163 /*******************************************************************
7164 inits a SAMR_Q_CONNECT5 structure.
7165 ********************************************************************/
7167 void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
7168 char *srv_name, uint32 access_mask)
7170 DEBUG(5, ("init_samr_q_connect5\n"));
7172 /* make PDC server name \\server */
7173 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7174 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7176 /* example values: 0x0000 0002 */
7177 q_u->access_mask = access_mask;
7180 q_u->info1_unk1 = 3;
7181 q_u->info1_unk2 = 0;
7184 /*******************************************************************
7185 inits a SAMR_R_CONNECT5 structure.
7186 ********************************************************************/
7188 void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
7190 DEBUG(5, ("init_samr_q_connect5\n"));
7193 r_u->info1_unk1 = 3;
7194 r_u->info1_unk2 = 0;
7196 r_u->connect_pol = *pol;
7197 r_u->status = status;
7200 /*******************************************************************
7201 reads or writes a structure.
7202 ********************************************************************/
7204 bool samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
7205 prs_struct *ps, int depth)
7210 prs_debug(ps, depth, desc, "samr_io_q_connect5");
7216 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7218 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7223 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7226 if(!prs_uint32("level", ps, depth, &q_u->level))
7228 if(!prs_uint32("level", ps, depth, &q_u->level))
7231 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
7233 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
7239 /*******************************************************************
7240 reads or writes a structure.
7241 ********************************************************************/
7243 bool samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
7244 prs_struct *ps, int depth)
7249 prs_debug(ps, depth, desc, "samr_io_r_connect5");
7255 if(!prs_uint32("level", ps, depth, &r_u->level))
7257 if(!prs_uint32("level", ps, depth, &r_u->level))
7259 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
7261 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
7264 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7267 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7273 /*******************************************************************
7274 inits a SAMR_Q_CONNECT_ANON structure.
7275 ********************************************************************/
7277 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
7279 DEBUG(5, ("init_samr_q_connect_anon\n"));
7282 q_u->unknown_0 = 0x5c; /* server name (?!!) */
7283 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
7286 /*******************************************************************
7287 reads or writes a structure.
7288 ********************************************************************/
7290 bool samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
7291 prs_struct *ps, int depth)
7296 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
7302 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
7305 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
7310 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7316 /*******************************************************************
7317 reads or writes a structure.
7318 ********************************************************************/
7320 bool samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
7321 prs_struct *ps, int depth)
7326 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
7332 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7335 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7341 /*******************************************************************
7342 inits a SAMR_Q_GET_DOM_PWINFO structure.
7343 ********************************************************************/
7345 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
7348 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7351 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
7352 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
7355 /*******************************************************************
7356 reads or writes a structure.
7357 ********************************************************************/
7359 bool samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
7360 prs_struct *ps, int depth)
7365 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
7371 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
7373 if (q_u->ptr != 0) {
7374 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7376 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7383 /*******************************************************************
7384 reads or writes a structure.
7385 ********************************************************************/
7387 bool samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7388 prs_struct *ps, int depth)
7393 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7399 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
7403 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
7406 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7412 /*******************************************************************
7413 make a SAMR_ENC_PASSWD structure.
7414 ********************************************************************/
7416 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7424 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7428 /*******************************************************************
7429 reads or writes a SAMR_ENC_PASSWD structure.
7430 ********************************************************************/
7432 bool samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7433 prs_struct *ps, int depth)
7438 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7444 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7447 if (pwd->ptr != 0) {
7448 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7455 /*******************************************************************
7456 inits a SAMR_ENC_HASH structure.
7457 ********************************************************************/
7459 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7467 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7471 /*******************************************************************
7472 reads or writes a SAMR_ENC_HASH structure.
7473 ********************************************************************/
7475 bool samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7476 prs_struct *ps, int depth)
7481 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7487 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7489 if (hsh->ptr != 0) {
7490 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7497 /*******************************************************************
7498 inits a SAMR_Q_CHGPASSWD_USER structure.
7499 ********************************************************************/
7501 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7502 const char *dest_host, const char *user_name,
7503 const uchar nt_newpass[516],
7504 const uchar nt_oldhash[16],
7505 const uchar lm_newpass[516],
7506 const uchar lm_oldhash[16])
7508 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7511 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7512 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7514 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7515 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7517 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7518 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7520 q_u->unknown = 0x01;
7522 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7523 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7526 /*******************************************************************
7527 reads or writes a structure.
7528 ********************************************************************/
7530 bool samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7531 prs_struct *ps, int depth)
7536 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7542 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7545 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7547 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7552 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7554 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7557 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7559 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7562 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7565 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7567 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7573 /*******************************************************************
7574 inits a SAMR_R_CHGPASSWD_USER structure.
7575 ********************************************************************/
7577 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7579 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7581 r_u->status = status;
7584 /*******************************************************************
7585 reads or writes a structure.
7586 ********************************************************************/
7588 bool samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7589 prs_struct *ps, int depth)
7594 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7600 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7606 /*******************************************************************
7607 inits a SAMR_Q_CHGPASSWD3 structure.
7608 ********************************************************************/
7610 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
7611 const char *dest_host, const char *user_name,
7612 const uchar nt_newpass[516],
7613 const uchar nt_oldhash[16],
7614 const uchar lm_newpass[516],
7615 const uchar lm_oldhash[16])
7617 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7620 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7621 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7623 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7624 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7626 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7627 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7629 q_u->lm_change = 0x01;
7631 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7632 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7634 init_enc_passwd(&q_u->password3, NULL);
7637 /*******************************************************************
7638 reads or writes a structure.
7639 ********************************************************************/
7641 bool samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
7642 prs_struct *ps, int depth)
7647 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
7653 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7656 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7658 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7663 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7665 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7668 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7670 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7673 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
7676 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7678 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7681 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
7687 /*******************************************************************
7688 inits a SAMR_R_CHGPASSWD_USER3 structure.
7689 ********************************************************************/
7691 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
7692 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
7694 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7696 r_u->status = status;
7700 r_u->ptr_reject = 0;
7706 if (reject && (reject->reject_reason != Undefined)) {
7707 r_u->reject = reject;
7708 r_u->ptr_reject = 1;
7712 /*******************************************************************
7713 Reads or writes an SAMR_CHANGE_REJECT structure.
7714 ********************************************************************/
7716 bool samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
7721 prs_debug(ps, depth, desc, "samr_io_change_reject");
7727 if(UNMARSHALLING(ps))
7728 ZERO_STRUCTP(reject);
7730 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
7733 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
7736 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
7742 /*******************************************************************
7743 reads or writes a structure.
7744 ********************************************************************/
7746 bool samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
7747 prs_struct *ps, int depth)
7752 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
7758 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
7761 /* special case: Windows 2000 can return stub data here saying
7762 NT_STATUS_NOT_SUPPORTED */
7764 if ( NT_STATUS_EQUAL( NT_STATUS_NOT_SUPPORTED, NT_STATUS(r_u->ptr_info)) ) {
7765 r_u->status = NT_STATUS_NOT_SUPPORTED;
7769 if (r_u->ptr_info && r_u->info != NULL) {
7770 /* SAM_UNK_INFO_1 */
7771 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
7775 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
7778 if (r_u->ptr_reject && r_u->reject != NULL) {
7779 /* SAMR_CHANGE_REJECT */
7780 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
7784 if (!prs_ntstatus("status", ps, depth, &r_u->status))
7790 /*******************************************************************
7791 reads or writes a structure.
7792 ********************************************************************/
7794 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7795 POLICY_HND *domain_pol, uint16 switch_value)
7797 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7799 q_u->domain_pol = *domain_pol;
7800 q_u->switch_value = switch_value;
7803 /*******************************************************************
7804 reads or writes a structure.
7805 ********************************************************************/
7807 bool samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7808 prs_struct *ps, int depth)
7813 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7819 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7822 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7828 /*******************************************************************
7829 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7830 ********************************************************************/
7832 void init_samr_r_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7833 uint16 switch_value, SAM_UNK_CTR * ctr,
7836 DEBUG(5, ("init_samr_r_query_domain_info2\n"));
7839 r_u->switch_value = 0;
7840 r_u->status = status; /* return status */
7842 if (NT_STATUS_IS_OK(status)) {
7843 r_u->switch_value = switch_value;
7849 /*******************************************************************
7850 reads or writes a structure.
7851 ********************************************************************/
7853 bool samr_io_r_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7854 prs_struct *ps, int depth)
7859 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info2");
7865 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7868 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7869 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7874 switch (r_u->switch_value) {
7876 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
7880 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7884 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
7888 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
7892 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7896 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7900 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7904 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
7908 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7912 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7916 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7920 DEBUG(0, ("samr_io_r_query_domain_info2: unknown switch level 0x%x\n",
7921 r_u->switch_value));
7922 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7930 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7937 /*******************************************************************
7938 reads or writes a structure.
7939 ********************************************************************/
7941 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7942 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7944 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7946 q_u->domain_pol = *domain_pol;
7947 q_u->switch_value0 = switch_value;
7949 q_u->switch_value = switch_value;
7954 /*******************************************************************
7955 reads or writes a structure.
7956 ********************************************************************/
7958 bool samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7959 prs_struct *ps, int depth)
7964 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7970 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7973 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7976 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7982 if (UNMARSHALLING(ps)) {
7983 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7987 switch (q_u->switch_value) {
7990 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7994 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7998 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
8002 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
8006 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
8010 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
8014 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
8018 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
8019 q_u->switch_value));
8026 /*******************************************************************
8027 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
8028 ********************************************************************/
8030 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
8032 DEBUG(5, ("init_samr_r_set_domain_info\n"));
8034 r_u->status = status; /* return status */
8037 /*******************************************************************
8038 reads or writes a structure.
8039 ********************************************************************/
8041 bool samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
8042 prs_struct *ps, int depth)
8047 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
8053 if(!prs_ntstatus("status", ps, depth, &r_u->status))