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_GET_DISPENUM_INDEX structure.
2176 ********************************************************************/
2178 void init_samr_q_get_dispenum_index(SAMR_Q_GET_DISPENUM_INDEX * q_e, POLICY_HND *pol,
2179 uint16 switch_level, const char *name)
2181 DEBUG(5, ("init_samr_q_get_dispenum_index\n"));
2183 q_e->domain_pol = *pol;
2185 q_e->switch_level = switch_level;
2187 init_lsa_string(&q_e->name, name);
2190 /*******************************************************************
2191 reads or writes a structure.
2192 ********************************************************************/
2194 BOOL samr_io_q_get_dispenum_index(const char *desc, SAMR_Q_GET_DISPENUM_INDEX * q_e,
2195 prs_struct *ps, int depth)
2200 prs_debug(ps, depth, desc, "samr_io_q_get_dispenum_index");
2206 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
2209 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2212 if (!smb_io_lsa_string("name", &q_e->name, ps, depth))
2218 /*******************************************************************
2219 reads or writes a structure.
2220 ********************************************************************/
2222 BOOL samr_io_r_get_dispenum_index(const char *desc, SAMR_R_GET_DISPENUM_INDEX * r_u,
2223 prs_struct *ps, int depth)
2228 prs_debug(ps, depth, desc, "samr_io_r_get_dispenum_index");
2234 if(!prs_uint32("idx", ps, depth, &r_u->idx))
2237 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2244 /*******************************************************************
2245 inits a SAMR_Q_OPEN_GROUP structure.
2246 ********************************************************************/
2248 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2250 uint32 access_mask, uint32 rid)
2252 DEBUG(5, ("init_samr_q_open_group\n"));
2254 q_c->domain_pol = *hnd;
2255 q_c->access_mask = access_mask;
2256 q_c->rid_group = rid;
2259 /*******************************************************************
2260 reads or writes a structure.
2261 ********************************************************************/
2263 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2264 prs_struct *ps, int depth)
2269 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2275 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2278 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2280 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2286 /*******************************************************************
2287 reads or writes a structure.
2288 ********************************************************************/
2290 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2291 prs_struct *ps, int depth)
2296 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2302 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2305 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2311 /*******************************************************************
2312 inits a GROUP_INFO1 structure.
2313 ********************************************************************/
2315 void init_samr_group_info1(GROUP_INFO1 * gr1,
2316 char *acct_name, char *acct_desc,
2319 DEBUG(5, ("init_samr_group_info1\n"));
2321 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2322 gr1->num_members = num_members;
2324 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2325 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2326 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2327 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2330 /*******************************************************************
2331 reads or writes a structure.
2332 ********************************************************************/
2334 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2335 prs_struct *ps, int depth)
2342 prs_debug(ps, depth, desc, "samr_io_group_info1");
2345 if(!prs_uint16("level", ps, depth, &dummy))
2351 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2354 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2356 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2359 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2362 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2363 gr1->hdr_acct_name.buffer, ps, depth))
2366 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2367 gr1->hdr_acct_desc.buffer, ps, depth))
2373 /*******************************************************************
2374 inits a GROUP_INFO2 structure.
2375 ********************************************************************/
2377 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2379 DEBUG(5, ("init_samr_group_info2\n"));
2382 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2383 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2386 /*******************************************************************
2387 reads or writes a structure.
2388 ********************************************************************/
2390 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2395 prs_debug(ps, depth, desc, "samr_io_group_info2");
2398 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2401 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2403 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2404 gr2->hdr_acct_name.buffer, ps, depth))
2410 /*******************************************************************
2411 inits a GROUP_INFO3 structure.
2412 ********************************************************************/
2414 void init_samr_group_info3(GROUP_INFO3 *gr3)
2416 DEBUG(5, ("init_samr_group_info3\n"));
2418 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2421 /*******************************************************************
2422 reads or writes a structure.
2423 ********************************************************************/
2425 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2430 prs_debug(ps, depth, desc, "samr_io_group_info3");
2436 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2442 /*******************************************************************
2443 inits a GROUP_INFO4 structure.
2444 ********************************************************************/
2446 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2448 DEBUG(5, ("init_samr_group_info4\n"));
2451 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2452 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2455 /*******************************************************************
2456 reads or writes a structure.
2457 ********************************************************************/
2459 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2460 prs_struct *ps, int depth)
2465 prs_debug(ps, depth, desc, "samr_io_group_info4");
2468 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2470 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2472 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2473 gr4->hdr_acct_desc.buffer, ps, depth))
2479 /*******************************************************************
2480 inits a GROUP_INFO5 structure.
2481 ********************************************************************/
2483 void init_samr_group_info5(GROUP_INFO5 * gr5,
2484 char *acct_name, char *acct_desc,
2487 DEBUG(5, ("init_samr_group_info5\n"));
2489 gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2490 gr5->num_members = num_members;
2492 init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2493 init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
2494 init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2495 init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
2498 /*******************************************************************
2499 reads or writes a structure.
2500 ********************************************************************/
2502 BOOL samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
2503 prs_struct *ps, int depth)
2510 prs_debug(ps, depth, desc, "samr_io_group_info5");
2513 if(!prs_uint16("level", ps, depth, &dummy))
2519 if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
2522 if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
2524 if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
2527 if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
2530 if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
2531 gr5->hdr_acct_name.buffer, ps, depth))
2534 if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
2535 gr5->hdr_acct_desc.buffer, ps, depth))
2542 /*******************************************************************
2543 reads or writes a structure.
2544 ********************************************************************/
2546 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2547 prs_struct *ps, int depth)
2549 if (UNMARSHALLING(ps))
2550 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2555 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2558 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2561 switch ((*ctr)->switch_value1) {
2563 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2567 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2571 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2575 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2579 if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
2583 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2590 /*******************************************************************
2591 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2592 ********************************************************************/
2594 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2595 POLICY_HND *pol, const char *acct_desc,
2598 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2602 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2603 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2605 q_e->access_mask = access_mask;
2608 /*******************************************************************
2609 reads or writes a structure.
2610 ********************************************************************/
2612 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2613 prs_struct *ps, int depth)
2618 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2624 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2627 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2629 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2630 q_e->hdr_acct_desc.buffer, ps, depth))
2635 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2641 /*******************************************************************
2642 reads or writes a structure.
2643 ********************************************************************/
2645 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2646 prs_struct *ps, int depth)
2651 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2657 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2660 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2662 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2668 /*******************************************************************
2669 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2670 ********************************************************************/
2672 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2675 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2677 q_c->group_pol = *hnd;
2680 /*******************************************************************
2681 reads or writes a structure.
2682 ********************************************************************/
2684 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2685 prs_struct *ps, int depth)
2690 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2696 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2702 /*******************************************************************
2703 reads or writes a structure.
2704 ********************************************************************/
2706 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2707 prs_struct *ps, int depth)
2712 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2718 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2721 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2727 /*******************************************************************
2728 inits a SAMR_Q_DEL_GROUPMEM structure.
2729 ********************************************************************/
2731 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2732 POLICY_HND *pol, uint32 rid)
2734 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2740 /*******************************************************************
2741 reads or writes a structure.
2742 ********************************************************************/
2744 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2745 prs_struct *ps, int depth)
2750 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2756 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2759 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2765 /*******************************************************************
2766 inits a SAMR_R_DEL_GROUPMEM structure.
2767 ********************************************************************/
2769 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2772 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2774 r_u->status = status;
2777 /*******************************************************************
2778 reads or writes a structure.
2779 ********************************************************************/
2781 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2782 prs_struct *ps, int depth)
2787 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2793 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2799 /*******************************************************************
2800 inits a SAMR_Q_ADD_GROUPMEM structure.
2801 ********************************************************************/
2803 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2804 POLICY_HND *pol, uint32 rid)
2806 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2810 q_e->unknown = 0x0005;
2813 /*******************************************************************
2814 reads or writes a structure.
2815 ********************************************************************/
2817 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2818 prs_struct *ps, int depth)
2823 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2829 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2832 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2834 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2840 /*******************************************************************
2841 inits a SAMR_R_ADD_GROUPMEM structure.
2842 ********************************************************************/
2844 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2847 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2849 r_u->status = status;
2852 /*******************************************************************
2853 reads or writes a structure.
2854 ********************************************************************/
2856 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2857 prs_struct *ps, int depth)
2862 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2868 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2874 /*******************************************************************
2875 inits a SAMR_Q_SET_GROUPINFO structure.
2876 ********************************************************************/
2878 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2879 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2881 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2887 /*******************************************************************
2888 reads or writes a structure.
2889 ********************************************************************/
2891 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2892 prs_struct *ps, int depth)
2897 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2903 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2906 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2912 /*******************************************************************
2913 inits a SAMR_R_SET_GROUPINFO structure.
2914 ********************************************************************/
2916 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2918 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2920 r_u->status = status;
2923 /*******************************************************************
2924 reads or writes a structure.
2925 ********************************************************************/
2927 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2928 prs_struct *ps, int depth)
2933 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2939 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2945 /*******************************************************************
2946 inits a SAMR_Q_QUERY_GROUPINFO structure.
2947 ********************************************************************/
2949 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2950 POLICY_HND *pol, uint16 switch_level)
2952 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2956 q_e->switch_level = switch_level;
2959 /*******************************************************************
2960 reads or writes a structure.
2961 ********************************************************************/
2963 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2964 prs_struct *ps, int depth)
2969 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2975 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2978 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2984 /*******************************************************************
2985 inits a SAMR_R_QUERY_GROUPINFO structure.
2986 ********************************************************************/
2988 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2989 GROUP_INFO_CTR * ctr, NTSTATUS status)
2991 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2993 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2995 r_u->status = status;
2998 /*******************************************************************
2999 reads or writes a structure.
3000 ********************************************************************/
3002 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
3003 prs_struct *ps, int depth)
3008 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
3014 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3017 if (r_u->ptr != 0) {
3018 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
3024 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3030 /*******************************************************************
3031 inits a SAMR_Q_QUERY_GROUPMEM structure.
3032 ********************************************************************/
3034 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
3036 DEBUG(5, ("init_samr_q_query_groupmem\n"));
3038 q_c->group_pol = *hnd;
3041 /*******************************************************************
3042 reads or writes a structure.
3043 ********************************************************************/
3045 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
3046 prs_struct *ps, int depth)
3051 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
3057 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
3063 /*******************************************************************
3064 inits a SAMR_R_QUERY_GROUPMEM structure.
3065 ********************************************************************/
3067 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
3068 uint32 num_entries, uint32 *rid,
3069 uint32 *attr, NTSTATUS status)
3071 DEBUG(5, ("init_samr_r_query_groupmem\n"));
3073 if (NT_STATUS_IS_OK(status)) {
3075 r_u->num_entries = num_entries;
3077 r_u->ptr_attrs = attr != NULL ? 1 : 0;
3078 r_u->ptr_rids = rid != NULL ? 1 : 0;
3080 r_u->num_rids = num_entries;
3083 r_u->num_attrs = num_entries;
3087 r_u->num_entries = 0;
3090 r_u->status = status;
3093 /*******************************************************************
3094 reads or writes a structure.
3095 ********************************************************************/
3097 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
3098 prs_struct *ps, int depth)
3105 if (UNMARSHALLING(ps))
3108 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
3114 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3116 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3119 if (r_u->ptr != 0) {
3120 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
3122 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
3125 if (r_u->ptr_rids != 0) {
3126 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
3128 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
3129 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
3130 if (r_u->rid == NULL)
3134 for (i = 0; i < r_u->num_rids; i++) {
3135 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
3140 if (r_u->ptr_attrs != 0) {
3141 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
3144 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
3145 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
3146 if (r_u->attr == NULL)
3150 for (i = 0; i < r_u->num_attrs; i++) {
3151 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
3157 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3163 /*******************************************************************
3164 inits a SAMR_Q_QUERY_USERGROUPS structure.
3165 ********************************************************************/
3167 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
3170 DEBUG(5, ("init_samr_q_query_usergroups\n"));
3175 /*******************************************************************
3176 reads or writes a structure.
3177 ********************************************************************/
3179 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
3180 prs_struct *ps, int depth)
3185 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
3191 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3197 /*******************************************************************
3198 inits a SAMR_R_QUERY_USERGROUPS structure.
3199 ********************************************************************/
3201 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3202 uint32 num_gids, DOM_GID * gid,
3205 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3207 if (NT_STATUS_IS_OK(status)) {
3209 r_u->num_entries = num_gids;
3210 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3211 r_u->num_entries2 = num_gids;
3216 r_u->num_entries = 0;
3221 r_u->status = status;
3224 /*******************************************************************
3225 reads or writes a structure.
3226 ********************************************************************/
3228 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3229 prs_struct *ps, int depth)
3235 prs_debug(ps, depth, desc, "samr_io_gids");
3241 if(!prs_uint32("num_gids", ps, depth, num_gids))
3244 if ((*num_gids) != 0) {
3245 if (UNMARSHALLING(ps)) {
3246 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3249 if ((*gid) == NULL) {
3253 for (i = 0; i < (*num_gids); i++) {
3254 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3262 /*******************************************************************
3263 reads or writes a structure.
3264 ********************************************************************/
3266 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3267 prs_struct *ps, int depth)
3272 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3278 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3281 if (r_u->ptr_0 != 0) {
3282 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3284 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3287 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3288 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3295 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3301 /*******************************************************************
3302 inits a SAMR_Q_ENUM_DOMAINS structure.
3303 ********************************************************************/
3305 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3307 uint32 start_idx, uint32 size)
3309 DEBUG(5, ("init_samr_q_enum_domains\n"));
3313 q_e->start_idx = start_idx;
3314 q_e->max_size = size;
3317 /*******************************************************************
3318 reads or writes a structure.
3319 ********************************************************************/
3321 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3322 prs_struct *ps, int depth)
3327 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3333 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3336 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3338 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3344 /*******************************************************************
3345 inits a SAMR_R_ENUM_DOMAINS structure.
3346 ********************************************************************/
3348 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3349 uint32 next_idx, uint32 num_sam_entries)
3351 DEBUG(5, ("init_samr_r_enum_domains\n"));
3353 r_u->next_idx = next_idx;
3355 if (num_sam_entries != 0) {
3356 r_u->ptr_entries1 = 1;
3357 r_u->ptr_entries2 = 1;
3358 r_u->num_entries2 = num_sam_entries;
3359 r_u->num_entries3 = num_sam_entries;
3361 r_u->num_entries4 = num_sam_entries;
3363 r_u->ptr_entries1 = 0;
3364 r_u->num_entries2 = num_sam_entries;
3365 r_u->ptr_entries2 = 1;
3369 /*******************************************************************
3370 reads or writes a structure.
3371 ********************************************************************/
3373 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3374 prs_struct *ps, int depth)
3381 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3387 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3389 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3392 if (r_u->ptr_entries1 != 0) {
3393 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3395 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3397 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3400 if (UNMARSHALLING(ps) && r_u->num_entries2) {
3401 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3402 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3405 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3406 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3407 r_u->num_entries4 = 0;
3408 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3412 for (i = 0; i < r_u->num_entries2; i++) {
3414 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3415 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3419 for (i = 0; i < r_u->num_entries2; i++) {
3421 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3422 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3423 r_u->sam[i].hdr_name.buffer, ps,
3432 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3434 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3440 /*******************************************************************
3441 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3442 ********************************************************************/
3444 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3446 uint32 start_idx, uint32 size)
3448 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3452 q_e->start_idx = start_idx;
3453 q_e->max_size = size;
3456 /*******************************************************************
3457 reads or writes a structure.
3458 ********************************************************************/
3460 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3461 prs_struct *ps, int depth)
3466 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3472 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3475 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3477 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3483 /*******************************************************************
3484 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3485 ********************************************************************/
3487 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3488 uint32 next_idx, uint32 num_sam_entries)
3490 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3492 r_u->next_idx = next_idx;
3494 if (num_sam_entries != 0) {
3495 r_u->ptr_entries1 = 1;
3496 r_u->ptr_entries2 = 1;
3497 r_u->num_entries2 = num_sam_entries;
3498 r_u->num_entries3 = num_sam_entries;
3500 r_u->num_entries4 = num_sam_entries;
3502 r_u->ptr_entries1 = 0;
3503 r_u->num_entries2 = num_sam_entries;
3504 r_u->ptr_entries2 = 1;
3508 /*******************************************************************
3509 reads or writes a structure.
3510 ********************************************************************/
3512 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3513 prs_struct *ps, int depth)
3520 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3526 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3528 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3531 if (r_u->ptr_entries1 != 0) {
3532 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3534 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3536 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3539 if (UNMARSHALLING(ps) && r_u->num_entries2) {
3540 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3541 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3544 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3546 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3547 r_u->num_entries4 = 0;
3548 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3552 for (i = 0; i < r_u->num_entries2; i++) {
3553 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3557 for (i = 0; i < r_u->num_entries2; i++) {
3558 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3559 r_u->sam[i].hdr_name.buffer, ps, depth))
3566 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3568 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3574 /*******************************************************************
3575 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3576 ********************************************************************/
3578 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3579 POLICY_HND *pol, uint32 start_idx,
3582 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3586 q_e->start_idx = start_idx;
3587 q_e->max_size = size;
3591 /*******************************************************************
3592 reads or writes a structure.
3593 ********************************************************************/
3595 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3596 prs_struct *ps, int depth)
3601 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3607 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3610 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3612 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3618 /*******************************************************************
3619 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3620 ********************************************************************/
3622 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3624 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3626 r_u->next_idx = next_idx;
3628 if (num_sam_entries != 0) {
3629 r_u->ptr_entries1 = 1;
3630 r_u->ptr_entries2 = 1;
3631 r_u->num_entries2 = num_sam_entries;
3632 r_u->num_entries3 = num_sam_entries;
3634 r_u->num_entries4 = num_sam_entries;
3636 r_u->ptr_entries1 = 0;
3637 r_u->num_entries2 = num_sam_entries;
3638 r_u->ptr_entries2 = 1;
3642 /*******************************************************************
3643 reads or writes a structure.
3644 ********************************************************************/
3646 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3647 prs_struct *ps, int depth)
3654 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3660 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3662 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3665 if (r_u->ptr_entries1 != 0) {
3666 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3668 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3670 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3673 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3674 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3675 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3678 if (r_u->num_entries2 != 0 &&
3679 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3680 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3681 r_u->num_entries4 = 0;
3682 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3686 for (i = 0; i < r_u->num_entries2; i++) {
3687 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3691 for (i = 0; i < r_u->num_entries2; i++) {
3692 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3693 r_u->sam[i].hdr_name.buffer, ps,
3701 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3703 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3709 /*******************************************************************
3710 inits a ALIAS_INFO1 structure.
3711 ********************************************************************/
3713 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3715 DEBUG(5, ("init_samr_alias_info1\n"));
3717 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3718 al1->num_member = num_member;
3719 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3722 /*******************************************************************
3723 reads or writes a structure.
3724 ********************************************************************/
3726 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3727 prs_struct *ps, int depth)
3732 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3738 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3740 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3742 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3745 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3747 if ( !prs_align(ps) )
3749 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3751 if ( !prs_align(ps) )
3757 /*******************************************************************
3758 inits a ALIAS_INFO3 structure.
3759 ********************************************************************/
3761 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3763 DEBUG(5, ("init_samr_alias_info3\n"));
3765 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3768 /*******************************************************************
3769 reads or writes a structure.
3770 ********************************************************************/
3772 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3773 prs_struct *ps, int depth)
3778 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3784 if (!prs_unistr4("description", ps, depth, &al3->description))
3790 /*******************************************************************
3791 reads or writes a structure.
3792 ********************************************************************/
3794 BOOL samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
3795 prs_struct *ps, int depth)
3800 prs_debug(ps, depth, desc, "samr_io_alias_info2");
3806 if (!prs_unistr4("name", ps, depth, &al2->name))
3812 /*******************************************************************
3813 reads or writes a structure.
3814 ********************************************************************/
3816 BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3821 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3824 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3829 switch (ctr->level) {
3831 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3835 if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
3839 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3843 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3850 /*******************************************************************
3851 inits a SAMR_Q_QUERY_ALIASINFO structure.
3852 ********************************************************************/
3854 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3855 POLICY_HND *pol, uint32 switch_level)
3857 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3860 q_e->level = switch_level;
3863 /*******************************************************************
3864 reads or writes a structure.
3865 ********************************************************************/
3867 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3868 prs_struct *ps, int depth)
3873 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3879 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3882 if ( !prs_uint16("level", ps, depth, &in->level) )
3888 /*******************************************************************
3889 inits a SAMR_R_QUERY_ALIASINFO structure.
3890 ********************************************************************/
3892 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3893 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3895 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3898 out->status = status;
3901 /*******************************************************************
3902 reads or writes a structure.
3903 ********************************************************************/
3905 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3906 prs_struct *ps, int depth)
3911 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3917 if ( !prs_pointer("alias", ps, depth, (void*)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3922 if(!prs_ntstatus("status", ps, depth, &out->status))
3928 /*******************************************************************
3929 inits a SAMR_Q_SET_ALIASINFO structure.
3930 ********************************************************************/
3932 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3933 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3935 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3937 q_u->alias_pol = *hnd;
3941 /*******************************************************************
3942 reads or writes a structure.
3943 ********************************************************************/
3945 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3946 prs_struct *ps, int depth)
3951 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3957 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3959 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3965 /*******************************************************************
3966 reads or writes a structure.
3967 ********************************************************************/
3969 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3970 prs_struct *ps, int depth)
3975 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3980 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3986 /*******************************************************************
3987 inits a SAMR_Q_QUERY_USERALIASES structure.
3988 ********************************************************************/
3990 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3993 uint32 *ptr_sid, DOM_SID2 * sid)
3995 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3999 q_u->num_sids1 = num_sids;
4001 q_u->num_sids2 = num_sids;
4003 q_u->ptr_sid = ptr_sid;
4007 /*******************************************************************
4008 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
4009 ********************************************************************/
4011 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
4012 prs_struct *ps, int depth)
4020 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
4026 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4029 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
4031 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4037 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
4040 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
4041 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
4042 if (q_u->ptr_sid == NULL)
4045 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
4046 if (q_u->sid == NULL)
4050 for (i = 0; i < q_u->num_sids2; i++) {
4051 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
4052 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
4056 for (i = 0; i < q_u->num_sids2; i++) {
4057 if (q_u->ptr_sid[i] != 0) {
4058 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
4059 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
4067 /*******************************************************************
4068 inits a SAMR_R_QUERY_USERALIASES structure.
4069 ********************************************************************/
4071 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
4072 uint32 num_rids, uint32 *rid,
4075 DEBUG(5, ("init_samr_r_query_useraliases\n"));
4077 if (NT_STATUS_IS_OK(status)) {
4078 r_u->num_entries = num_rids;
4080 r_u->num_entries2 = num_rids;
4084 r_u->num_entries = 0;
4086 r_u->num_entries2 = 0;
4089 r_u->status = status;
4092 /*******************************************************************
4093 reads or writes a structure.
4094 ********************************************************************/
4096 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
4097 prs_struct *ps, int depth)
4104 prs_debug(ps, depth, desc, "samr_io_rids");
4110 if(!prs_uint32("num_rids", ps, depth, num_rids))
4113 if ((*num_rids) != 0) {
4114 if (UNMARSHALLING(ps)) {
4116 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
4121 for (i = 0; i < (*num_rids); i++) {
4122 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
4123 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
4131 /*******************************************************************
4132 reads or writes a structure.
4133 ********************************************************************/
4135 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
4136 prs_struct *ps, int depth)
4141 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
4147 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
4149 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
4152 if (r_u->ptr != 0) {
4153 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
4159 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4165 /*******************************************************************
4166 inits a SAMR_Q_OPEN_ALIAS structure.
4167 ********************************************************************/
4169 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
4170 uint32 access_mask, uint32 rid)
4172 DEBUG(5, ("init_samr_q_open_alias\n"));
4174 q_u->dom_pol = *pol;
4175 q_u->access_mask = access_mask;
4176 q_u->rid_alias = rid;
4179 /*******************************************************************
4180 reads or writes a structure.
4181 ********************************************************************/
4183 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
4184 prs_struct *ps, int depth)
4189 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
4195 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
4198 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4200 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
4206 /*******************************************************************
4207 reads or writes a structure.
4208 ********************************************************************/
4210 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4211 prs_struct *ps, int depth)
4216 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4222 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4225 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4231 /*******************************************************************
4232 inits a SAMR_Q_LOOKUP_RIDS structure.
4233 ********************************************************************/
4235 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4236 POLICY_HND *pol, uint32 flags,
4237 uint32 num_rids, uint32 *rid)
4239 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4243 q_u->num_rids1 = num_rids;
4246 q_u->num_rids2 = num_rids;
4248 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4252 if (q_u->rid == NULL) {
4256 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4260 /*******************************************************************
4261 reads or writes a structure.
4262 ********************************************************************/
4264 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4265 prs_struct *ps, int depth)
4273 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4276 if (UNMARSHALLING(ps))
4282 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4285 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4287 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4289 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4291 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4294 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4295 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4296 if (q_u->rid == NULL)
4300 for (i = 0; i < q_u->num_rids2; i++) {
4301 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4302 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4309 /*******************************************************************
4310 inits a SAMR_R_LOOKUP_RIDS structure.
4311 ********************************************************************/
4313 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4314 uint32 num_names, UNIHDR * hdr_name,
4315 UNISTR2 *uni_name, uint32 *type)
4317 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4319 r_u->hdr_name = NULL;
4320 r_u->uni_name = NULL;
4323 if (num_names != 0) {
4324 r_u->num_names1 = num_names;
4326 r_u->num_names2 = num_names;
4328 r_u->num_types1 = num_names;
4330 r_u->num_types2 = num_names;
4332 r_u->hdr_name = hdr_name;
4333 r_u->uni_name = uni_name;
4336 r_u->num_names1 = num_names;
4338 r_u->num_names2 = num_names;
4340 r_u->num_types1 = num_names;
4342 r_u->num_types2 = num_names;
4346 /*******************************************************************
4347 reads or writes a structure.
4348 ********************************************************************/
4350 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4351 prs_struct *ps, int depth)
4358 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4364 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4366 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4369 if (r_u->ptr_names != 0) {
4371 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4375 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4376 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4377 if (r_u->hdr_name == NULL)
4380 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4381 if (r_u->uni_name == NULL)
4385 for (i = 0; i < r_u->num_names2; i++) {
4386 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4387 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4390 for (i = 0; i < r_u->num_names2; i++) {
4391 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4392 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4400 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4402 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4405 if (r_u->ptr_types != 0) {
4407 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4410 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4411 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4412 if (r_u->type == NULL)
4416 for (i = 0; i < r_u->num_types2; i++) {
4417 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4418 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4423 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4429 /*******************************************************************
4430 inits a SAMR_Q_OPEN_ALIAS structure.
4431 ********************************************************************/
4433 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4435 DEBUG(5, ("init_samr_q_delete_alias\n"));
4437 q_u->alias_pol = *hnd;
4440 /*******************************************************************
4441 reads or writes a structure.
4442 ********************************************************************/
4444 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4445 prs_struct *ps, int depth)
4450 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4456 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4462 /*******************************************************************
4463 reads or writes a structure.
4464 ********************************************************************/
4466 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4467 prs_struct *ps, int depth)
4472 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4478 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4480 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4486 /*******************************************************************
4487 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4488 ********************************************************************/
4490 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4491 POLICY_HND *hnd, const char *acct_desc)
4493 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4495 q_u->dom_pol = *hnd;
4497 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4498 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4500 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4503 /*******************************************************************
4504 reads or writes a structure.
4505 ********************************************************************/
4507 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4508 prs_struct *ps, int depth)
4513 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4519 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4522 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4524 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4525 q_u->hdr_acct_desc.buffer, ps, depth))
4530 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4536 /*******************************************************************
4537 reads or writes a structure.
4538 ********************************************************************/
4540 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4541 prs_struct *ps, int depth)
4546 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4552 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4555 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4558 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4564 /*******************************************************************
4565 inits a SAMR_Q_ADD_ALIASMEM structure.
4566 ********************************************************************/
4568 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4571 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4573 q_u->alias_pol = *hnd;
4574 init_dom_sid2(&q_u->sid, sid);
4577 /*******************************************************************
4578 reads or writes a structure.
4579 ********************************************************************/
4581 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4582 prs_struct *ps, int depth)
4587 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4593 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4595 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4601 /*******************************************************************
4602 reads or writes a structure.
4603 ********************************************************************/
4605 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4606 prs_struct *ps, int depth)
4611 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4617 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4623 /*******************************************************************
4624 inits a SAMR_Q_DEL_ALIASMEM structure.
4625 ********************************************************************/
4627 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4630 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4632 q_u->alias_pol = *hnd;
4633 init_dom_sid2(&q_u->sid, sid);
4636 /*******************************************************************
4637 reads or writes a structure.
4638 ********************************************************************/
4640 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4641 prs_struct *ps, int depth)
4646 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4652 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4654 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4660 /*******************************************************************
4661 reads or writes a structure.
4662 ********************************************************************/
4664 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4665 prs_struct *ps, int depth)
4670 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4676 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4682 /*******************************************************************
4683 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4684 ********************************************************************/
4686 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4689 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4691 q_c->alias_pol = *hnd;
4694 /*******************************************************************
4695 reads or writes a structure.
4696 ********************************************************************/
4698 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4699 prs_struct *ps, int depth)
4704 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4710 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4716 /*******************************************************************
4717 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4718 ********************************************************************/
4720 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4723 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4725 r_u->status = status;
4728 /*******************************************************************
4729 reads or writes a structure.
4730 ********************************************************************/
4732 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4733 prs_struct *ps, int depth)
4738 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4744 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4747 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4753 /*******************************************************************
4754 inits a SAMR_Q_QUERY_ALIASMEM structure.
4755 ********************************************************************/
4757 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4760 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4762 q_c->alias_pol = *hnd;
4765 /*******************************************************************
4766 reads or writes a structure.
4767 ********************************************************************/
4769 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4770 prs_struct *ps, int depth)
4775 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4781 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4787 /*******************************************************************
4788 inits a SAMR_R_QUERY_ALIASMEM structure.
4789 ********************************************************************/
4791 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4792 uint32 num_sids, DOM_SID2 * sid,
4795 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4797 if (NT_STATUS_IS_OK(status)) {
4798 r_u->num_sids = num_sids;
4799 r_u->ptr = (num_sids != 0) ? 1 : 0;
4800 r_u->num_sids1 = num_sids;
4808 r_u->status = status;
4811 /*******************************************************************
4812 reads or writes a structure.
4813 ********************************************************************/
4815 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4816 prs_struct *ps, int depth)
4823 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4829 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4831 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4834 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4835 uint32 *ptr_sid = NULL;
4837 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4840 /* We must always use talloc here even when marshalling. */
4841 if (r_u->num_sids1) {
4842 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4850 for (i = 0; i < r_u->num_sids1; i++) {
4852 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4856 if (UNMARSHALLING(ps)) {
4857 if (r_u->num_sids1) {
4858 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4867 for (i = 0; i < r_u->num_sids1; i++) {
4868 if (ptr_sid[i] != 0) {
4869 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4877 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4883 /*******************************************************************
4884 inits a SAMR_Q_LOOKUP_NAMES structure.
4885 ********************************************************************/
4887 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4888 POLICY_HND *pol, uint32 flags,
4889 uint32 num_names, const char **name)
4893 DEBUG(5, ("init_samr_q_lookup_names\n"));
4897 q_u->num_names1 = num_names;
4900 q_u->num_names2 = num_names;
4903 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4904 return NT_STATUS_NO_MEMORY;
4906 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4907 return NT_STATUS_NO_MEMORY;
4909 q_u->hdr_name = NULL;
4910 q_u->uni_name = NULL;
4913 for (i = 0; i < num_names; i++) {
4914 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4915 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4918 return NT_STATUS_OK;
4921 /*******************************************************************
4922 reads or writes a structure.
4923 ********************************************************************/
4925 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4926 prs_struct *ps, int depth)
4933 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4936 if (UNMARSHALLING(ps))
4942 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4945 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4947 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4949 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4951 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4954 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4955 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4956 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4957 if (!q_u->hdr_name || !q_u->uni_name)
4961 for (i = 0; i < q_u->num_names2; i++) {
4962 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4966 for (i = 0; i < q_u->num_names2; i++) {
4967 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4974 /*******************************************************************
4975 inits a SAMR_R_LOOKUP_NAMES structure.
4976 ********************************************************************/
4978 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4980 uint32 *rid, enum lsa_SidType *type,
4983 DEBUG(5, ("init_samr_r_lookup_names\n"));
4985 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4988 r_u->num_types1 = num_rids;
4990 r_u->num_types2 = num_rids;
4992 r_u->num_rids1 = num_rids;
4994 r_u->num_rids2 = num_rids;
4997 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4998 return NT_STATUS_NO_MEMORY;
4999 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
5000 return NT_STATUS_NO_MEMORY;
5006 if (!r_u->rids || !r_u->types)
5009 for (i = 0; i < num_rids; i++) {
5010 r_u->rids[i] = rid[i];
5011 r_u->types[i] = type[i];
5016 r_u->num_types1 = 0;
5018 r_u->num_types2 = 0;
5028 r_u->status = status;
5030 return NT_STATUS_OK;
5033 /*******************************************************************
5034 reads or writes a structure.
5035 ********************************************************************/
5037 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
5038 prs_struct *ps, int depth)
5046 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
5049 if (UNMARSHALLING(ps))
5055 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
5057 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
5060 if (r_u->ptr_rids != 0) {
5061 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
5064 if (r_u->num_rids2 != r_u->num_rids1) {
5069 if (UNMARSHALLING(ps) && r_u->num_rids2) {
5070 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
5073 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
5078 for (i = 0; i < r_u->num_rids2; i++) {
5079 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
5080 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
5085 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
5087 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
5090 if (r_u->ptr_types != 0) {
5091 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
5094 if (r_u->num_types2 != r_u->num_types1) {
5099 if (UNMARSHALLING(ps) && r_u->num_types2) {
5100 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
5103 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
5108 for (i = 0; i < r_u->num_types2; i++) {
5109 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
5110 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
5115 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5121 /*******************************************************************
5122 inits a SAMR_Q_DELETE_DOM_USER structure.
5123 ********************************************************************/
5125 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
5128 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
5130 q_c->user_pol = *hnd;
5133 /*******************************************************************
5134 reads or writes a structure.
5135 ********************************************************************/
5137 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
5138 prs_struct *ps, int depth)
5143 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
5149 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
5155 /*******************************************************************
5156 reads or writes a structure.
5157 ********************************************************************/
5159 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
5160 prs_struct *ps, int depth)
5165 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
5171 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
5173 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5179 /*******************************************************************
5180 reads or writes a structure.
5181 ********************************************************************/
5183 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
5185 uint32 access_mask, uint32 rid)
5187 DEBUG(5, ("samr_init_samr_q_open_user\n"));
5189 q_u->domain_pol = *pol;
5190 q_u->access_mask = access_mask;
5191 q_u->user_rid = rid;
5194 /*******************************************************************
5195 reads or writes a structure.
5196 ********************************************************************/
5198 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
5199 prs_struct *ps, int depth)
5204 prs_debug(ps, depth, desc, "samr_io_q_open_user");
5210 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5213 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5215 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
5221 /*******************************************************************
5222 reads or writes a structure.
5223 ********************************************************************/
5225 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
5226 prs_struct *ps, int depth)
5231 prs_debug(ps, depth, desc, "samr_io_r_open_user");
5237 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5240 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5247 /*******************************************************************
5248 reads or writes a structure.
5249 ********************************************************************/
5251 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5254 uint32 acb_info, uint32 access_mask)
5256 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5258 q_u->domain_pol = *pol;
5260 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5261 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5263 q_u->acb_info = acb_info;
5264 q_u->access_mask = access_mask;
5267 /*******************************************************************
5268 reads or writes a structure.
5269 ********************************************************************/
5271 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5272 prs_struct *ps, int depth)
5277 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5283 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5286 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5288 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5293 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5295 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5301 /*******************************************************************
5302 reads or writes a structure.
5303 ********************************************************************/
5305 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5306 prs_struct *ps, int depth)
5311 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5317 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5320 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5322 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5324 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5330 /*******************************************************************
5331 inits a SAMR_Q_QUERY_USERINFO structure.
5332 ********************************************************************/
5334 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5335 const POLICY_HND *hnd, uint16 switch_value)
5337 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5340 q_u->switch_value = switch_value;
5343 /*******************************************************************
5344 reads or writes a structure.
5345 ********************************************************************/
5347 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5348 prs_struct *ps, int depth)
5353 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5359 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5362 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5368 /*******************************************************************
5369 reads or writes a LOGON_HRS structure.
5370 ********************************************************************/
5372 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5373 prs_struct *ps, int depth)
5378 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5384 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5387 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5390 if(!prs_uint32("len ", ps, depth, &hrs->len))
5393 if (hrs->len > sizeof(hrs->hours)) {
5394 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5395 hrs->len = sizeof(hrs->hours);
5398 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5404 /*******************************************************************
5405 inits a SAM_USER_INFO_18 structure.
5406 ********************************************************************/
5408 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5409 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5411 DEBUG(5, ("init_sam_user_info18\n"));
5413 usr->lm_pwd_active =
5414 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5415 usr->nt_pwd_active =
5416 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5419 /*******************************************************************
5420 reads or writes a structure.
5421 ********************************************************************/
5423 static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5424 prs_struct *ps, int depth)
5429 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5435 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5437 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5440 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5442 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5448 /*******************************************************************
5449 inits a SAM_USER_INFO_7 structure.
5450 ********************************************************************/
5452 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5454 DEBUG(5, ("init_sam_user_info7\n"));
5456 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5457 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5461 /*******************************************************************
5462 reads or writes a structure.
5463 ********************************************************************/
5465 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5466 prs_struct *ps, int depth)
5471 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5477 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5480 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5486 /*******************************************************************
5487 inits a SAM_USER_INFO_9 structure.
5488 ********************************************************************/
5490 void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
5492 DEBUG(5, ("init_sam_user_info9\n"));
5494 usr->rid_group = rid_group;
5497 /*******************************************************************
5498 reads or writes a structure.
5499 ********************************************************************/
5501 static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
5502 prs_struct *ps, int depth)
5507 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
5513 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5519 /*******************************************************************
5520 inits a SAM_USER_INFO_16 structure.
5521 ********************************************************************/
5523 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5525 DEBUG(5, ("init_sam_user_info16\n"));
5527 usr->acb_info = acb_info;
5530 /*******************************************************************
5531 reads or writes a structure.
5532 ********************************************************************/
5534 static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5535 prs_struct *ps, int depth)
5540 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5546 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5552 /*******************************************************************
5553 inits a SAM_USER_INFO_17 structure.
5554 ********************************************************************/
5556 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5559 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5561 DEBUG(5, ("init_sam_user_info17\n"));
5563 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5564 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5566 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5568 usr->ptr_1 = 1; /* pointer */
5569 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5570 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5572 usr->ptr_2 = 1; /* pointer */
5573 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5575 usr->ptr_3 = 1; /* pointer */
5576 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5578 usr->rid_user = rid_user;
5579 usr->rid_group = rid_group;
5581 usr->acct_ctrl = acct_ctrl;
5582 usr->unknown_3 = 0x0000;
5584 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5585 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5587 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5588 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5590 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5591 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5594 /*******************************************************************
5595 reads or writes a structure.
5596 ********************************************************************/
5598 static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5599 prs_struct *ps, int depth)
5604 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5610 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5613 if(!smb_io_time("time", &usr->expiry, ps, depth))
5616 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5619 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5622 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5625 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5627 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5630 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5633 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5635 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5638 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5640 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5643 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5645 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5647 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5649 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5651 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5653 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5656 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5659 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5662 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5668 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5674 /*************************************************************************
5676 *************************************************************************/
5678 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516],
5681 DEBUG(10, ("init_sam_user_info24:\n"));
5682 memcpy(usr->pass, newpass, sizeof(usr->pass));
5683 usr->pw_len = pw_len;
5686 /*******************************************************************
5687 reads or writes a structure.
5688 ********************************************************************/
5690 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5691 prs_struct *ps, int depth)
5696 prs_debug(ps, depth, desc, "sam_io_user_info24");
5702 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5706 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5707 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5709 } else if (UNMARSHALLING(ps)) {
5710 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5717 /*******************************************************************
5718 reads or writes a structure.
5719 ********************************************************************/
5721 static BOOL sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
5722 prs_struct *ps, int depth)
5727 prs_debug(ps, depth, desc, "sam_io_user_info26");
5733 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5737 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5744 /*************************************************************************
5745 init_sam_user_info23
5747 unknown_6 = 0x0000 04ec
5749 *************************************************************************/
5751 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5752 NTTIME * logoff_time, /* all zeros */
5753 NTTIME * kickoff_time, /* all zeros */
5754 NTTIME * pass_last_set_time, /* all zeros */
5755 NTTIME * pass_can_change_time, /* all zeros */
5756 NTTIME * pass_must_change_time, /* all zeros */
5767 uint32 user_rid, /* 0x0000 0000 */
5770 uint32 fields_present,
5773 uint16 bad_password_count,
5777 usr->logon_time = *logon_time; /* all zeros */
5778 usr->logoff_time = *logoff_time; /* all zeros */
5779 usr->kickoff_time = *kickoff_time; /* all zeros */
5780 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5781 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5782 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5784 ZERO_STRUCT(usr->nt_pwd);
5785 ZERO_STRUCT(usr->lm_pwd);
5787 usr->user_rid = user_rid; /* 0x0000 0000 */
5788 usr->group_rid = group_rid;
5789 usr->acb_info = acb_info;
5790 usr->fields_present = fields_present; /* 09f8 27fa */
5792 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5793 usr->ptr_logon_hrs = hrs ? 1 : 0;
5795 if (nt_time_is_zero(pass_must_change_time)) {
5796 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5798 usr->passmustchange=0;
5801 ZERO_STRUCT(usr->padding1);
5802 ZERO_STRUCT(usr->padding2);
5804 usr->bad_password_count = bad_password_count;
5805 usr->logon_count = logon_count;
5807 memcpy(usr->pass, newpass, sizeof(usr->pass));
5809 copy_unistr2(&usr->uni_user_name, user_name);
5810 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5812 copy_unistr2(&usr->uni_full_name, full_name);
5813 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5815 copy_unistr2(&usr->uni_home_dir, home_dir);
5816 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5818 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5819 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5821 copy_unistr2(&usr->uni_logon_script, log_scr);
5822 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5824 copy_unistr2(&usr->uni_profile_path, prof_path);
5825 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5827 copy_unistr2(&usr->uni_acct_desc, desc);
5828 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5830 copy_unistr2(&usr->uni_workstations, wkstas);
5831 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5833 copy_unistr2(&usr->uni_comment, unk_str);
5834 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5836 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5837 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5840 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5842 ZERO_STRUCT(usr->logon_hrs);
5846 /*************************************************************************
5847 init_sam_user_info23
5849 unknown_6 = 0x0000 04ec
5851 *************************************************************************/
5853 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5854 NTTIME * logoff_time, /* all zeros */
5855 NTTIME * kickoff_time, /* all zeros */
5856 NTTIME * pass_last_set_time, /* all zeros */
5857 NTTIME * pass_can_change_time, /* all zeros */
5858 NTTIME * pass_must_change_time, /* all zeros */
5859 char *user_name, /* NULL */
5861 char *home_dir, char *dir_drive, char *log_scr,
5862 char *prof_path, const char *desc, char *wkstas,
5863 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5864 uint32 group_rid, uint32 acb_info,
5865 uint32 fields_present, uint16 logon_divs,
5866 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5869 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5871 usr->logon_time = *logon_time; /* all zeros */
5872 usr->logoff_time = *logoff_time; /* all zeros */
5873 usr->kickoff_time = *kickoff_time; /* all zeros */
5874 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5875 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5876 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5878 ZERO_STRUCT(usr->nt_pwd);
5879 ZERO_STRUCT(usr->lm_pwd);
5881 usr->user_rid = user_rid; /* 0x0000 0000 */
5882 usr->group_rid = group_rid;
5883 usr->acb_info = acb_info;
5884 usr->fields_present = fields_present; /* 09f8 27fa */
5886 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5887 usr->ptr_logon_hrs = hrs ? 1 : 0;
5889 if (nt_time_is_zero(pass_must_change_time)) {
5890 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5892 usr->passmustchange=0;
5895 ZERO_STRUCT(usr->padding1);
5896 ZERO_STRUCT(usr->padding2);
5898 usr->bad_password_count = bad_password_count;
5899 usr->logon_count = logon_count;
5901 memcpy(usr->pass, newpass, sizeof(usr->pass));
5903 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5904 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5906 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5907 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5909 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5910 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5912 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5913 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5915 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5916 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5918 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5919 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5921 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5922 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5924 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5925 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5927 init_unistr2(&usr->uni_comment, unk_str, UNI_FLAGS_NONE);
5928 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5930 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5931 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5933 data_blob_free(&blob);
5936 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5938 ZERO_STRUCT(usr->logon_hrs);
5942 /*******************************************************************
5943 reads or writes a structure.
5944 ********************************************************************/
5946 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5947 prs_struct *ps, int depth)
5952 prs_debug(ps, depth, desc, "sam_io_user_info23");
5958 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5960 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5962 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5964 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5966 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5968 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5971 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5973 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5975 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5977 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5979 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5981 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5983 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5985 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5987 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
5989 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5992 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5994 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5997 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5999 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6001 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6004 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6006 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6010 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6013 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6015 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6018 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6020 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6022 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6026 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6029 /* here begins pointed-to data */
6031 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6034 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6037 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6040 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6043 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6046 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6049 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6052 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6055 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
6058 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6061 /* ok, this is only guess-work (as usual) */
6062 if (usr->ptr_logon_hrs) {
6063 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6070 /*******************************************************************
6071 reads or writes a structure.
6072 NB. This structure is *definately* incorrect. It's my best guess
6073 currently for W2K SP2. The password field is encrypted in a different
6074 way than normal... And there are definately other problems. JRA.
6075 ********************************************************************/
6077 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
6082 prs_debug(ps, depth, desc, "sam_io_user_info25");
6088 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6090 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6092 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6094 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
6096 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
6098 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6101 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6103 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6105 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6107 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6109 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6111 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6113 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6115 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6117 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6119 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6122 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6124 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6127 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6129 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6131 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6133 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6136 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6140 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6143 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6145 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6148 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6150 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6152 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6156 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6159 /* here begins pointed-to data */
6161 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6164 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6167 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6170 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6173 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6176 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6179 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6182 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6185 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
6188 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6191 /* ok, this is only guess-work (as usual) */
6192 if (usr->ptr_logon_hrs) {
6193 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6201 /*************************************************************************
6202 init_sam_user_info21W
6204 unknown_6 = 0x0000 04ec
6206 *************************************************************************/
6208 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
6209 NTTIME * logon_time,
6210 NTTIME * logoff_time,
6211 NTTIME * kickoff_time,
6212 NTTIME * pass_last_set_time,
6213 NTTIME * pass_can_change_time,
6214 NTTIME * pass_must_change_time,
6230 uint32 fields_present,
6233 uint16 bad_password_count,
6236 usr->logon_time = *logon_time;
6237 usr->logoff_time = *logoff_time;
6238 usr->kickoff_time = *kickoff_time;
6239 usr->pass_last_set_time = *pass_last_set_time;
6240 usr->pass_can_change_time = *pass_can_change_time;
6241 usr->pass_must_change_time = *pass_must_change_time;
6243 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
6244 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
6246 usr->user_rid = user_rid;
6247 usr->group_rid = group_rid;
6248 usr->acb_info = acb_info;
6249 usr->fields_present = fields_present; /* 0x00ff ffff */
6251 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
6252 usr->ptr_logon_hrs = hrs ? 1 : 0;
6253 usr->bad_password_count = bad_password_count;
6254 usr->logon_count = logon_count;
6256 if (nt_time_is_zero(pass_must_change_time)) {
6257 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6259 usr->passmustchange=0;
6262 ZERO_STRUCT(usr->padding1);
6263 ZERO_STRUCT(usr->padding2);
6265 copy_unistr2(&usr->uni_user_name, user_name);
6266 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6268 copy_unistr2(&usr->uni_full_name, full_name);
6269 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6271 copy_unistr2(&usr->uni_home_dir, home_dir);
6272 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6274 copy_unistr2(&usr->uni_dir_drive, dir_drive);
6275 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6277 copy_unistr2(&usr->uni_logon_script, log_scr);
6278 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6280 copy_unistr2(&usr->uni_profile_path, prof_path);
6281 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6283 copy_unistr2(&usr->uni_acct_desc, desc);
6284 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6286 copy_unistr2(&usr->uni_workstations, wkstas);
6287 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6289 copy_unistr2(&usr->uni_comment, unk_str);
6290 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6292 copy_unistr2(&usr->uni_munged_dial, mung_dial);
6293 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6296 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
6298 ZERO_STRUCT(usr->logon_hrs);
6302 /*************************************************************************
6303 init_sam_user_info21
6305 unknown_6 = 0x0000 04ec
6307 *************************************************************************/
6309 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
6311 NTTIME logon_time, logoff_time, kickoff_time,
6312 pass_last_set_time, pass_can_change_time,
6313 pass_must_change_time;
6315 time_t must_change_time;
6316 const char* user_name = pdb_get_username(pw);
6317 const char* full_name = pdb_get_fullname(pw);
6318 const char* home_dir = pdb_get_homedir(pw);
6319 const char* dir_drive = pdb_get_dir_drive(pw);
6320 const char* logon_script = pdb_get_logon_script(pw);
6321 const char* profile_path = pdb_get_profile_path(pw);
6322 const char* description = pdb_get_acct_desc(pw);
6323 const char* workstations = pdb_get_workstations(pw);
6324 const char* munged_dial = pdb_get_munged_dial(pw);
6325 DATA_BLOB munged_dial_blob;
6328 const DOM_SID *user_sid;
6331 const DOM_SID *group_sid;
6334 munged_dial_blob = base64_decode_data_blob(munged_dial);
6336 munged_dial_blob = data_blob_null;
6339 /* Create NTTIME structs */
6340 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6341 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6342 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6343 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6344 unix_to_nt_time (&pass_can_change_time,pdb_get_pass_can_change_time(pw));
6345 must_change_time = pdb_get_pass_must_change_time(pw);
6346 if (must_change_time == get_time_t_max())
6347 unix_to_nt_time_abs(&pass_must_change_time, must_change_time);
6349 unix_to_nt_time(&pass_must_change_time, must_change_time);
6351 /* structure assignment */
6352 usr->logon_time = logon_time;
6353 usr->logoff_time = logoff_time;
6354 usr->kickoff_time = kickoff_time;
6355 usr->pass_last_set_time = pass_last_set_time;
6356 usr->pass_can_change_time = pass_can_change_time;
6357 usr->pass_must_change_time = pass_must_change_time;
6359 ZERO_STRUCT(usr->nt_pwd);
6360 ZERO_STRUCT(usr->lm_pwd);
6362 user_sid = pdb_get_user_sid(pw);
6364 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6365 fstring user_sid_string;
6366 fstring domain_sid_string;
6367 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6368 "the domain sid %s. Failing operation.\n",
6370 sid_to_string(user_sid_string, user_sid),
6371 sid_to_string(domain_sid_string, domain_sid)));
6372 data_blob_free(&munged_dial_blob);
6373 return NT_STATUS_UNSUCCESSFUL;
6377 group_sid = pdb_get_group_sid(pw);
6380 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6381 fstring group_sid_string;
6382 fstring domain_sid_string;
6383 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6384 "which conflicts with the domain sid %s. Failing operation.\n",
6386 sid_to_string(group_sid_string, group_sid),
6387 sid_to_string(domain_sid_string, domain_sid)));
6388 data_blob_free(&munged_dial_blob);
6389 return NT_STATUS_UNSUCCESSFUL;
6392 usr->user_rid = user_rid;
6393 usr->group_rid = group_rid;
6394 usr->acb_info = pdb_get_acct_ctrl(pw);
6397 Look at a user on a real NT4 PDC with usrmgr, press
6398 'ok'. Then you will see that fields_present is set to
6399 0x08f827fa. Look at the user immediately after that again,
6400 and you will see that 0x00fffff is returned. This solves
6401 the problem that you get access denied after having looked
6405 usr->fields_present = pdb_build_fields_present(pw);
6407 usr->logon_divs = pdb_get_logon_divs(pw);
6408 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6409 usr->bad_password_count = pdb_get_bad_password_count(pw);
6410 usr->logon_count = pdb_get_logon_count(pw);
6412 if (pdb_get_pass_must_change_time(pw) == 0) {
6413 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6415 usr->passmustchange=0;
6418 ZERO_STRUCT(usr->padding1);
6419 ZERO_STRUCT(usr->padding2);
6421 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6422 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6424 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6425 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6427 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6428 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6430 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6431 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6433 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6434 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6436 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6437 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6439 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6440 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6442 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6443 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6445 init_unistr2(&usr->uni_comment, NULL, UNI_STR_TERMINATE);
6446 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6448 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6449 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6450 data_blob_free(&munged_dial_blob);
6452 if (pdb_get_hours(pw)) {
6453 usr->logon_hrs.max_len = 1260;
6454 usr->logon_hrs.offset = 0;
6455 usr->logon_hrs.len = pdb_get_hours_len(pw);
6456 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6458 usr->logon_hrs.max_len = 1260;
6459 usr->logon_hrs.offset = 0;
6460 usr->logon_hrs.len = 0;
6461 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6464 return NT_STATUS_OK;
6467 /*******************************************************************
6468 reads or writes a structure.
6469 ********************************************************************/
6471 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6472 prs_struct *ps, int depth)
6477 prs_debug(ps, depth, desc, "sam_io_user_info21");
6483 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6485 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6487 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6489 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6491 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6493 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6496 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6498 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6500 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6502 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6504 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6506 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6508 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6510 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6512 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6514 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6517 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6519 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6522 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6524 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6526 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6529 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6531 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6535 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6538 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6540 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6543 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6545 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6547 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6550 /* here begins pointed-to data */
6552 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth))
6554 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth))
6556 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth))
6558 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth))
6560 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth))
6562 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth))
6564 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth))
6566 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth))
6568 if(!smb_io_unistr2("uni_comment", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth))
6570 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth))
6573 /* ok, this is only guess-work (as usual) */
6574 if (usr->ptr_logon_hrs) {
6575 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6582 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
6584 const char *munged_dial = pdb_get_munged_dial(pw);
6588 blob = base64_decode_data_blob(munged_dial);
6590 blob = data_blob_null;
6593 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6594 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6595 data_blob_free(&blob);
6598 /*******************************************************************
6599 reads or writes a structure.
6600 ********************************************************************/
6602 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6603 prs_struct *ps, int depth)
6608 prs_debug(ps, depth, desc, "sam_io_user_info20");
6614 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6617 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6623 /*******************************************************************
6624 inits a SAM_USERINFO_CTR structure.
6625 ********************************************************************/
6627 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6628 uint16 switch_value,
6629 SAM_USER_INFO_21 * usr)
6631 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6633 ctr->switch_value = switch_value;
6634 ctr->info.id = NULL;
6636 switch (switch_value) {
6638 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6639 if (ctr->info.id16 == NULL)
6640 return NT_STATUS_NO_MEMORY;
6642 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6645 /* whoops - got this wrong. i think. or don't understand what's happening. */
6649 info = (void *)&id11;
6651 expire.low = 0xffffffff;
6652 expire.high = 0x7fffffff;
6654 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6655 init_sam_user_info11(ctr->info.id17, &expire,
6656 "BROOKFIELDS$", /* name */
6657 0x03ef, /* user rid */
6658 0x201, /* group rid */
6659 0x0080); /* acb info */
6665 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6666 if (ctr->info.id18 == NULL)
6667 return NT_STATUS_NO_MEMORY;
6669 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6673 SAM_USER_INFO_21 *cusr;
6674 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6675 ctr->info.id21 = cusr;
6676 if (ctr->info.id21 == NULL)
6677 return NT_STATUS_NO_MEMORY;
6678 memcpy(cusr, usr, sizeof(*usr));
6679 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6680 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6684 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6685 return NT_STATUS_INVALID_INFO_CLASS;
6688 return NT_STATUS_OK;
6691 /*******************************************************************
6692 inits a SAM_USERINFO_CTR structure.
6693 ********************************************************************/
6695 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6696 uint16 switch_value, void *info)
6698 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6700 ctr->switch_value = switch_value;
6701 ctr->info.id = info;
6703 switch (switch_value) {
6705 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6706 dump_data(100, sess_key->data, sess_key->length);
6707 dump_data(100, ctr->info.id24->pass, 516);
6710 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6711 dump_data(100, sess_key->data, sess_key->length);
6712 dump_data(100, ctr->info.id23->pass, 516);
6717 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6721 /*******************************************************************
6722 reads or writes a structure.
6723 ********************************************************************/
6725 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6726 prs_struct *ps, int depth)
6729 SAM_USERINFO_CTR *ctr;
6731 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6734 if (UNMARSHALLING(ps)) {
6735 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6743 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6745 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6752 switch (ctr->switch_value) {
6754 if (UNMARSHALLING(ps))
6755 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6756 if (ctr->info.id7 == NULL) {
6757 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6760 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6763 if (UNMARSHALLING(ps))
6764 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
6765 if (ctr->info.id9 == NULL) {
6766 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6769 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
6772 if (UNMARSHALLING(ps))
6773 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6774 if (ctr->info.id16 == NULL) {
6775 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6778 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6781 if (UNMARSHALLING(ps))
6782 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6784 if (ctr->info.id17 == NULL) {
6785 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6788 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6791 if (UNMARSHALLING(ps))
6792 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6794 if (ctr->info.id18 == NULL) {
6795 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6798 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6801 if (UNMARSHALLING(ps))
6802 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6804 if (ctr->info.id20 == NULL) {
6805 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6808 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6811 if (UNMARSHALLING(ps))
6812 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6814 if (ctr->info.id21 == NULL) {
6815 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6818 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6821 if (UNMARSHALLING(ps))
6822 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6824 if (ctr->info.id23 == NULL) {
6825 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6828 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6831 if (UNMARSHALLING(ps))
6832 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6834 if (ctr->info.id24 == NULL) {
6835 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6838 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6841 if (UNMARSHALLING(ps))
6842 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6844 if (ctr->info.id25 == NULL) {
6845 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6848 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6851 if (UNMARSHALLING(ps))
6852 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6854 if (ctr->info.id26 == NULL) {
6855 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6858 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6861 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6869 /*******************************************************************
6870 inits a SAMR_R_QUERY_USERINFO structure.
6871 ********************************************************************/
6873 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6874 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6876 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6881 if (NT_STATUS_IS_OK(status)) {
6886 r_u->status = status; /* return status */
6889 /*******************************************************************
6890 reads or writes a structure.
6891 ********************************************************************/
6893 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6894 prs_struct *ps, int depth)
6899 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6905 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6908 if (r_u->ptr != 0) {
6909 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6921 /*******************************************************************
6922 inits a SAMR_Q_SET_USERINFO structure.
6923 ********************************************************************/
6925 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6926 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6927 uint16 switch_value, void *info)
6929 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6932 q_u->switch_value = switch_value;
6933 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6936 /*******************************************************************
6937 reads or writes a structure.
6938 ********************************************************************/
6940 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6941 prs_struct *ps, int depth)
6946 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6952 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6954 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6956 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6962 /*******************************************************************
6963 inits a SAMR_R_SET_USERINFO structure.
6964 ********************************************************************/
6966 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6968 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6970 r_u->status = status; /* return status */
6973 /*******************************************************************
6974 reads or writes a structure.
6975 ********************************************************************/
6977 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6978 prs_struct *ps, int depth)
6983 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6989 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6995 /*******************************************************************
6996 inits a SAMR_Q_SET_USERINFO2 structure.
6997 ********************************************************************/
6999 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
7000 const POLICY_HND *hnd, DATA_BLOB *sess_key,
7001 uint16 switch_value, SAM_USERINFO_CTR * ctr)
7003 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
7006 q_u->switch_value = switch_value;
7009 q_u->ctr->switch_value = switch_value;
7011 switch (switch_value) {
7013 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
7014 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
7015 dump_data(100, sess_key->data, sess_key->length);
7016 dump_data(100, ctr->info.id18->lm_pwd, 16);
7017 dump_data(100, ctr->info.id18->nt_pwd, 16);
7022 /*******************************************************************
7023 reads or writes a structure.
7024 ********************************************************************/
7026 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
7027 prs_struct *ps, int depth)
7032 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
7038 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
7041 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7043 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
7049 /*******************************************************************
7050 inits a SAMR_R_SET_USERINFO2 structure.
7051 ********************************************************************/
7053 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
7055 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
7057 r_u->status = status; /* return status */
7060 /*******************************************************************
7061 reads or writes a structure.
7062 ********************************************************************/
7064 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
7065 prs_struct *ps, int depth)
7070 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
7076 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7082 /*******************************************************************
7083 inits a SAMR_Q_CONNECT structure.
7084 ********************************************************************/
7086 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
7087 char *srv_name, uint32 access_mask)
7089 DEBUG(5, ("init_samr_q_connect\n"));
7091 /* make PDC server name \\server */
7092 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7093 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7095 /* example values: 0x0000 0002 */
7096 q_u->access_mask = access_mask;
7099 /*******************************************************************
7100 reads or writes a structure.
7101 ********************************************************************/
7103 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
7104 prs_struct *ps, int depth)
7109 prs_debug(ps, depth, desc, "samr_io_q_connect");
7115 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7117 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7122 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7128 /*******************************************************************
7129 reads or writes a structure.
7130 ********************************************************************/
7132 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
7133 prs_struct *ps, int depth)
7138 prs_debug(ps, depth, desc, "samr_io_r_connect");
7144 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7147 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7153 /*******************************************************************
7154 inits a SAMR_Q_CONNECT4 structure.
7155 ********************************************************************/
7157 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
7158 char *srv_name, uint32 access_mask)
7160 DEBUG(5, ("init_samr_q_connect4\n"));
7162 /* make PDC server name \\server */
7163 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7164 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7166 /* Only value we've seen, possibly an address type ? */
7169 /* example values: 0x0000 0002 */
7170 q_u->access_mask = access_mask;
7173 /*******************************************************************
7174 reads or writes a structure.
7175 ********************************************************************/
7177 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
7178 prs_struct *ps, int depth)
7183 prs_debug(ps, depth, desc, "samr_io_q_connect4");
7189 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7191 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7196 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
7198 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7204 /*******************************************************************
7205 reads or writes a structure.
7206 ********************************************************************/
7208 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
7209 prs_struct *ps, int depth)
7214 prs_debug(ps, depth, desc, "samr_io_r_connect4");
7220 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7223 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7229 /*******************************************************************
7230 inits a SAMR_Q_CONNECT5 structure.
7231 ********************************************************************/
7233 void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
7234 char *srv_name, uint32 access_mask)
7236 DEBUG(5, ("init_samr_q_connect5\n"));
7238 /* make PDC server name \\server */
7239 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7240 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7242 /* example values: 0x0000 0002 */
7243 q_u->access_mask = access_mask;
7246 q_u->info1_unk1 = 3;
7247 q_u->info1_unk2 = 0;
7250 /*******************************************************************
7251 inits a SAMR_R_CONNECT5 structure.
7252 ********************************************************************/
7254 void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
7256 DEBUG(5, ("init_samr_q_connect5\n"));
7259 r_u->info1_unk1 = 3;
7260 r_u->info1_unk2 = 0;
7262 r_u->connect_pol = *pol;
7263 r_u->status = status;
7266 /*******************************************************************
7267 reads or writes a structure.
7268 ********************************************************************/
7270 BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
7271 prs_struct *ps, int depth)
7276 prs_debug(ps, depth, desc, "samr_io_q_connect5");
7282 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7284 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7289 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7292 if(!prs_uint32("level", ps, depth, &q_u->level))
7294 if(!prs_uint32("level", ps, depth, &q_u->level))
7297 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
7299 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
7305 /*******************************************************************
7306 reads or writes a structure.
7307 ********************************************************************/
7309 BOOL samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
7310 prs_struct *ps, int depth)
7315 prs_debug(ps, depth, desc, "samr_io_r_connect5");
7321 if(!prs_uint32("level", ps, depth, &r_u->level))
7323 if(!prs_uint32("level", ps, depth, &r_u->level))
7325 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
7327 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
7330 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7333 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7339 /*******************************************************************
7340 inits a SAMR_Q_CONNECT_ANON structure.
7341 ********************************************************************/
7343 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
7345 DEBUG(5, ("init_samr_q_connect_anon\n"));
7348 q_u->unknown_0 = 0x5c; /* server name (?!!) */
7349 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
7352 /*******************************************************************
7353 reads or writes a structure.
7354 ********************************************************************/
7356 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
7357 prs_struct *ps, int depth)
7362 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
7368 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
7371 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
7376 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7382 /*******************************************************************
7383 reads or writes a structure.
7384 ********************************************************************/
7386 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
7387 prs_struct *ps, int depth)
7392 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
7398 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7401 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7407 /*******************************************************************
7408 inits a SAMR_Q_GET_DOM_PWINFO structure.
7409 ********************************************************************/
7411 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
7414 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7417 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
7418 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
7421 /*******************************************************************
7422 reads or writes a structure.
7423 ********************************************************************/
7425 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
7426 prs_struct *ps, int depth)
7431 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
7437 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
7439 if (q_u->ptr != 0) {
7440 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7442 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7449 /*******************************************************************
7450 reads or writes a structure.
7451 ********************************************************************/
7453 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7454 prs_struct *ps, int depth)
7459 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7465 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
7469 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
7472 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7478 /*******************************************************************
7479 make a SAMR_ENC_PASSWD structure.
7480 ********************************************************************/
7482 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7490 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7494 /*******************************************************************
7495 reads or writes a SAMR_ENC_PASSWD structure.
7496 ********************************************************************/
7498 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7499 prs_struct *ps, int depth)
7504 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7510 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7513 if (pwd->ptr != 0) {
7514 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7521 /*******************************************************************
7522 inits a SAMR_ENC_HASH structure.
7523 ********************************************************************/
7525 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7533 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7537 /*******************************************************************
7538 reads or writes a SAMR_ENC_HASH structure.
7539 ********************************************************************/
7541 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7542 prs_struct *ps, int depth)
7547 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7553 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7555 if (hsh->ptr != 0) {
7556 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7563 /*******************************************************************
7564 inits a SAMR_Q_CHGPASSWD_USER structure.
7565 ********************************************************************/
7567 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7568 const char *dest_host, const char *user_name,
7569 const uchar nt_newpass[516],
7570 const uchar nt_oldhash[16],
7571 const uchar lm_newpass[516],
7572 const uchar lm_oldhash[16])
7574 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7577 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7578 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7580 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7581 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7583 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7584 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7586 q_u->unknown = 0x01;
7588 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7589 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7592 /*******************************************************************
7593 reads or writes a structure.
7594 ********************************************************************/
7596 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7597 prs_struct *ps, int depth)
7602 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7608 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7611 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7613 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7618 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7620 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7623 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7625 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7628 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7631 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7633 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7639 /*******************************************************************
7640 inits a SAMR_R_CHGPASSWD_USER structure.
7641 ********************************************************************/
7643 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7645 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7647 r_u->status = status;
7650 /*******************************************************************
7651 reads or writes a structure.
7652 ********************************************************************/
7654 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7655 prs_struct *ps, int depth)
7660 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7666 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7672 /*******************************************************************
7673 inits a SAMR_Q_CHGPASSWD3 structure.
7674 ********************************************************************/
7676 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
7677 const char *dest_host, const char *user_name,
7678 const uchar nt_newpass[516],
7679 const uchar nt_oldhash[16],
7680 const uchar lm_newpass[516],
7681 const uchar lm_oldhash[16])
7683 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7686 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7687 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7689 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7690 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7692 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7693 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7695 q_u->lm_change = 0x01;
7697 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7698 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7700 init_enc_passwd(&q_u->password3, NULL);
7703 /*******************************************************************
7704 reads or writes a structure.
7705 ********************************************************************/
7707 BOOL samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
7708 prs_struct *ps, int depth)
7713 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
7719 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7722 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7724 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7729 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7731 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7734 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7736 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7739 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
7742 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7744 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7747 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
7753 /*******************************************************************
7754 inits a SAMR_R_CHGPASSWD_USER3 structure.
7755 ********************************************************************/
7757 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
7758 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
7760 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7762 r_u->status = status;
7766 r_u->ptr_reject = 0;
7772 if (reject && (reject->reject_reason != Undefined)) {
7773 r_u->reject = reject;
7774 r_u->ptr_reject = 1;
7778 /*******************************************************************
7779 Reads or writes an SAMR_CHANGE_REJECT structure.
7780 ********************************************************************/
7782 BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
7787 prs_debug(ps, depth, desc, "samr_io_change_reject");
7793 if(UNMARSHALLING(ps))
7794 ZERO_STRUCTP(reject);
7796 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
7799 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
7802 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
7808 /*******************************************************************
7809 reads or writes a structure.
7810 ********************************************************************/
7812 BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
7813 prs_struct *ps, int depth)
7818 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
7824 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
7827 /* special case: Windows 2000 can return stub data here saying
7828 NT_STATUS_NOT_SUPPORTED */
7830 if ( NT_STATUS_EQUAL( NT_STATUS_NOT_SUPPORTED, NT_STATUS(r_u->ptr_info)) ) {
7831 r_u->status = NT_STATUS_NOT_SUPPORTED;
7835 if (r_u->ptr_info && r_u->info != NULL) {
7836 /* SAM_UNK_INFO_1 */
7837 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
7841 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
7844 if (r_u->ptr_reject && r_u->reject != NULL) {
7845 /* SAMR_CHANGE_REJECT */
7846 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
7850 if (!prs_ntstatus("status", ps, depth, &r_u->status))
7856 /*******************************************************************
7857 reads or writes a structure.
7858 ********************************************************************/
7860 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7861 POLICY_HND *domain_pol, uint16 switch_value)
7863 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7865 q_u->domain_pol = *domain_pol;
7866 q_u->switch_value = switch_value;
7869 /*******************************************************************
7870 reads or writes a structure.
7871 ********************************************************************/
7873 BOOL samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7874 prs_struct *ps, int depth)
7879 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7885 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7888 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7894 /*******************************************************************
7895 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7896 ********************************************************************/
7898 void init_samr_r_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7899 uint16 switch_value, SAM_UNK_CTR * ctr,
7902 DEBUG(5, ("init_samr_r_query_domain_info2\n"));
7905 r_u->switch_value = 0;
7906 r_u->status = status; /* return status */
7908 if (NT_STATUS_IS_OK(status)) {
7909 r_u->switch_value = switch_value;
7915 /*******************************************************************
7916 reads or writes a structure.
7917 ********************************************************************/
7919 BOOL samr_io_r_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7920 prs_struct *ps, int depth)
7925 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info2");
7931 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7934 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7935 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7940 switch (r_u->switch_value) {
7942 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
7946 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7950 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
7954 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
7958 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7962 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7966 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7970 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
7974 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7978 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7982 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7986 DEBUG(0, ("samr_io_r_query_domain_info2: unknown switch level 0x%x\n",
7987 r_u->switch_value));
7988 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7996 if(!prs_ntstatus("status", ps, depth, &r_u->status))
8003 /*******************************************************************
8004 reads or writes a structure.
8005 ********************************************************************/
8007 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
8008 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
8010 DEBUG(5, ("init_samr_q_set_domain_info\n"));
8012 q_u->domain_pol = *domain_pol;
8013 q_u->switch_value0 = switch_value;
8015 q_u->switch_value = switch_value;
8020 /*******************************************************************
8021 reads or writes a structure.
8022 ********************************************************************/
8024 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
8025 prs_struct *ps, int depth)
8030 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
8036 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
8039 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
8042 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
8048 if (UNMARSHALLING(ps)) {
8049 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
8053 switch (q_u->switch_value) {
8056 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
8060 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
8064 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
8068 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
8072 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
8076 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
8080 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
8084 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
8085 q_u->switch_value));
8092 /*******************************************************************
8093 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
8094 ********************************************************************/
8096 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
8098 DEBUG(5, ("init_samr_r_set_domain_info\n"));
8100 r_u->status = status; /* return status */
8103 /*******************************************************************
8104 reads or writes a structure.
8105 ********************************************************************/
8107 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
8108 prs_struct *ps, int depth)
8113 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
8119 if(!prs_ntstatus("status", ps, depth, &r_u->status))