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_LOOKUP_DOMAIN structure.
33 ********************************************************************/
35 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
36 POLICY_HND *pol, char *dom_name)
38 DEBUG(5, ("init_samr_q_lookup_domain\n"));
40 q_u->connect_pol = *pol;
42 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
43 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
46 /*******************************************************************
47 reads or writes a structure.
48 ********************************************************************/
49 bool samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
50 prs_struct *ps, int depth)
55 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
61 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
64 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
67 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
73 /*******************************************************************
74 inits a SAMR_R_LOOKUP_DOMAIN structure.
75 ********************************************************************/
77 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
78 DOM_SID *dom_sid, NTSTATUS status)
80 DEBUG(5, ("init_samr_r_lookup_domain\n"));
84 if (NT_STATUS_IS_OK(status)) {
86 init_dom_sid2(&r_u->dom_sid, dom_sid);
90 /*******************************************************************
91 reads or writes a structure.
92 ********************************************************************/
94 bool samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
95 prs_struct *ps, int depth)
100 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
106 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
109 if (r_u->ptr_sid != 0) {
110 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
116 if(!prs_ntstatus("status", ps, depth, &r_u->status))
122 /*******************************************************************
123 reads or writes a structure.
124 ********************************************************************/
126 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
128 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
130 q_u->dom_pol = *dom_pol;
131 init_dom_sid2(&q_u->sid, sid);
134 /*******************************************************************
135 reads or writes a structure.
136 ********************************************************************/
138 bool samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
139 prs_struct *ps, int depth)
144 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
150 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
153 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
162 /*******************************************************************
163 reads or writes a structure.
164 ********************************************************************/
166 bool samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
167 prs_struct *ps, int depth)
172 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
178 if(!prs_ntstatus("status", ps, depth, &r_u->status))
184 /*******************************************************************
185 reads or writes a structure.
186 ********************************************************************/
188 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
189 POLICY_HND *user_pol)
191 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
193 q_u->user_pol = *user_pol;
196 /*******************************************************************
197 reads or writes a structure.
198 ********************************************************************/
200 bool samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
201 prs_struct *ps, int depth)
206 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
212 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
215 /*******************************************************************
217 ********************************************************************/
219 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
221 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
223 r_u->min_pwd_length = 0x0000;
227 * r_u->unknown_1 = 0x0015;
230 r_u->unknown_1 = 0x01D1;
231 r_u->unknown_1 = 0x0015;
233 r_u->password_properties = 0x00000000;
235 r_u->status = status;
238 /*******************************************************************
239 reads or writes a structure.
240 ********************************************************************/
242 bool samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
243 prs_struct *ps, int depth)
248 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
254 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
256 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
258 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
261 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
268 /*******************************************************************
269 reads or writes a structure.
270 ********************************************************************/
272 bool samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
273 prs_struct *ps, int depth)
278 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
284 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
287 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
290 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
297 /*******************************************************************
298 reads or writes a structure.
299 ********************************************************************/
301 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
302 POLICY_HND *user_pol, uint32 sec_info)
304 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
306 q_u->user_pol = *user_pol;
307 q_u->sec_info = sec_info;
311 /*******************************************************************
312 reads or writes a structure.
313 ********************************************************************/
315 bool samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
316 prs_struct *ps, int depth)
321 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
327 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
330 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
336 /*******************************************************************
337 reads or writes a structure.
338 ********************************************************************/
340 void init_samr_q_query_domain_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
341 POLICY_HND *domain_pol, uint16 switch_value)
343 DEBUG(5, ("samr_init_samr_q_query_domain_info\n"));
345 q_u->domain_pol = *domain_pol;
346 q_u->switch_value = switch_value;
349 /*******************************************************************
350 reads or writes a structure.
351 ********************************************************************/
353 bool samr_io_q_query_domain_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
354 prs_struct *ps, int depth)
359 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info");
365 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
368 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
374 /*******************************************************************
376 ********************************************************************/
378 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
379 uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
381 u_1->min_length_password = min_pass_len;
382 u_1->password_history = pass_hist;
384 if (lp_check_password_script() && *lp_check_password_script()) {
385 password_properties |= DOMAIN_PASSWORD_COMPLEX;
387 u_1->password_properties = password_properties;
389 /* password never expire */
390 u_1->expire = nt_expire;
392 /* can change the password now */
393 u_1->min_passwordage = nt_min_age;
397 /*******************************************************************
398 reads or writes a structure.
399 ********************************************************************/
401 static bool sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
402 prs_struct *ps, int depth)
407 prs_debug(ps, depth, desc, "sam_io_unk_info1");
410 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
412 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
414 if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
416 if(!smb_io_time("expire", &u_1->expire, ps, depth))
418 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
424 /*******************************************************************
426 ********************************************************************/
428 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
429 const char *comment, const char *domain, const char *server,
430 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
432 u_2->logout = nt_logout;
434 u_2->seq_num = seq_num;
437 u_2->unknown_4 = 0x00000001;
438 u_2->server_role = server_role;
439 u_2->unknown_6 = 0x00000001;
440 u_2->num_domain_usrs = num_users;
441 u_2->num_domain_grps = num_groups;
442 u_2->num_local_grps = num_alias;
444 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
445 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
446 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
447 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
448 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
449 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
452 /*******************************************************************
453 reads or writes a structure.
454 ********************************************************************/
456 static bool sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
457 prs_struct *ps, int depth)
462 prs_debug(ps, depth, desc, "sam_io_unk_info2");
465 if(!smb_io_time("logout", &u_2->logout, ps, depth))
467 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
469 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
471 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
474 /* put all the data in here, at the moment, including what the above
475 pointer is referring to
478 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
481 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
483 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
485 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
487 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
489 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
491 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
494 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
496 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
498 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
504 /*******************************************************************
506 ********************************************************************/
508 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
510 u_3->logout = nt_logout;
513 /*******************************************************************
514 reads or writes a structure.
515 ********************************************************************/
517 static bool sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
518 prs_struct *ps, int depth)
523 prs_debug(ps, depth, desc, "sam_io_unk_info3");
526 if(!smb_io_time("logout", &u_3->logout, ps, depth))
532 /*******************************************************************
534 ********************************************************************/
536 void init_unk_info4(SAM_UNK_INFO_4 * u_4,const char *comment)
538 init_unistr2(&u_4->uni_comment, comment, UNI_FLAGS_NONE);
539 init_uni_hdr(&u_4->hdr_comment, &u_4->uni_comment);
542 /*******************************************************************
543 reads or writes a structure.
544 ********************************************************************/
546 static bool sam_io_unk_info4(const char *desc, SAM_UNK_INFO_4 * u_4,
547 prs_struct *ps, int depth)
552 prs_debug(ps, depth, desc, "sam_io_unk_info4");
555 if(!smb_io_unihdr("hdr_comment", &u_4->hdr_comment, ps, depth))
558 if(!smb_io_unistr2("uni_comment", &u_4->uni_comment, u_4->hdr_comment.buffer, ps, depth))
564 /*******************************************************************
566 ********************************************************************/
568 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *domain)
570 init_unistr2(&u_5->uni_domain, domain, UNI_FLAGS_NONE);
571 init_uni_hdr(&u_5->hdr_domain, &u_5->uni_domain);
574 /*******************************************************************
575 reads or writes a structure.
576 ********************************************************************/
578 static bool sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
579 prs_struct *ps, int depth)
584 prs_debug(ps, depth, desc, "sam_io_unk_info5");
587 if(!smb_io_unihdr("hdr_domain", &u_5->hdr_domain, ps, depth))
590 if(!smb_io_unistr2("uni_domain", &u_5->uni_domain, u_5->hdr_domain.buffer, ps, depth))
596 /*******************************************************************
598 ********************************************************************/
600 void init_unk_info6(SAM_UNK_INFO_6 * u_6, const char *server)
602 init_unistr2(&u_6->uni_server, server, UNI_FLAGS_NONE);
603 init_uni_hdr(&u_6->hdr_server, &u_6->uni_server);
606 /*******************************************************************
607 reads or writes a structure.
608 ********************************************************************/
610 static bool sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
611 prs_struct *ps, int depth)
616 prs_debug(ps, depth, desc, "sam_io_unk_info6");
619 if(!smb_io_unihdr("hdr_server", &u_6->hdr_server, ps, depth))
622 if(!smb_io_unistr2("uni_server", &u_6->uni_server, u_6->hdr_server.buffer, ps, depth))
628 /*******************************************************************
630 ********************************************************************/
632 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
634 u_7->server_role = server_role;
637 /*******************************************************************
638 reads or writes a structure.
639 ********************************************************************/
641 static bool sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
642 prs_struct *ps, int depth)
647 prs_debug(ps, depth, desc, "sam_io_unk_info7");
650 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
656 /*******************************************************************
658 ********************************************************************/
660 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
662 unix_to_nt_time(&u_8->domain_create_time, 0);
663 u_8->seq_num = seq_num;
666 /*******************************************************************
667 reads or writes a structure.
668 ********************************************************************/
670 static bool sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
671 prs_struct *ps, int depth)
676 prs_debug(ps, depth, desc, "sam_io_unk_info8");
679 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
682 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
688 /*******************************************************************
690 ********************************************************************/
692 void init_unk_info9(SAM_UNK_INFO_9 * u_9, uint32 unknown)
694 u_9->unknown = unknown;
697 /*******************************************************************
698 reads or writes a structure.
699 ********************************************************************/
701 static bool sam_io_unk_info9(const char *desc, SAM_UNK_INFO_9 * u_9,
702 prs_struct *ps, int depth)
707 prs_debug(ps, depth, desc, "sam_io_unk_info9");
710 if (!prs_uint32("unknown", ps, depth, &u_9->unknown))
716 /*******************************************************************
718 ********************************************************************/
720 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
722 u_12->duration = nt_lock_duration;
723 u_12->reset_count = nt_reset_time;
725 u_12->bad_attempt_lockout = lockout;
728 /*******************************************************************
729 reads or writes a structure.
730 ********************************************************************/
732 static bool sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
733 prs_struct *ps, int depth)
738 prs_debug(ps, depth, desc, "sam_io_unk_info12");
741 if(!smb_io_time("duration", &u_12->duration, ps, depth))
743 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
745 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
751 /*******************************************************************
753 ********************************************************************/
755 void init_unk_info13(SAM_UNK_INFO_13 * u_13, uint32 seq_num)
757 unix_to_nt_time(&u_13->domain_create_time, 0);
758 u_13->seq_num = seq_num;
763 /*******************************************************************
764 reads or writes a structure.
765 ********************************************************************/
767 static bool sam_io_unk_info13(const char *desc, SAM_UNK_INFO_13 * u_13,
768 prs_struct *ps, int depth)
773 prs_debug(ps, depth, desc, "sam_io_unk_info13");
776 if (!prs_uint64("seq_num", ps, depth, &u_13->seq_num))
779 if(!smb_io_time("domain_create_time", &u_13->domain_create_time, ps, depth))
782 if (!prs_uint32("unknown1", ps, depth, &u_13->unknown1))
784 if (!prs_uint32("unknown2", ps, depth, &u_13->unknown2))
790 /*******************************************************************
791 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
792 ********************************************************************/
794 void init_samr_r_query_domain_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
795 uint16 switch_value, SAM_UNK_CTR * ctr,
798 DEBUG(5, ("init_samr_r_query_domain_info\n"));
801 r_u->switch_value = 0;
802 r_u->status = status; /* return status */
804 if (NT_STATUS_IS_OK(status)) {
805 r_u->switch_value = switch_value;
811 /*******************************************************************
812 reads or writes a structure.
813 ********************************************************************/
815 bool samr_io_r_query_domain_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
816 prs_struct *ps, int depth)
821 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info");
827 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
830 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
831 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
836 switch (r_u->switch_value) {
838 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
842 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
846 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
850 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
854 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
858 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
862 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
866 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
870 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
874 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
878 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
882 DEBUG(0, ("samr_io_r_query_domain_info: unknown switch level 0x%x\n",
884 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
892 if(!prs_ntstatus("status", ps, depth, &r_u->status))
898 /*******************************************************************
899 reads or writes a structure.
900 ********************************************************************/
902 void init_samr_q_set_sec_obj(SAMR_Q_SET_SEC_OBJ * q_u,
903 POLICY_HND *pol, uint32 sec_info, SEC_DESC_BUF *buf)
905 DEBUG(5, ("samr_init_samr_q_set_sec_obj\n"));
908 q_u->sec_info = sec_info;
913 /*******************************************************************
914 reads or writes a SAMR_R_SET_SEC_OBJ structure.
915 ********************************************************************/
917 bool samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
918 prs_struct *ps, int depth)
923 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
929 if(!prs_ntstatus("status", ps, depth, &r_u->status))
935 /*******************************************************************
936 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
937 ********************************************************************/
939 bool samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
940 prs_struct *ps, int depth)
945 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
951 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
954 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
958 if(!prs_ntstatus("status", ps, depth, &r_u->status))
964 /*******************************************************************
965 reads or writes a SAM_STR1 structure.
966 ********************************************************************/
968 static bool sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
969 uint32 name_buf, uint32 desc_buf,
970 prs_struct *ps, int depth)
975 prs_debug(ps, depth, desc, "sam_io_sam_str1");
980 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
983 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
986 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
992 /*******************************************************************
993 inits a SAM_ENTRY1 structure.
994 ********************************************************************/
996 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
997 UNISTR2 *sam_name, UNISTR2 *sam_full,
998 UNISTR2 *sam_desc, uint32 rid_user,
1001 DEBUG(5, ("init_sam_entry1\n"));
1005 sam->user_idx = user_idx;
1006 sam->rid_user = rid_user;
1007 sam->acb_info = acb_info;
1009 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1010 init_uni_hdr(&sam->hdr_user_name, sam_full);
1011 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1014 /*******************************************************************
1015 reads or writes a SAM_ENTRY1 structure.
1016 ********************************************************************/
1018 static bool sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1019 prs_struct *ps, int depth)
1024 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1030 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1033 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1035 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1038 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1040 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1042 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1048 /*******************************************************************
1049 reads or writes a SAM_STR2 structure.
1050 ********************************************************************/
1052 static bool sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1053 uint32 desc_buf, prs_struct *ps, int depth)
1058 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1064 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1066 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1072 /*******************************************************************
1073 inits a SAM_ENTRY2 structure.
1074 ********************************************************************/
1075 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1076 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1077 uint32 rid_user, uint32 acb_info)
1079 DEBUG(5, ("init_sam_entry2\n"));
1081 sam->user_idx = user_idx;
1082 sam->rid_user = rid_user;
1083 sam->acb_info = acb_info;
1085 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1086 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1089 /*******************************************************************
1090 reads or writes a SAM_ENTRY2 structure.
1091 ********************************************************************/
1093 static bool sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1094 prs_struct *ps, int depth)
1099 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1105 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1108 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1110 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1113 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1115 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1121 /*******************************************************************
1122 reads or writes a SAM_STR3 structure.
1123 ********************************************************************/
1125 static bool sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1126 uint32 desc_buf, prs_struct *ps, int depth)
1131 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1137 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1139 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1145 /*******************************************************************
1146 inits a SAM_ENTRY3 structure.
1147 ********************************************************************/
1149 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1150 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1153 DEBUG(5, ("init_sam_entry3\n"));
1155 sam->grp_idx = grp_idx;
1156 sam->rid_grp = rid_grp;
1157 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1159 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1160 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1163 /*******************************************************************
1164 reads or writes a SAM_ENTRY3 structure.
1165 ********************************************************************/
1167 static bool sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1168 prs_struct *ps, int depth)
1173 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1179 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1182 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1184 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1187 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1189 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1195 /*******************************************************************
1196 inits a SAM_ENTRY4 structure.
1197 ********************************************************************/
1199 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1200 uint32 len_acct_name)
1202 DEBUG(5, ("init_sam_entry4\n"));
1204 sam->user_idx = user_idx;
1205 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1208 /*******************************************************************
1209 reads or writes a SAM_ENTRY4 structure.
1210 ********************************************************************/
1212 static bool sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1213 prs_struct *ps, int depth)
1218 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1224 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1226 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1232 /*******************************************************************
1233 inits a SAM_ENTRY5 structure.
1234 ********************************************************************/
1236 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1237 uint32 len_grp_name)
1239 DEBUG(5, ("init_sam_entry5\n"));
1241 sam->grp_idx = grp_idx;
1242 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1246 /*******************************************************************
1247 reads or writes a SAM_ENTRY5 structure.
1248 ********************************************************************/
1250 static bool sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1251 prs_struct *ps, int depth)
1256 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1262 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1264 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1270 /*******************************************************************
1271 inits a SAM_ENTRY structure.
1272 ********************************************************************/
1274 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1276 DEBUG(10, ("init_sam_entry: %d\n", rid));
1279 init_uni_hdr(&sam->hdr_name, uni2);
1282 /*******************************************************************
1283 reads or writes a SAM_ENTRY structure.
1284 ********************************************************************/
1286 static bool sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1287 prs_struct *ps, int depth)
1292 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1297 if(!prs_uint32("rid", ps, depth, &sam->rid))
1299 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1305 /*******************************************************************
1306 inits a SAMR_Q_ENUM_DOM_USERS structure.
1307 ********************************************************************/
1309 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1311 uint32 acb_mask, uint32 size)
1313 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1317 q_e->start_idx = start_idx; /* zero indicates lots */
1318 q_e->acb_mask = acb_mask;
1319 q_e->max_size = size;
1322 /*******************************************************************
1323 reads or writes a structure.
1324 ********************************************************************/
1326 bool samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1327 prs_struct *ps, int depth)
1332 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1338 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1341 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1343 if(!prs_uint32("acb_mask ", ps, depth, &q_e->acb_mask))
1346 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1353 /*******************************************************************
1354 inits a SAMR_R_ENUM_DOM_USERS structure.
1355 ********************************************************************/
1357 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1358 uint32 next_idx, uint32 num_sam_entries)
1360 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1362 r_u->next_idx = next_idx;
1364 if (num_sam_entries != 0) {
1365 r_u->ptr_entries1 = 1;
1366 r_u->ptr_entries2 = 1;
1367 r_u->num_entries2 = num_sam_entries;
1368 r_u->num_entries3 = num_sam_entries;
1370 r_u->num_entries4 = num_sam_entries;
1372 r_u->ptr_entries1 = 0;
1373 r_u->num_entries2 = num_sam_entries;
1374 r_u->ptr_entries2 = 1;
1378 /*******************************************************************
1379 reads or writes a structure.
1380 ********************************************************************/
1382 bool samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1383 prs_struct *ps, int depth)
1390 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1396 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1398 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1401 if (r_u->ptr_entries1 != 0) {
1402 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1404 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1406 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1409 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1410 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1411 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1414 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1415 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1416 r_u->num_entries4 = 0;
1417 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1421 for (i = 0; i < r_u->num_entries2; i++) {
1422 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1426 for (i = 0; i < r_u->num_entries2; i++) {
1427 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1436 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1438 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1444 /*******************************************************************
1445 inits a SAMR_Q_QUERY_DISPINFO structure.
1446 ********************************************************************/
1448 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1449 uint16 switch_level, uint32 start_idx,
1450 uint32 max_entries, uint32 max_size)
1452 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1454 q_e->domain_pol = *pol;
1456 q_e->switch_level = switch_level;
1458 q_e->start_idx = start_idx;
1459 q_e->max_entries = max_entries;
1460 q_e->max_size = max_size;
1463 /*******************************************************************
1464 reads or writes a structure.
1465 ********************************************************************/
1467 bool samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1468 prs_struct *ps, int depth)
1473 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1479 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1482 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1487 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1489 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1491 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1497 /*******************************************************************
1498 inits a SAM_DISPINFO_1 structure.
1499 ********************************************************************/
1501 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1502 uint32 num_entries, uint32 start_idx,
1503 struct samr_displayentry *entries)
1507 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1510 return NT_STATUS_OK;
1512 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1514 return NT_STATUS_NO_MEMORY;
1516 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1517 if ((*sam)->sam == NULL)
1518 return NT_STATUS_NO_MEMORY;
1520 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1521 if ((*sam)->str == NULL)
1522 return NT_STATUS_NO_MEMORY;
1524 for (i = 0; i < num_entries ; i++) {
1525 init_unistr2(&(*sam)->str[i].uni_acct_name,
1526 entries[i].account_name, UNI_FLAGS_NONE);
1527 init_unistr2(&(*sam)->str[i].uni_full_name,
1528 entries[i].fullname, UNI_FLAGS_NONE);
1529 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1530 entries[i].description, UNI_FLAGS_NONE);
1532 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1533 &(*sam)->str[i].uni_acct_name,
1534 &(*sam)->str[i].uni_full_name,
1535 &(*sam)->str[i].uni_acct_desc,
1536 entries[i].rid, entries[i].acct_flags);
1539 return NT_STATUS_OK;
1542 /*******************************************************************
1543 reads or writes a structure.
1544 ********************************************************************/
1546 static bool sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1548 prs_struct *ps, int depth)
1552 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1558 if (UNMARSHALLING(ps) && num_entries > 0) {
1560 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1561 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1565 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1566 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1571 for (i = 0; i < num_entries; i++) {
1572 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1576 for (i = 0; i < num_entries; i++) {
1577 if(!sam_io_sam_str1("", &sam->str[i],
1578 sam->sam[i].hdr_acct_name.buffer,
1579 sam->sam[i].hdr_user_name.buffer,
1580 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1587 /*******************************************************************
1588 inits a SAM_DISPINFO_2 structure.
1589 ********************************************************************/
1591 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1592 uint32 num_entries, uint32 start_idx,
1593 struct samr_displayentry *entries)
1597 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1600 return NT_STATUS_OK;
1602 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1604 return NT_STATUS_NO_MEMORY;
1606 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1607 if ((*sam)->sam == NULL)
1608 return NT_STATUS_NO_MEMORY;
1610 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1611 if ((*sam)->str == NULL)
1612 return NT_STATUS_NO_MEMORY;
1614 for (i = 0; i < num_entries; i++) {
1615 init_unistr2(&(*sam)->str[i].uni_srv_name,
1616 entries[i].account_name, UNI_FLAGS_NONE);
1617 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1618 entries[i].description, UNI_FLAGS_NONE);
1620 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1621 &(*sam)->str[i].uni_srv_name,
1622 &(*sam)->str[i].uni_srv_desc,
1623 entries[i].rid, entries[i].acct_flags);
1626 return NT_STATUS_OK;
1629 /*******************************************************************
1630 reads or writes a structure.
1631 ********************************************************************/
1633 static bool sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1635 prs_struct *ps, int depth)
1642 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1648 if (UNMARSHALLING(ps) && num_entries > 0) {
1650 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1651 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1655 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1656 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1661 for (i = 0; i < num_entries; i++) {
1662 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1666 for (i = 0; i < num_entries; i++) {
1667 if(!sam_io_sam_str2("", &sam->str[i],
1668 sam->sam[i].hdr_srv_name.buffer,
1669 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1676 /*******************************************************************
1677 inits a SAM_DISPINFO_3 structure.
1678 ********************************************************************/
1680 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1681 uint32 num_entries, uint32 start_idx,
1682 struct samr_displayentry *entries)
1686 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1689 return NT_STATUS_OK;
1691 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1693 return NT_STATUS_NO_MEMORY;
1695 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1696 return NT_STATUS_NO_MEMORY;
1698 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1699 return NT_STATUS_NO_MEMORY;
1701 for (i = 0; i < num_entries; i++) {
1702 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1704 init_unistr2(&(*sam)->str[i].uni_grp_name,
1705 entries[i].account_name, UNI_FLAGS_NONE);
1706 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1707 entries[i].description, UNI_FLAGS_NONE);
1709 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1710 &(*sam)->str[i].uni_grp_name,
1711 &(*sam)->str[i].uni_grp_desc,
1715 return NT_STATUS_OK;
1718 /*******************************************************************
1719 reads or writes a structure.
1720 ********************************************************************/
1722 static bool sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1724 prs_struct *ps, int depth)
1731 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1737 if (UNMARSHALLING(ps) && num_entries > 0) {
1739 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1740 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1744 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1745 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1750 for (i = 0; i < num_entries; i++) {
1751 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1755 for (i = 0; i < num_entries; i++) {
1756 if(!sam_io_sam_str3("", &sam->str[i],
1757 sam->sam[i].hdr_grp_name.buffer,
1758 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1765 /*******************************************************************
1766 inits a SAM_DISPINFO_4 structure.
1767 ********************************************************************/
1769 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1770 uint32 num_entries, uint32 start_idx,
1771 struct samr_displayentry *entries)
1775 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1778 return NT_STATUS_OK;
1780 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1782 return NT_STATUS_NO_MEMORY;
1784 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1785 if ((*sam)->sam == NULL)
1786 return NT_STATUS_NO_MEMORY;
1788 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1789 if ((*sam)->str == NULL)
1790 return NT_STATUS_NO_MEMORY;
1792 for (i = 0; i < num_entries; i++) {
1793 size_t len_sam_name = strlen(entries[i].account_name);
1795 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1797 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1800 init_string2(&(*sam)->str[i].acct_name,
1801 entries[i].account_name, len_sam_name+1,
1805 return NT_STATUS_OK;
1808 /*******************************************************************
1809 reads or writes a structure.
1810 ********************************************************************/
1812 static bool sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1814 prs_struct *ps, int depth)
1821 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1827 if (UNMARSHALLING(ps) && num_entries > 0) {
1829 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1830 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1834 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1835 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1840 for (i = 0; i < num_entries; i++) {
1841 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1845 for (i = 0; i < num_entries; i++) {
1846 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1847 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1854 /*******************************************************************
1855 inits a SAM_DISPINFO_5 structure.
1856 ********************************************************************/
1858 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1859 uint32 num_entries, uint32 start_idx,
1860 struct samr_displayentry *entries)
1862 uint32 len_sam_name;
1865 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1868 return NT_STATUS_OK;
1870 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1872 return NT_STATUS_NO_MEMORY;
1874 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1875 return NT_STATUS_NO_MEMORY;
1877 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1878 return NT_STATUS_NO_MEMORY;
1880 for (i = 0; i < num_entries; i++) {
1881 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1883 len_sam_name = strlen(entries[i].account_name);
1885 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
1886 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
1887 len_sam_name+1, len_sam_name);
1890 return NT_STATUS_OK;
1893 /*******************************************************************
1894 reads or writes a structure.
1895 ********************************************************************/
1897 static bool sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1899 prs_struct *ps, int depth)
1906 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1912 if (UNMARSHALLING(ps) && num_entries > 0) {
1914 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1915 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1919 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1920 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1925 for (i = 0; i < num_entries; i++) {
1926 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1930 for (i = 0; i < num_entries; i++) {
1931 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1932 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1939 /*******************************************************************
1940 inits a SAMR_R_QUERY_DISPINFO structure.
1941 ********************************************************************/
1943 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1944 uint32 num_entries, uint32 total_size, uint32 data_size,
1945 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1948 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1950 r_u->total_size = total_size;
1952 r_u->data_size = data_size;
1954 r_u->switch_level = switch_level;
1955 r_u->num_entries = num_entries;
1958 r_u->ptr_entries = 0;
1960 r_u->ptr_entries = 1;
1962 r_u->num_entries2 = num_entries;
1965 r_u->status = status;
1968 /*******************************************************************
1969 reads or writes a structure.
1970 ********************************************************************/
1972 bool samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1973 prs_struct *ps, int depth)
1978 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
1984 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
1986 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
1988 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
1993 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
1995 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
1998 if (r_u->ptr_entries==0) {
2001 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2007 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2010 switch (r_u->switch_level) {
2012 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2013 r_u->num_entries, ps, depth))
2017 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2018 r_u->num_entries, ps, depth))
2022 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2023 r_u->num_entries, ps, depth))
2027 if(!sam_io_sam_dispinfo_4("user list",
2028 r_u->ctr->sam.info4,
2029 r_u->num_entries, ps, depth))
2033 if(!sam_io_sam_dispinfo_5("group list",
2034 r_u->ctr->sam.info5,
2035 r_u->num_entries, ps, depth))
2039 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2045 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2051 /*******************************************************************
2052 inits a GROUP_INFO1 structure.
2053 ********************************************************************/
2055 void init_samr_group_info1(GROUP_INFO1 * gr1,
2056 char *acct_name, char *acct_desc,
2059 DEBUG(5, ("init_samr_group_info1\n"));
2061 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2062 gr1->num_members = num_members;
2064 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2065 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2066 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2067 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2070 /*******************************************************************
2071 reads or writes a structure.
2072 ********************************************************************/
2074 bool samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2075 prs_struct *ps, int depth)
2082 prs_debug(ps, depth, desc, "samr_io_group_info1");
2085 if(!prs_uint16("level", ps, depth, &dummy))
2091 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2094 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2096 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2099 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2102 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2103 gr1->hdr_acct_name.buffer, ps, depth))
2106 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2107 gr1->hdr_acct_desc.buffer, ps, depth))
2113 /*******************************************************************
2114 inits a GROUP_INFO2 structure.
2115 ********************************************************************/
2117 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2119 DEBUG(5, ("init_samr_group_info2\n"));
2122 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2123 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2126 /*******************************************************************
2127 reads or writes a structure.
2128 ********************************************************************/
2130 bool samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2135 prs_debug(ps, depth, desc, "samr_io_group_info2");
2138 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2141 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2143 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2144 gr2->hdr_acct_name.buffer, ps, depth))
2150 /*******************************************************************
2151 inits a GROUP_INFO3 structure.
2152 ********************************************************************/
2154 void init_samr_group_info3(GROUP_INFO3 *gr3)
2156 DEBUG(5, ("init_samr_group_info3\n"));
2158 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2161 /*******************************************************************
2162 reads or writes a structure.
2163 ********************************************************************/
2165 bool samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2170 prs_debug(ps, depth, desc, "samr_io_group_info3");
2176 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2182 /*******************************************************************
2183 inits a GROUP_INFO4 structure.
2184 ********************************************************************/
2186 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2188 DEBUG(5, ("init_samr_group_info4\n"));
2191 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2192 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2195 /*******************************************************************
2196 reads or writes a structure.
2197 ********************************************************************/
2199 bool samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2200 prs_struct *ps, int depth)
2205 prs_debug(ps, depth, desc, "samr_io_group_info4");
2208 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2210 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2212 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2213 gr4->hdr_acct_desc.buffer, ps, depth))
2219 /*******************************************************************
2220 inits a GROUP_INFO5 structure.
2221 ********************************************************************/
2223 void init_samr_group_info5(GROUP_INFO5 * gr5,
2224 char *acct_name, char *acct_desc,
2227 DEBUG(5, ("init_samr_group_info5\n"));
2229 gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2230 gr5->num_members = num_members;
2232 init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2233 init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
2234 init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2235 init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
2238 /*******************************************************************
2239 reads or writes a structure.
2240 ********************************************************************/
2242 bool samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
2243 prs_struct *ps, int depth)
2250 prs_debug(ps, depth, desc, "samr_io_group_info5");
2253 if(!prs_uint16("level", ps, depth, &dummy))
2259 if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
2262 if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
2264 if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
2267 if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
2270 if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
2271 gr5->hdr_acct_name.buffer, ps, depth))
2274 if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
2275 gr5->hdr_acct_desc.buffer, ps, depth))
2282 /*******************************************************************
2283 reads or writes a structure.
2284 ********************************************************************/
2286 static bool samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2287 prs_struct *ps, int depth)
2289 if (UNMARSHALLING(ps))
2290 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2295 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2298 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2301 switch ((*ctr)->switch_value1) {
2303 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2307 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2311 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2315 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2319 if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
2323 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2330 /*******************************************************************
2331 inits a SAMR_Q_DEL_GROUPMEM structure.
2332 ********************************************************************/
2334 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2335 POLICY_HND *pol, uint32 rid)
2337 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2343 /*******************************************************************
2344 reads or writes a structure.
2345 ********************************************************************/
2347 bool samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2348 prs_struct *ps, int depth)
2353 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2359 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2362 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2368 /*******************************************************************
2369 inits a SAMR_R_DEL_GROUPMEM structure.
2370 ********************************************************************/
2372 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2375 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2377 r_u->status = status;
2380 /*******************************************************************
2381 reads or writes a structure.
2382 ********************************************************************/
2384 bool samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2385 prs_struct *ps, int depth)
2390 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2396 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2402 /*******************************************************************
2403 inits a SAMR_Q_ADD_GROUPMEM structure.
2404 ********************************************************************/
2406 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2407 POLICY_HND *pol, uint32 rid)
2409 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2413 q_e->unknown = 0x0005;
2416 /*******************************************************************
2417 reads or writes a structure.
2418 ********************************************************************/
2420 bool samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2421 prs_struct *ps, int depth)
2426 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2432 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2435 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2437 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2443 /*******************************************************************
2444 inits a SAMR_R_ADD_GROUPMEM structure.
2445 ********************************************************************/
2447 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2450 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2452 r_u->status = status;
2455 /*******************************************************************
2456 reads or writes a structure.
2457 ********************************************************************/
2459 bool samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2460 prs_struct *ps, int depth)
2465 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2471 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2477 /*******************************************************************
2478 inits a SAMR_Q_SET_GROUPINFO structure.
2479 ********************************************************************/
2481 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2482 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2484 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2490 /*******************************************************************
2491 reads or writes a structure.
2492 ********************************************************************/
2494 bool samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2495 prs_struct *ps, int depth)
2500 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2506 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2509 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2515 /*******************************************************************
2516 inits a SAMR_R_SET_GROUPINFO structure.
2517 ********************************************************************/
2519 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2521 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2523 r_u->status = status;
2526 /*******************************************************************
2527 reads or writes a structure.
2528 ********************************************************************/
2530 bool samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2531 prs_struct *ps, int depth)
2536 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2542 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2548 /*******************************************************************
2549 inits a SAMR_Q_QUERY_GROUPINFO structure.
2550 ********************************************************************/
2552 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2553 POLICY_HND *pol, uint16 switch_level)
2555 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2559 q_e->switch_level = switch_level;
2562 /*******************************************************************
2563 reads or writes a structure.
2564 ********************************************************************/
2566 bool samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2567 prs_struct *ps, int depth)
2572 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2578 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2581 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2587 /*******************************************************************
2588 inits a SAMR_R_QUERY_GROUPINFO structure.
2589 ********************************************************************/
2591 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2592 GROUP_INFO_CTR * ctr, NTSTATUS status)
2594 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2596 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2598 r_u->status = status;
2601 /*******************************************************************
2602 reads or writes a structure.
2603 ********************************************************************/
2605 bool samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2606 prs_struct *ps, int depth)
2611 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2617 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2620 if (r_u->ptr != 0) {
2621 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2627 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2633 /*******************************************************************
2634 inits a SAMR_Q_QUERY_GROUPMEM structure.
2635 ********************************************************************/
2637 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2639 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2641 q_c->group_pol = *hnd;
2644 /*******************************************************************
2645 reads or writes a structure.
2646 ********************************************************************/
2648 bool samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2649 prs_struct *ps, int depth)
2654 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2660 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2666 /*******************************************************************
2667 inits a SAMR_R_QUERY_GROUPMEM structure.
2668 ********************************************************************/
2670 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2671 uint32 num_entries, uint32 *rid,
2672 uint32 *attr, NTSTATUS status)
2674 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2676 if (NT_STATUS_IS_OK(status)) {
2678 r_u->num_entries = num_entries;
2680 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2681 r_u->ptr_rids = rid != NULL ? 1 : 0;
2683 r_u->num_rids = num_entries;
2686 r_u->num_attrs = num_entries;
2690 r_u->num_entries = 0;
2693 r_u->status = status;
2696 /*******************************************************************
2697 reads or writes a structure.
2698 ********************************************************************/
2700 bool samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2701 prs_struct *ps, int depth)
2708 if (UNMARSHALLING(ps))
2711 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2717 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2719 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2722 if (r_u->ptr != 0) {
2723 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2725 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2728 if (r_u->ptr_rids != 0) {
2729 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2731 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2732 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2733 if (r_u->rid == NULL)
2737 for (i = 0; i < r_u->num_rids; i++) {
2738 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2743 if (r_u->ptr_attrs != 0) {
2744 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2747 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2748 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2749 if (r_u->attr == NULL)
2753 for (i = 0; i < r_u->num_attrs; i++) {
2754 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2760 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2766 /*******************************************************************
2767 inits a SAMR_Q_QUERY_USERGROUPS structure.
2768 ********************************************************************/
2770 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2773 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2778 /*******************************************************************
2779 reads or writes a structure.
2780 ********************************************************************/
2782 bool samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2783 prs_struct *ps, int depth)
2788 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2794 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2800 /*******************************************************************
2801 inits a SAMR_R_QUERY_USERGROUPS structure.
2802 ********************************************************************/
2804 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2805 uint32 num_gids, DOM_GID * gid,
2808 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2810 if (NT_STATUS_IS_OK(status)) {
2812 r_u->num_entries = num_gids;
2813 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2814 r_u->num_entries2 = num_gids;
2819 r_u->num_entries = 0;
2824 r_u->status = status;
2827 /*******************************************************************
2828 reads or writes a structure.
2829 ********************************************************************/
2831 bool samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
2832 prs_struct *ps, int depth)
2838 prs_debug(ps, depth, desc, "samr_io_gids");
2844 if(!prs_uint32("num_gids", ps, depth, num_gids))
2847 if ((*num_gids) != 0) {
2848 if (UNMARSHALLING(ps)) {
2849 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
2852 if ((*gid) == NULL) {
2856 for (i = 0; i < (*num_gids); i++) {
2857 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
2865 /*******************************************************************
2866 reads or writes a structure.
2867 ********************************************************************/
2869 bool samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
2870 prs_struct *ps, int depth)
2875 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
2881 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
2884 if (r_u->ptr_0 != 0) {
2885 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2887 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
2890 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
2891 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
2898 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2904 /*******************************************************************
2905 inits a SAMR_Q_ENUM_DOMAINS structure.
2906 ********************************************************************/
2908 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
2910 uint32 start_idx, uint32 size)
2912 DEBUG(5, ("init_samr_q_enum_domains\n"));
2916 q_e->start_idx = start_idx;
2917 q_e->max_size = size;
2920 /*******************************************************************
2921 reads or writes a structure.
2922 ********************************************************************/
2924 bool samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
2925 prs_struct *ps, int depth)
2930 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
2936 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2939 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
2941 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
2947 /*******************************************************************
2948 inits a SAMR_R_ENUM_DOMAINS structure.
2949 ********************************************************************/
2951 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
2952 uint32 next_idx, uint32 num_sam_entries)
2954 DEBUG(5, ("init_samr_r_enum_domains\n"));
2956 r_u->next_idx = next_idx;
2958 if (num_sam_entries != 0) {
2959 r_u->ptr_entries1 = 1;
2960 r_u->ptr_entries2 = 1;
2961 r_u->num_entries2 = num_sam_entries;
2962 r_u->num_entries3 = num_sam_entries;
2964 r_u->num_entries4 = num_sam_entries;
2966 r_u->ptr_entries1 = 0;
2967 r_u->num_entries2 = num_sam_entries;
2968 r_u->ptr_entries2 = 1;
2972 /*******************************************************************
2973 reads or writes a structure.
2974 ********************************************************************/
2976 bool samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
2977 prs_struct *ps, int depth)
2984 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
2990 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
2992 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
2995 if (r_u->ptr_entries1 != 0) {
2996 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2998 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3000 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3003 if (UNMARSHALLING(ps) && r_u->num_entries2) {
3004 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3005 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3008 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3009 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3010 r_u->num_entries4 = 0;
3011 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3015 for (i = 0; i < r_u->num_entries2; i++) {
3017 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3018 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3022 for (i = 0; i < r_u->num_entries2; i++) {
3024 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3025 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3026 r_u->sam[i].hdr_name.buffer, ps,
3035 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3037 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3043 /*******************************************************************
3044 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3045 ********************************************************************/
3047 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3049 uint32 start_idx, uint32 size)
3051 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3055 q_e->start_idx = start_idx;
3056 q_e->max_size = size;
3059 /*******************************************************************
3060 reads or writes a structure.
3061 ********************************************************************/
3063 bool samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3064 prs_struct *ps, int depth)
3069 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3075 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3078 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3080 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3086 /*******************************************************************
3087 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3088 ********************************************************************/
3090 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3091 uint32 next_idx, uint32 num_sam_entries)
3093 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3095 r_u->next_idx = next_idx;
3097 if (num_sam_entries != 0) {
3098 r_u->ptr_entries1 = 1;
3099 r_u->ptr_entries2 = 1;
3100 r_u->num_entries2 = num_sam_entries;
3101 r_u->num_entries3 = num_sam_entries;
3103 r_u->num_entries4 = num_sam_entries;
3105 r_u->ptr_entries1 = 0;
3106 r_u->num_entries2 = num_sam_entries;
3107 r_u->ptr_entries2 = 1;
3111 /*******************************************************************
3112 reads or writes a structure.
3113 ********************************************************************/
3115 bool samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3116 prs_struct *ps, int depth)
3123 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3129 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3131 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3134 if (r_u->ptr_entries1 != 0) {
3135 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3137 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3139 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3142 if (UNMARSHALLING(ps) && r_u->num_entries2) {
3143 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3144 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3147 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3149 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3150 r_u->num_entries4 = 0;
3151 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3155 for (i = 0; i < r_u->num_entries2; i++) {
3156 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3160 for (i = 0; i < r_u->num_entries2; i++) {
3161 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3162 r_u->sam[i].hdr_name.buffer, ps, depth))
3169 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3171 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3177 /*******************************************************************
3178 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3179 ********************************************************************/
3181 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3182 POLICY_HND *pol, uint32 start_idx,
3185 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3189 q_e->start_idx = start_idx;
3190 q_e->max_size = size;
3194 /*******************************************************************
3195 reads or writes a structure.
3196 ********************************************************************/
3198 bool samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3199 prs_struct *ps, int depth)
3204 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3210 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3213 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3215 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3221 /*******************************************************************
3222 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3223 ********************************************************************/
3225 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3227 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3229 r_u->next_idx = next_idx;
3231 if (num_sam_entries != 0) {
3232 r_u->ptr_entries1 = 1;
3233 r_u->ptr_entries2 = 1;
3234 r_u->num_entries2 = num_sam_entries;
3235 r_u->num_entries3 = num_sam_entries;
3237 r_u->num_entries4 = num_sam_entries;
3239 r_u->ptr_entries1 = 0;
3240 r_u->num_entries2 = num_sam_entries;
3241 r_u->ptr_entries2 = 1;
3245 /*******************************************************************
3246 reads or writes a structure.
3247 ********************************************************************/
3249 bool samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3250 prs_struct *ps, int depth)
3257 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3263 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3265 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3268 if (r_u->ptr_entries1 != 0) {
3269 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3271 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3273 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3276 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3277 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3278 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3281 if (r_u->num_entries2 != 0 &&
3282 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3283 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3284 r_u->num_entries4 = 0;
3285 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3289 for (i = 0; i < r_u->num_entries2; i++) {
3290 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3294 for (i = 0; i < r_u->num_entries2; i++) {
3295 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3296 r_u->sam[i].hdr_name.buffer, ps,
3304 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3306 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3312 /*******************************************************************
3313 inits a ALIAS_INFO1 structure.
3314 ********************************************************************/
3316 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3318 DEBUG(5, ("init_samr_alias_info1\n"));
3320 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3321 al1->num_member = num_member;
3322 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3325 /*******************************************************************
3326 reads or writes a structure.
3327 ********************************************************************/
3329 bool samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3330 prs_struct *ps, int depth)
3335 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3341 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3343 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3345 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3348 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3350 if ( !prs_align(ps) )
3352 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3354 if ( !prs_align(ps) )
3360 /*******************************************************************
3361 inits a ALIAS_INFO3 structure.
3362 ********************************************************************/
3364 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3366 DEBUG(5, ("init_samr_alias_info3\n"));
3368 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3371 /*******************************************************************
3372 reads or writes a structure.
3373 ********************************************************************/
3375 bool samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3376 prs_struct *ps, int depth)
3381 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3387 if (!prs_unistr4("description", ps, depth, &al3->description))
3393 /*******************************************************************
3394 reads or writes a structure.
3395 ********************************************************************/
3397 bool samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
3398 prs_struct *ps, int depth)
3403 prs_debug(ps, depth, desc, "samr_io_alias_info2");
3409 if (!prs_unistr4("name", ps, depth, &al2->name))
3415 /*******************************************************************
3416 reads or writes a structure.
3417 ********************************************************************/
3419 bool samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3424 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3427 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3432 switch (ctr->level) {
3434 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3438 if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
3442 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3446 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3453 /*******************************************************************
3454 inits a SAMR_Q_QUERY_ALIASINFO structure.
3455 ********************************************************************/
3457 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3458 POLICY_HND *pol, uint32 switch_level)
3460 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3463 q_e->level = switch_level;
3466 /*******************************************************************
3467 reads or writes a structure.
3468 ********************************************************************/
3470 bool samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3471 prs_struct *ps, int depth)
3476 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3482 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3485 if ( !prs_uint16("level", ps, depth, &in->level) )
3491 /*******************************************************************
3492 inits a SAMR_R_QUERY_ALIASINFO structure.
3493 ********************************************************************/
3495 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3496 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3498 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3501 out->status = status;
3504 /*******************************************************************
3505 reads or writes a structure.
3506 ********************************************************************/
3508 bool samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3509 prs_struct *ps, int depth)
3514 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3520 if ( !prs_pointer("alias", ps, depth, (void*)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3525 if(!prs_ntstatus("status", ps, depth, &out->status))
3531 /*******************************************************************
3532 inits a SAMR_Q_SET_ALIASINFO structure.
3533 ********************************************************************/
3535 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3536 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3538 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3540 q_u->alias_pol = *hnd;
3544 /*******************************************************************
3545 reads or writes a structure.
3546 ********************************************************************/
3548 bool samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3549 prs_struct *ps, int depth)
3554 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3560 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3562 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3568 /*******************************************************************
3569 reads or writes a structure.
3570 ********************************************************************/
3572 bool samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3573 prs_struct *ps, int depth)
3578 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3583 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3589 /*******************************************************************
3590 inits a SAMR_Q_QUERY_USERALIASES structure.
3591 ********************************************************************/
3593 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3596 uint32 *ptr_sid, DOM_SID2 * sid)
3598 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3602 q_u->num_sids1 = num_sids;
3604 q_u->num_sids2 = num_sids;
3606 q_u->ptr_sid = ptr_sid;
3610 /*******************************************************************
3611 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3612 ********************************************************************/
3614 bool samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3615 prs_struct *ps, int depth)
3623 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3629 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3632 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3634 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3640 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3643 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3644 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3645 if (q_u->ptr_sid == NULL)
3648 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3649 if (q_u->sid == NULL)
3653 for (i = 0; i < q_u->num_sids2; i++) {
3654 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3655 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3659 for (i = 0; i < q_u->num_sids2; i++) {
3660 if (q_u->ptr_sid[i] != 0) {
3661 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3662 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3670 /*******************************************************************
3671 inits a SAMR_R_QUERY_USERALIASES structure.
3672 ********************************************************************/
3674 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3675 uint32 num_rids, uint32 *rid,
3678 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3680 if (NT_STATUS_IS_OK(status)) {
3681 r_u->num_entries = num_rids;
3683 r_u->num_entries2 = num_rids;
3687 r_u->num_entries = 0;
3689 r_u->num_entries2 = 0;
3692 r_u->status = status;
3695 /*******************************************************************
3696 reads or writes a structure.
3697 ********************************************************************/
3699 bool samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3700 prs_struct *ps, int depth)
3707 prs_debug(ps, depth, desc, "samr_io_rids");
3713 if(!prs_uint32("num_rids", ps, depth, num_rids))
3716 if ((*num_rids) != 0) {
3717 if (UNMARSHALLING(ps)) {
3719 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3724 for (i = 0; i < (*num_rids); i++) {
3725 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3726 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3734 /*******************************************************************
3735 reads or writes a structure.
3736 ********************************************************************/
3738 bool samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3739 prs_struct *ps, int depth)
3744 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3750 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3752 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3755 if (r_u->ptr != 0) {
3756 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3762 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3768 /*******************************************************************
3769 inits a SAMR_Q_LOOKUP_RIDS structure.
3770 ********************************************************************/
3772 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3773 POLICY_HND *pol, uint32 flags,
3774 uint32 num_rids, uint32 *rid)
3776 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3780 q_u->num_rids1 = num_rids;
3783 q_u->num_rids2 = num_rids;
3785 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
3789 if (q_u->rid == NULL) {
3793 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
3797 /*******************************************************************
3798 reads or writes a structure.
3799 ********************************************************************/
3801 bool samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
3802 prs_struct *ps, int depth)
3810 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
3813 if (UNMARSHALLING(ps))
3819 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3822 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
3824 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
3826 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3828 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
3831 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
3832 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
3833 if (q_u->rid == NULL)
3837 for (i = 0; i < q_u->num_rids2; i++) {
3838 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
3839 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
3846 /*******************************************************************
3847 inits a SAMR_R_LOOKUP_RIDS structure.
3848 ********************************************************************/
3850 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
3851 uint32 num_names, UNIHDR * hdr_name,
3852 UNISTR2 *uni_name, uint32 *type)
3854 DEBUG(5, ("init_samr_r_lookup_rids\n"));
3856 r_u->hdr_name = NULL;
3857 r_u->uni_name = NULL;
3860 if (num_names != 0) {
3861 r_u->num_names1 = num_names;
3863 r_u->num_names2 = num_names;
3865 r_u->num_types1 = num_names;
3867 r_u->num_types2 = num_names;
3869 r_u->hdr_name = hdr_name;
3870 r_u->uni_name = uni_name;
3873 r_u->num_names1 = num_names;
3875 r_u->num_names2 = num_names;
3877 r_u->num_types1 = num_names;
3879 r_u->num_types2 = num_names;
3883 /*******************************************************************
3884 reads or writes a structure.
3885 ********************************************************************/
3887 bool samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
3888 prs_struct *ps, int depth)
3895 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
3901 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
3903 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
3906 if (r_u->ptr_names != 0) {
3908 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
3912 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
3913 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
3914 if (r_u->hdr_name == NULL)
3917 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
3918 if (r_u->uni_name == NULL)
3922 for (i = 0; i < r_u->num_names2; i++) {
3923 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
3924 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
3927 for (i = 0; i < r_u->num_names2; i++) {
3928 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
3929 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
3937 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
3939 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
3942 if (r_u->ptr_types != 0) {
3944 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
3947 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
3948 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
3949 if (r_u->type == NULL)
3953 for (i = 0; i < r_u->num_types2; i++) {
3954 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
3955 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
3960 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3966 /*******************************************************************
3967 inits a SAMR_Q_ADD_ALIASMEM structure.
3968 ********************************************************************/
3970 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
3973 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
3975 q_u->alias_pol = *hnd;
3976 init_dom_sid2(&q_u->sid, sid);
3979 /*******************************************************************
3980 reads or writes a structure.
3981 ********************************************************************/
3983 bool samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
3984 prs_struct *ps, int depth)
3989 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
3995 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3997 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4003 /*******************************************************************
4004 reads or writes a structure.
4005 ********************************************************************/
4007 bool samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4008 prs_struct *ps, int depth)
4013 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4019 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4025 /*******************************************************************
4026 inits a SAMR_Q_DEL_ALIASMEM structure.
4027 ********************************************************************/
4029 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4032 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4034 q_u->alias_pol = *hnd;
4035 init_dom_sid2(&q_u->sid, sid);
4038 /*******************************************************************
4039 reads or writes a structure.
4040 ********************************************************************/
4042 bool samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4043 prs_struct *ps, int depth)
4048 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4054 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4056 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4062 /*******************************************************************
4063 reads or writes a structure.
4064 ********************************************************************/
4066 bool samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4067 prs_struct *ps, int depth)
4072 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4078 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4084 /*******************************************************************
4085 inits a SAMR_Q_QUERY_ALIASMEM structure.
4086 ********************************************************************/
4088 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4091 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4093 q_c->alias_pol = *hnd;
4096 /*******************************************************************
4097 reads or writes a structure.
4098 ********************************************************************/
4100 bool samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4101 prs_struct *ps, int depth)
4106 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4112 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4118 /*******************************************************************
4119 inits a SAMR_R_QUERY_ALIASMEM structure.
4120 ********************************************************************/
4122 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4123 uint32 num_sids, DOM_SID2 * sid,
4126 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4128 if (NT_STATUS_IS_OK(status)) {
4129 r_u->num_sids = num_sids;
4130 r_u->ptr = (num_sids != 0) ? 1 : 0;
4131 r_u->num_sids1 = num_sids;
4139 r_u->status = status;
4142 /*******************************************************************
4143 reads or writes a structure.
4144 ********************************************************************/
4146 bool samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4147 prs_struct *ps, int depth)
4154 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4160 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4162 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4165 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4166 uint32 *ptr_sid = NULL;
4168 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4171 /* We must always use talloc here even when marshalling. */
4172 if (r_u->num_sids1) {
4173 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4181 for (i = 0; i < r_u->num_sids1; i++) {
4183 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4187 if (UNMARSHALLING(ps)) {
4188 if (r_u->num_sids1) {
4189 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4198 for (i = 0; i < r_u->num_sids1; i++) {
4199 if (ptr_sid[i] != 0) {
4200 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4208 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4214 /*******************************************************************
4215 inits a SAMR_Q_LOOKUP_NAMES structure.
4216 ********************************************************************/
4218 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4219 POLICY_HND *pol, uint32 flags,
4220 uint32 num_names, const char **name)
4224 DEBUG(5, ("init_samr_q_lookup_names\n"));
4228 q_u->num_names1 = num_names;
4231 q_u->num_names2 = num_names;
4234 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4235 return NT_STATUS_NO_MEMORY;
4237 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4238 return NT_STATUS_NO_MEMORY;
4240 q_u->hdr_name = NULL;
4241 q_u->uni_name = NULL;
4244 for (i = 0; i < num_names; i++) {
4245 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4246 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4249 return NT_STATUS_OK;
4252 /*******************************************************************
4253 reads or writes a structure.
4254 ********************************************************************/
4256 bool samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4257 prs_struct *ps, int depth)
4264 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4267 if (UNMARSHALLING(ps))
4273 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4276 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4278 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4280 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4282 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4285 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4286 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4287 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4288 if (!q_u->hdr_name || !q_u->uni_name)
4292 for (i = 0; i < q_u->num_names2; i++) {
4293 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4297 for (i = 0; i < q_u->num_names2; i++) {
4298 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4305 /*******************************************************************
4306 inits a SAMR_R_LOOKUP_NAMES structure.
4307 ********************************************************************/
4309 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4311 uint32 *rid, enum lsa_SidType *type,
4314 DEBUG(5, ("init_samr_r_lookup_names\n"));
4316 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4319 r_u->num_types1 = num_rids;
4321 r_u->num_types2 = num_rids;
4323 r_u->num_rids1 = num_rids;
4325 r_u->num_rids2 = num_rids;
4327 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4328 return NT_STATUS_NO_MEMORY;
4329 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4330 return NT_STATUS_NO_MEMORY;
4332 for (i = 0; i < num_rids; i++) {
4333 r_u->rids[i] = rid[i];
4334 r_u->types[i] = type[i];
4338 r_u->num_types1 = 0;
4340 r_u->num_types2 = 0;
4350 r_u->status = status;
4352 return NT_STATUS_OK;
4355 /*******************************************************************
4356 reads or writes a structure.
4357 ********************************************************************/
4359 bool samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4360 prs_struct *ps, int depth)
4368 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4371 if (UNMARSHALLING(ps))
4377 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4379 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4382 if (r_u->ptr_rids != 0) {
4383 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4386 if (r_u->num_rids2 != r_u->num_rids1) {
4391 if (UNMARSHALLING(ps) && r_u->num_rids2) {
4392 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4395 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4400 for (i = 0; i < r_u->num_rids2; i++) {
4401 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4402 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4407 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4409 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4412 if (r_u->ptr_types != 0) {
4413 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4416 if (r_u->num_types2 != r_u->num_types1) {
4421 if (UNMARSHALLING(ps) && r_u->num_types2) {
4422 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4425 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4430 for (i = 0; i < r_u->num_types2; i++) {
4431 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4432 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4437 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4443 /*******************************************************************
4444 reads or writes a structure.
4445 ********************************************************************/
4447 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4450 uint32 acb_info, uint32 acct_flags)
4452 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4454 q_u->domain_pol = *pol;
4456 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
4457 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
4459 q_u->acb_info = acb_info;
4460 q_u->acct_flags = acct_flags;
4463 /*******************************************************************
4464 reads or writes a structure.
4465 ********************************************************************/
4467 bool samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
4468 prs_struct *ps, int depth)
4473 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4479 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4482 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
4484 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
4489 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
4491 if(!prs_uint32("acct_flags", ps, depth, &q_u->acct_flags))
4497 /*******************************************************************
4498 reads or writes a structure.
4499 ********************************************************************/
4501 bool samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
4502 prs_struct *ps, int depth)
4507 prs_debug(ps, depth, desc, "samr_io_r_create_user");
4513 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4516 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
4518 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
4520 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4526 /*******************************************************************
4527 inits a SAMR_Q_QUERY_USERINFO structure.
4528 ********************************************************************/
4530 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
4531 const POLICY_HND *hnd, uint16 switch_value)
4533 DEBUG(5, ("init_samr_q_query_userinfo\n"));
4536 q_u->switch_value = switch_value;
4539 /*******************************************************************
4540 reads or writes a structure.
4541 ********************************************************************/
4543 bool samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
4544 prs_struct *ps, int depth)
4549 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
4555 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4558 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
4564 /*******************************************************************
4565 reads or writes a LOGON_HRS structure.
4566 ********************************************************************/
4568 static bool sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
4569 prs_struct *ps, int depth)
4574 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
4580 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
4583 if(!prs_uint32("offset", ps, depth, &hrs->offset))
4586 if(!prs_uint32("len ", ps, depth, &hrs->len))
4589 if (hrs->len > sizeof(hrs->hours)) {
4590 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
4591 hrs->len = sizeof(hrs->hours);
4594 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
4600 /*******************************************************************
4601 inits a SAM_USER_INFO_18 structure.
4602 ********************************************************************/
4604 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
4605 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
4607 DEBUG(5, ("init_sam_user_info18\n"));
4609 usr->lm_pwd_active =
4610 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
4611 usr->nt_pwd_active =
4612 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
4615 /*******************************************************************
4616 reads or writes a structure.
4617 ********************************************************************/
4619 static bool sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
4620 prs_struct *ps, int depth)
4625 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
4631 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
4633 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
4636 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
4638 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
4644 /*******************************************************************
4645 inits a SAM_USER_INFO_7 structure.
4646 ********************************************************************/
4648 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
4650 DEBUG(5, ("init_sam_user_info7\n"));
4652 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
4653 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
4657 /*******************************************************************
4658 reads or writes a structure.
4659 ********************************************************************/
4661 static bool sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
4662 prs_struct *ps, int depth)
4667 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
4673 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
4676 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
4682 /*******************************************************************
4683 inits a SAM_USER_INFO_9 structure.
4684 ********************************************************************/
4686 void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
4688 DEBUG(5, ("init_sam_user_info9\n"));
4690 usr->rid_group = rid_group;
4693 /*******************************************************************
4694 reads or writes a structure.
4695 ********************************************************************/
4697 static bool sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
4698 prs_struct *ps, int depth)
4703 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
4709 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
4715 /*******************************************************************
4716 inits a SAM_USER_INFO_16 structure.
4717 ********************************************************************/
4719 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
4721 DEBUG(5, ("init_sam_user_info16\n"));
4723 usr->acb_info = acb_info;
4726 /*******************************************************************
4727 reads or writes a structure.
4728 ********************************************************************/
4730 static bool sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
4731 prs_struct *ps, int depth)
4736 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
4742 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
4748 /*******************************************************************
4749 inits a SAM_USER_INFO_17 structure.
4750 ********************************************************************/
4752 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
4755 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
4757 DEBUG(5, ("init_sam_user_info17\n"));
4759 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
4760 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
4762 usr->padding_2 = 0; /* 0 - padding 4 bytes */
4764 usr->ptr_1 = 1; /* pointer */
4765 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
4766 usr->padding_4 = 0; /* 0 - padding 4 bytes */
4768 usr->ptr_2 = 1; /* pointer */
4769 usr->padding_5 = 0; /* 0 - padding 4 bytes */
4771 usr->ptr_3 = 1; /* pointer */
4772 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
4774 usr->rid_user = rid_user;
4775 usr->rid_group = rid_group;
4777 usr->acct_ctrl = acct_ctrl;
4778 usr->unknown_3 = 0x0000;
4780 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
4781 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
4783 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
4784 usr->padding_8 = 0; /* 0 - padding 4 bytes */
4786 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
4787 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
4790 /*******************************************************************
4791 reads or writes a structure.
4792 ********************************************************************/
4794 static bool sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
4795 prs_struct *ps, int depth)
4800 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
4806 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
4809 if(!smb_io_time("time", &usr->expiry, ps, depth))
4812 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
4815 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
4818 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
4821 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
4823 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
4826 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
4829 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
4831 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
4834 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
4836 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
4839 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
4841 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
4843 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
4845 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
4847 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
4849 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
4852 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
4855 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
4858 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
4864 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
4870 /*************************************************************************
4872 *************************************************************************/
4874 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516],
4877 DEBUG(10, ("init_sam_user_info24:\n"));
4878 memcpy(usr->pass, newpass, sizeof(usr->pass));
4879 usr->pw_len = pw_len;
4882 /*******************************************************************
4883 reads or writes a structure.
4884 ********************************************************************/
4886 static bool sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
4887 prs_struct *ps, int depth)
4892 prs_debug(ps, depth, desc, "sam_io_user_info24");
4898 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
4902 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
4903 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
4905 } else if (UNMARSHALLING(ps)) {
4906 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
4913 /*******************************************************************
4914 reads or writes a structure.
4915 ********************************************************************/
4917 static bool sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
4918 prs_struct *ps, int depth)
4923 prs_debug(ps, depth, desc, "sam_io_user_info26");
4929 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
4933 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
4940 /*************************************************************************
4941 init_sam_user_info23
4943 unknown_6 = 0x0000 04ec
4945 *************************************************************************/
4947 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
4948 NTTIME * logoff_time, /* all zeros */
4949 NTTIME * kickoff_time, /* all zeros */
4950 NTTIME * pass_last_set_time, /* all zeros */
4951 NTTIME * pass_can_change_time, /* all zeros */
4952 NTTIME * pass_must_change_time, /* all zeros */
4963 uint32 user_rid, /* 0x0000 0000 */
4966 uint32 fields_present,
4969 uint16 bad_password_count,
4973 usr->logon_time = *logon_time; /* all zeros */
4974 usr->logoff_time = *logoff_time; /* all zeros */
4975 usr->kickoff_time = *kickoff_time; /* all zeros */
4976 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
4977 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
4978 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
4980 ZERO_STRUCT(usr->nt_pwd);
4981 ZERO_STRUCT(usr->lm_pwd);
4983 usr->user_rid = user_rid; /* 0x0000 0000 */
4984 usr->group_rid = group_rid;
4985 usr->acb_info = acb_info;
4986 usr->fields_present = fields_present; /* 09f8 27fa */
4988 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
4989 usr->ptr_logon_hrs = hrs ? 1 : 0;
4991 if (nt_time_is_zero(pass_must_change_time)) {
4992 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
4994 usr->passmustchange=0;
4997 ZERO_STRUCT(usr->padding1);
4998 ZERO_STRUCT(usr->padding2);
5000 usr->bad_password_count = bad_password_count;
5001 usr->logon_count = logon_count;
5003 memcpy(usr->pass, newpass, sizeof(usr->pass));
5005 copy_unistr2(&usr->uni_user_name, user_name);
5006 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5008 copy_unistr2(&usr->uni_full_name, full_name);
5009 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5011 copy_unistr2(&usr->uni_home_dir, home_dir);
5012 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5014 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5015 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5017 copy_unistr2(&usr->uni_logon_script, log_scr);
5018 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5020 copy_unistr2(&usr->uni_profile_path, prof_path);
5021 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5023 copy_unistr2(&usr->uni_acct_desc, desc);
5024 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5026 copy_unistr2(&usr->uni_workstations, wkstas);
5027 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5029 copy_unistr2(&usr->uni_comment, unk_str);
5030 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5032 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5033 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5036 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5038 ZERO_STRUCT(usr->logon_hrs);
5042 /*************************************************************************
5043 init_sam_user_info23
5045 unknown_6 = 0x0000 04ec
5047 *************************************************************************/
5049 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5050 NTTIME * logoff_time, /* all zeros */
5051 NTTIME * kickoff_time, /* all zeros */
5052 NTTIME * pass_last_set_time, /* all zeros */
5053 NTTIME * pass_can_change_time, /* all zeros */
5054 NTTIME * pass_must_change_time, /* all zeros */
5055 char *user_name, /* NULL */
5057 char *home_dir, char *dir_drive, char *log_scr,
5058 char *prof_path, const char *desc, char *wkstas,
5059 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5060 uint32 group_rid, uint32 acb_info,
5061 uint32 fields_present, uint16 logon_divs,
5062 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5065 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5067 usr->logon_time = *logon_time; /* all zeros */
5068 usr->logoff_time = *logoff_time; /* all zeros */
5069 usr->kickoff_time = *kickoff_time; /* all zeros */
5070 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5071 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5072 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5074 ZERO_STRUCT(usr->nt_pwd);
5075 ZERO_STRUCT(usr->lm_pwd);
5077 usr->user_rid = user_rid; /* 0x0000 0000 */
5078 usr->group_rid = group_rid;
5079 usr->acb_info = acb_info;
5080 usr->fields_present = fields_present; /* 09f8 27fa */
5082 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5083 usr->ptr_logon_hrs = hrs ? 1 : 0;
5085 if (nt_time_is_zero(pass_must_change_time)) {
5086 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5088 usr->passmustchange=0;
5091 ZERO_STRUCT(usr->padding1);
5092 ZERO_STRUCT(usr->padding2);
5094 usr->bad_password_count = bad_password_count;
5095 usr->logon_count = logon_count;
5097 memcpy(usr->pass, newpass, sizeof(usr->pass));
5099 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5100 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5102 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5103 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5105 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5106 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5108 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5109 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5111 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5112 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5114 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5115 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5117 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5118 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5120 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5121 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5123 init_unistr2(&usr->uni_comment, unk_str, UNI_FLAGS_NONE);
5124 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5126 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5127 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5129 data_blob_free(&blob);
5132 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5134 ZERO_STRUCT(usr->logon_hrs);
5139 /*************************************************************************
5140 init_samr_user_info25P
5141 fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | ACCT_FLAGS
5142 *************************************************************************/
5144 void init_sam_user_info25P(SAM_USER_INFO_25 * usr,
5145 uint32 fields_present, uint32 acb_info,
5148 usr->fields_present = fields_present;
5149 ZERO_STRUCT(usr->padding1);
5150 ZERO_STRUCT(usr->padding2);
5152 usr->acb_info = acb_info;
5153 memcpy(usr->pass, newpass, sizeof(usr->pass));
5157 /*******************************************************************
5158 reads or writes a structure.
5159 ********************************************************************/
5161 static bool sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5162 prs_struct *ps, int depth)
5167 prs_debug(ps, depth, desc, "sam_io_user_info23");
5173 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5175 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5177 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5179 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5181 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5183 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5186 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5188 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5190 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5192 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5194 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5196 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5198 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5200 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5202 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
5204 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5207 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5209 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5212 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5214 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5216 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5219 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5221 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5225 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5228 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5230 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5233 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5235 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5237 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5241 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5244 /* here begins pointed-to data */
5246 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5249 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5252 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5255 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5258 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5261 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5264 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5267 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5270 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
5273 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5276 /* ok, this is only guess-work (as usual) */
5277 if (usr->ptr_logon_hrs) {
5278 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5285 /*******************************************************************
5286 reads or writes a structure.
5287 NB. This structure is *definately* incorrect. It's my best guess
5288 currently for W2K SP2. The password field is encrypted in a different
5289 way than normal... And there are definately other problems. JRA.
5290 ********************************************************************/
5292 static bool sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5297 prs_debug(ps, depth, desc, "sam_io_user_info25");
5303 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5305 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5307 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5309 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5311 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5313 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5316 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5318 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5320 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5322 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5324 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5326 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5328 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5330 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5332 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
5334 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5337 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5339 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5342 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5344 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5346 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5348 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5351 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5355 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5358 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5360 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5363 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5365 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5367 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5371 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5374 /* here begins pointed-to data */
5376 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5379 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5382 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5385 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5388 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5391 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5394 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5397 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5400 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
5403 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5406 /* ok, this is only guess-work (as usual) */
5407 if (usr->ptr_logon_hrs) {
5408 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5416 /*************************************************************************
5417 init_sam_user_info21W
5419 unknown_6 = 0x0000 04ec
5421 *************************************************************************/
5423 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5424 NTTIME * logon_time,
5425 NTTIME * logoff_time,
5426 NTTIME * kickoff_time,
5427 NTTIME * pass_last_set_time,
5428 NTTIME * pass_can_change_time,
5429 NTTIME * pass_must_change_time,
5445 uint32 fields_present,
5448 uint16 bad_password_count,
5451 usr->logon_time = *logon_time;
5452 usr->logoff_time = *logoff_time;
5453 usr->kickoff_time = *kickoff_time;
5454 usr->pass_last_set_time = *pass_last_set_time;
5455 usr->pass_can_change_time = *pass_can_change_time;
5456 usr->pass_must_change_time = *pass_must_change_time;
5458 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5459 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5461 usr->user_rid = user_rid;
5462 usr->group_rid = group_rid;
5463 usr->acb_info = acb_info;
5464 usr->fields_present = fields_present; /* 0x00ff ffff */
5466 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5467 usr->ptr_logon_hrs = hrs ? 1 : 0;
5468 usr->bad_password_count = bad_password_count;
5469 usr->logon_count = logon_count;
5471 if (nt_time_is_zero(pass_must_change_time)) {
5472 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5474 usr->passmustchange=0;
5477 ZERO_STRUCT(usr->padding1);
5478 ZERO_STRUCT(usr->padding2);
5480 copy_unistr2(&usr->uni_user_name, user_name);
5481 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5483 copy_unistr2(&usr->uni_full_name, full_name);
5484 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5486 copy_unistr2(&usr->uni_home_dir, home_dir);
5487 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5489 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5490 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5492 copy_unistr2(&usr->uni_logon_script, log_scr);
5493 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5495 copy_unistr2(&usr->uni_profile_path, prof_path);
5496 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5498 copy_unistr2(&usr->uni_acct_desc, desc);
5499 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5501 copy_unistr2(&usr->uni_workstations, wkstas);
5502 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5504 copy_unistr2(&usr->uni_comment, unk_str);
5505 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5507 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5508 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5511 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5513 ZERO_STRUCT(usr->logon_hrs);
5517 /*************************************************************************
5518 init_sam_user_info21
5520 unknown_6 = 0x0000 04ec
5522 *************************************************************************/
5524 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
5526 NTTIME logon_time, logoff_time, kickoff_time,
5527 pass_last_set_time, pass_can_change_time,
5528 pass_must_change_time;
5530 time_t must_change_time;
5531 const char* user_name = pdb_get_username(pw);
5532 const char* full_name = pdb_get_fullname(pw);
5533 const char* home_dir = pdb_get_homedir(pw);
5534 const char* dir_drive = pdb_get_dir_drive(pw);
5535 const char* logon_script = pdb_get_logon_script(pw);
5536 const char* profile_path = pdb_get_profile_path(pw);
5537 const char* description = pdb_get_acct_desc(pw);
5538 const char* workstations = pdb_get_workstations(pw);
5539 const char* munged_dial = pdb_get_munged_dial(pw);
5540 DATA_BLOB munged_dial_blob;
5543 const DOM_SID *user_sid;
5546 const DOM_SID *group_sid;
5549 munged_dial_blob = base64_decode_data_blob(munged_dial);
5551 munged_dial_blob = data_blob_null;
5554 /* Create NTTIME structs */
5555 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5556 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5557 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5558 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5559 unix_to_nt_time (&pass_can_change_time,pdb_get_pass_can_change_time(pw));
5560 must_change_time = pdb_get_pass_must_change_time(pw);
5561 if (must_change_time == get_time_t_max())
5562 unix_to_nt_time_abs(&pass_must_change_time, must_change_time);
5564 unix_to_nt_time(&pass_must_change_time, must_change_time);
5566 /* structure assignment */
5567 usr->logon_time = logon_time;
5568 usr->logoff_time = logoff_time;
5569 usr->kickoff_time = kickoff_time;
5570 usr->pass_last_set_time = pass_last_set_time;
5571 usr->pass_can_change_time = pass_can_change_time;
5572 usr->pass_must_change_time = pass_must_change_time;
5574 ZERO_STRUCT(usr->nt_pwd);
5575 ZERO_STRUCT(usr->lm_pwd);
5577 user_sid = pdb_get_user_sid(pw);
5579 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
5580 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
5581 "the domain sid %s. Failing operation.\n",
5582 user_name, sid_string_dbg(user_sid),
5583 sid_string_dbg(domain_sid)));
5584 data_blob_free(&munged_dial_blob);
5585 return NT_STATUS_UNSUCCESSFUL;
5589 group_sid = pdb_get_group_sid(pw);
5592 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
5593 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
5594 "which conflicts with the domain sid %s. Failing operation.\n",
5595 user_name, sid_string_dbg(group_sid),
5596 sid_string_dbg(domain_sid)));
5597 data_blob_free(&munged_dial_blob);
5598 return NT_STATUS_UNSUCCESSFUL;
5601 usr->user_rid = user_rid;
5602 usr->group_rid = group_rid;
5603 usr->acb_info = pdb_get_acct_ctrl(pw);
5606 Look at a user on a real NT4 PDC with usrmgr, press
5607 'ok'. Then you will see that fields_present is set to
5608 0x08f827fa. Look at the user immediately after that again,
5609 and you will see that 0x00fffff is returned. This solves
5610 the problem that you get access denied after having looked
5614 usr->fields_present = pdb_build_fields_present(pw);
5616 usr->logon_divs = pdb_get_logon_divs(pw);
5617 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
5618 usr->bad_password_count = pdb_get_bad_password_count(pw);
5619 usr->logon_count = pdb_get_logon_count(pw);
5621 if (pdb_get_pass_must_change_time(pw) == 0) {
5622 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5624 usr->passmustchange=0;
5627 ZERO_STRUCT(usr->padding1);
5628 ZERO_STRUCT(usr->padding2);
5630 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
5631 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5633 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
5634 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5636 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
5637 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5639 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
5640 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5642 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
5643 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5645 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
5646 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5648 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
5649 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5651 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
5652 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5654 init_unistr2(&usr->uni_comment, NULL, UNI_STR_TERMINATE);
5655 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5657 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
5658 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5659 data_blob_free(&munged_dial_blob);
5661 if (pdb_get_hours(pw)) {
5662 usr->logon_hrs.max_len = 1260;
5663 usr->logon_hrs.offset = 0;
5664 usr->logon_hrs.len = pdb_get_hours_len(pw);
5665 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
5667 usr->logon_hrs.max_len = 1260;
5668 usr->logon_hrs.offset = 0;
5669 usr->logon_hrs.len = 0;
5670 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
5673 return NT_STATUS_OK;
5676 /*******************************************************************
5677 reads or writes a structure.
5678 ********************************************************************/
5680 static bool sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
5681 prs_struct *ps, int depth)
5686 prs_debug(ps, depth, desc, "sam_io_user_info21");
5692 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5694 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5696 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
5698 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5700 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
5702 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5705 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5707 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5709 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5711 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5713 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5715 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5717 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5719 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5721 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
5723 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5726 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5728 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5731 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5733 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5735 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5738 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5740 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5744 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5747 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5749 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5752 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5754 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5756 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5759 /* here begins pointed-to data */
5761 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth))
5763 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth))
5765 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth))
5767 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth))
5769 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth))
5771 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth))
5773 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth))
5775 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth))
5777 if(!smb_io_unistr2("uni_comment", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth))
5779 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth))
5782 /* ok, this is only guess-work (as usual) */
5783 if (usr->ptr_logon_hrs) {
5784 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5791 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
5793 const char *munged_dial = pdb_get_munged_dial(pw);
5797 blob = base64_decode_data_blob(munged_dial);
5799 blob = data_blob_null;
5802 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5803 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5804 data_blob_free(&blob);
5807 /*******************************************************************
5808 reads or writes a structure.
5809 ********************************************************************/
5811 static bool sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
5812 prs_struct *ps, int depth)
5817 prs_debug(ps, depth, desc, "sam_io_user_info20");
5823 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5826 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
5832 /*******************************************************************
5833 inits a SAM_USERINFO_CTR structure.
5834 ********************************************************************/
5836 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
5837 uint16 switch_value,
5838 SAM_USER_INFO_21 * usr)
5840 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
5842 ctr->switch_value = switch_value;
5843 ctr->info.id = NULL;
5845 switch (switch_value) {
5847 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
5848 if (ctr->info.id16 == NULL)
5849 return NT_STATUS_NO_MEMORY;
5851 init_sam_user_info16(ctr->info.id16, usr->acb_info);
5854 /* whoops - got this wrong. i think. or don't understand what's happening. */
5858 info = (void *)&id11;
5860 expire.low = 0xffffffff;
5861 expire.high = 0x7fffffff;
5863 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
5864 init_sam_user_info11(ctr->info.id17, &expire,
5865 "BROOKFIELDS$", /* name */
5866 0x03ef, /* user rid */
5867 0x201, /* group rid */
5868 0x0080); /* acb info */
5874 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
5875 if (ctr->info.id18 == NULL)
5876 return NT_STATUS_NO_MEMORY;
5878 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
5882 SAM_USER_INFO_21 *cusr;
5883 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
5884 ctr->info.id21 = cusr;
5885 if (ctr->info.id21 == NULL)
5886 return NT_STATUS_NO_MEMORY;
5887 memcpy(cusr, usr, sizeof(*usr));
5888 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
5889 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
5893 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
5894 return NT_STATUS_INVALID_INFO_CLASS;
5897 return NT_STATUS_OK;
5900 /*******************************************************************
5901 inits a SAM_USERINFO_CTR structure.
5902 ********************************************************************/
5904 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
5905 uint16 switch_value, void *info)
5907 DEBUG(5, ("init_samr_userinfo_ctr\n"));
5909 ctr->switch_value = switch_value;
5910 ctr->info.id = info;
5912 switch (switch_value) {
5914 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
5915 dump_data(100, sess_key->data, sess_key->length);
5916 dump_data(100, ctr->info.id24->pass, 516);
5919 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
5920 dump_data(100, sess_key->data, sess_key->length);
5921 dump_data(100, ctr->info.id23->pass, 516);
5926 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
5930 /*******************************************************************
5931 reads or writes a structure.
5932 ********************************************************************/
5934 static bool samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
5935 prs_struct *ps, int depth)
5938 SAM_USERINFO_CTR *ctr;
5940 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
5943 if (UNMARSHALLING(ps)) {
5944 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
5952 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
5954 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
5961 switch (ctr->switch_value) {
5963 if (UNMARSHALLING(ps))
5964 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
5965 if (ctr->info.id7 == NULL) {
5966 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5969 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
5972 if (UNMARSHALLING(ps))
5973 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
5974 if (ctr->info.id9 == NULL) {
5975 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5978 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
5981 if (UNMARSHALLING(ps))
5982 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
5983 if (ctr->info.id16 == NULL) {
5984 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5987 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
5990 if (UNMARSHALLING(ps))
5991 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
5993 if (ctr->info.id17 == NULL) {
5994 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
5997 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6000 if (UNMARSHALLING(ps))
6001 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6003 if (ctr->info.id18 == NULL) {
6004 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6007 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6010 if (UNMARSHALLING(ps))
6011 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6013 if (ctr->info.id20 == NULL) {
6014 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6017 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6020 if (UNMARSHALLING(ps))
6021 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6023 if (ctr->info.id21 == NULL) {
6024 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6027 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6030 if (UNMARSHALLING(ps))
6031 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6033 if (ctr->info.id23 == NULL) {
6034 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6037 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6040 if (UNMARSHALLING(ps))
6041 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6043 if (ctr->info.id24 == NULL) {
6044 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6047 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6050 if (UNMARSHALLING(ps))
6051 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6053 if (ctr->info.id25 == NULL) {
6054 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6057 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6060 if (UNMARSHALLING(ps))
6061 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6063 if (ctr->info.id26 == NULL) {
6064 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6067 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6070 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6078 /*******************************************************************
6079 inits a SAMR_R_QUERY_USERINFO structure.
6080 ********************************************************************/
6082 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6083 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6085 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6090 if (NT_STATUS_IS_OK(status)) {
6095 r_u->status = status; /* return status */
6098 /*******************************************************************
6099 reads or writes a structure.
6100 ********************************************************************/
6102 bool samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6103 prs_struct *ps, int depth)
6108 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6114 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6117 if (r_u->ptr != 0) {
6118 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6124 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6130 /*******************************************************************
6131 inits a SAMR_Q_SET_USERINFO structure.
6132 ********************************************************************/
6134 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6135 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6136 uint16 switch_value, void *info)
6138 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6141 q_u->switch_value = switch_value;
6142 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6145 /*******************************************************************
6146 reads or writes a structure.
6147 ********************************************************************/
6149 bool samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6150 prs_struct *ps, int depth)
6155 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6161 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6163 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6165 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6171 /*******************************************************************
6172 inits a SAMR_R_SET_USERINFO structure.
6173 ********************************************************************/
6175 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6177 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6179 r_u->status = status; /* return status */
6182 /*******************************************************************
6183 reads or writes a structure.
6184 ********************************************************************/
6186 bool samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6187 prs_struct *ps, int depth)
6192 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6198 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6204 /*******************************************************************
6205 inits a SAMR_Q_SET_USERINFO2 structure.
6206 ********************************************************************/
6208 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6209 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6210 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6212 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6215 q_u->switch_value = switch_value;
6218 q_u->ctr->switch_value = switch_value;
6220 switch (switch_value) {
6222 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
6223 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
6224 dump_data(100, sess_key->data, sess_key->length);
6225 dump_data(100, ctr->info.id18->lm_pwd, 16);
6226 dump_data(100, ctr->info.id18->nt_pwd, 16);
6231 /*******************************************************************
6232 reads or writes a structure.
6233 ********************************************************************/
6235 bool samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6236 prs_struct *ps, int depth)
6241 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6247 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6250 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6252 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6258 /*******************************************************************
6259 inits a SAMR_R_SET_USERINFO2 structure.
6260 ********************************************************************/
6262 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6264 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6266 r_u->status = status; /* return status */
6269 /*******************************************************************
6270 reads or writes a structure.
6271 ********************************************************************/
6273 bool samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6274 prs_struct *ps, int depth)
6279 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6285 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6291 /*******************************************************************
6292 inits a SAMR_Q_CONNECT structure.
6293 ********************************************************************/
6295 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6296 char *srv_name, uint32 access_mask)
6298 DEBUG(5, ("init_samr_q_connect\n"));
6300 /* make PDC server name \\server */
6301 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6302 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6304 /* example values: 0x0000 0002 */
6305 q_u->access_mask = access_mask;
6308 /*******************************************************************
6309 reads or writes a structure.
6310 ********************************************************************/
6312 bool samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6313 prs_struct *ps, int depth)
6318 prs_debug(ps, depth, desc, "samr_io_q_connect");
6324 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6326 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6331 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6337 /*******************************************************************
6338 reads or writes a structure.
6339 ********************************************************************/
6341 bool samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6342 prs_struct *ps, int depth)
6347 prs_debug(ps, depth, desc, "samr_io_r_connect");
6353 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6356 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6362 /*******************************************************************
6363 inits a SAMR_Q_CONNECT4 structure.
6364 ********************************************************************/
6366 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6367 char *srv_name, uint32 access_mask)
6369 DEBUG(5, ("init_samr_q_connect4\n"));
6371 /* make PDC server name \\server */
6372 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6373 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6375 /* Only value we've seen, possibly an address type ? */
6378 /* example values: 0x0000 0002 */
6379 q_u->access_mask = access_mask;
6382 /*******************************************************************
6383 reads or writes a structure.
6384 ********************************************************************/
6386 bool samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6387 prs_struct *ps, int depth)
6392 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6398 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6400 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6405 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6407 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6413 /*******************************************************************
6414 reads or writes a structure.
6415 ********************************************************************/
6417 bool samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6418 prs_struct *ps, int depth)
6423 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6429 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6432 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6438 /*******************************************************************
6439 inits a SAMR_Q_CONNECT5 structure.
6440 ********************************************************************/
6442 void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
6443 char *srv_name, uint32 access_mask)
6445 DEBUG(5, ("init_samr_q_connect5\n"));
6447 /* make PDC server name \\server */
6448 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6449 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6451 /* example values: 0x0000 0002 */
6452 q_u->access_mask = access_mask;
6455 q_u->info1_unk1 = 3;
6456 q_u->info1_unk2 = 0;
6459 /*******************************************************************
6460 inits a SAMR_R_CONNECT5 structure.
6461 ********************************************************************/
6463 void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
6465 DEBUG(5, ("init_samr_q_connect5\n"));
6468 r_u->info1_unk1 = 3;
6469 r_u->info1_unk2 = 0;
6471 r_u->connect_pol = *pol;
6472 r_u->status = status;
6475 /*******************************************************************
6476 reads or writes a structure.
6477 ********************************************************************/
6479 bool samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
6480 prs_struct *ps, int depth)
6485 prs_debug(ps, depth, desc, "samr_io_q_connect5");
6491 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6493 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6498 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6501 if(!prs_uint32("level", ps, depth, &q_u->level))
6503 if(!prs_uint32("level", ps, depth, &q_u->level))
6506 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
6508 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
6514 /*******************************************************************
6515 reads or writes a structure.
6516 ********************************************************************/
6518 bool samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
6519 prs_struct *ps, int depth)
6524 prs_debug(ps, depth, desc, "samr_io_r_connect5");
6530 if(!prs_uint32("level", ps, depth, &r_u->level))
6532 if(!prs_uint32("level", ps, depth, &r_u->level))
6534 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
6536 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
6539 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6542 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6548 /*******************************************************************
6549 inits a SAMR_Q_CONNECT_ANON structure.
6550 ********************************************************************/
6552 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6554 DEBUG(5, ("init_samr_q_connect_anon\n"));
6557 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6558 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
6561 /*******************************************************************
6562 reads or writes a structure.
6563 ********************************************************************/
6565 bool samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6566 prs_struct *ps, int depth)
6571 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6577 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6580 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6585 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6591 /*******************************************************************
6592 reads or writes a structure.
6593 ********************************************************************/
6595 bool samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6596 prs_struct *ps, int depth)
6601 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6607 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6610 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6616 /*******************************************************************
6617 make a SAMR_ENC_PASSWD structure.
6618 ********************************************************************/
6620 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
6628 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6632 /*******************************************************************
6633 reads or writes a SAMR_ENC_PASSWD structure.
6634 ********************************************************************/
6636 bool samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
6637 prs_struct *ps, int depth)
6642 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6648 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
6651 if (pwd->ptr != 0) {
6652 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
6659 /*******************************************************************
6660 inits a SAMR_ENC_HASH structure.
6661 ********************************************************************/
6663 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
6671 memcpy(hsh->hash, hash, sizeof(hsh->hash));
6675 /*******************************************************************
6676 reads or writes a SAMR_ENC_HASH structure.
6677 ********************************************************************/
6679 bool samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
6680 prs_struct *ps, int depth)
6685 prs_debug(ps, depth, desc, "samr_io_enc_hash");
6691 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
6693 if (hsh->ptr != 0) {
6694 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
6701 /*******************************************************************
6702 inits a SAMR_Q_CHGPASSWD_USER structure.
6703 ********************************************************************/
6705 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
6706 const char *dest_host, const char *user_name,
6707 const uchar nt_newpass[516],
6708 const uchar nt_oldhash[16],
6709 const uchar lm_newpass[516],
6710 const uchar lm_oldhash[16])
6712 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
6715 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
6716 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
6718 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
6719 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
6721 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
6722 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
6724 q_u->unknown = 0x01;
6726 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
6727 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
6730 /*******************************************************************
6731 reads or writes a structure.
6732 ********************************************************************/
6734 bool samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
6735 prs_struct *ps, int depth)
6740 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
6746 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
6749 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
6751 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
6756 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
6758 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
6761 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
6763 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
6766 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
6769 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
6771 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
6777 /*******************************************************************
6778 inits a SAMR_R_CHGPASSWD_USER structure.
6779 ********************************************************************/
6781 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
6783 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
6785 r_u->status = status;
6788 /*******************************************************************
6789 reads or writes a structure.
6790 ********************************************************************/
6792 bool samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
6793 prs_struct *ps, int depth)
6798 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
6804 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6810 /*******************************************************************
6811 inits a SAMR_Q_CHGPASSWD3 structure.
6812 ********************************************************************/
6814 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
6815 const char *dest_host, const char *user_name,
6816 const uchar nt_newpass[516],
6817 const uchar nt_oldhash[16],
6818 const uchar lm_newpass[516],
6819 const uchar lm_oldhash[16])
6821 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
6824 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
6825 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
6827 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
6828 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
6830 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
6831 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
6833 q_u->lm_change = 0x01;
6835 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
6836 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
6838 init_enc_passwd(&q_u->password3, NULL);
6841 /*******************************************************************
6842 reads or writes a structure.
6843 ********************************************************************/
6845 bool samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
6846 prs_struct *ps, int depth)
6851 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
6857 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
6860 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
6862 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
6867 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
6869 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
6872 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
6874 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
6877 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
6880 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
6882 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
6885 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
6891 /*******************************************************************
6892 inits a SAMR_R_CHGPASSWD_USER3 structure.
6893 ********************************************************************/
6895 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
6896 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
6898 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
6900 r_u->status = status;
6904 r_u->ptr_reject = 0;
6910 if (reject && (reject->reject_reason != Undefined)) {
6911 r_u->reject = reject;
6912 r_u->ptr_reject = 1;
6916 /*******************************************************************
6917 Reads or writes an SAMR_CHANGE_REJECT structure.
6918 ********************************************************************/
6920 bool samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
6925 prs_debug(ps, depth, desc, "samr_io_change_reject");
6931 if(UNMARSHALLING(ps))
6932 ZERO_STRUCTP(reject);
6934 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
6937 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
6940 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
6946 /*******************************************************************
6947 reads or writes a structure.
6948 ********************************************************************/
6950 bool samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
6951 prs_struct *ps, int depth)
6956 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
6962 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
6965 /* special case: Windows 2000 can return stub data here saying
6966 NT_STATUS_NOT_SUPPORTED */
6968 if ( NT_STATUS_EQUAL( NT_STATUS_NOT_SUPPORTED, NT_STATUS(r_u->ptr_info)) ) {
6969 r_u->status = NT_STATUS_NOT_SUPPORTED;
6973 if (r_u->ptr_info && r_u->info != NULL) {
6974 /* SAM_UNK_INFO_1 */
6975 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
6979 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
6982 if (r_u->ptr_reject && r_u->reject != NULL) {
6983 /* SAMR_CHANGE_REJECT */
6984 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
6988 if (!prs_ntstatus("status", ps, depth, &r_u->status))
6994 /*******************************************************************
6995 reads or writes a structure.
6996 ********************************************************************/
6998 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
6999 POLICY_HND *domain_pol, uint16 switch_value)
7001 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7003 q_u->domain_pol = *domain_pol;
7004 q_u->switch_value = switch_value;
7007 /*******************************************************************
7008 reads or writes a structure.
7009 ********************************************************************/
7011 bool samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7012 prs_struct *ps, int depth)
7017 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7023 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7026 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7032 /*******************************************************************
7033 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7034 ********************************************************************/
7036 void init_samr_r_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7037 uint16 switch_value, SAM_UNK_CTR * ctr,
7040 DEBUG(5, ("init_samr_r_query_domain_info2\n"));
7043 r_u->switch_value = 0;
7044 r_u->status = status; /* return status */
7046 if (NT_STATUS_IS_OK(status)) {
7047 r_u->switch_value = switch_value;
7053 /*******************************************************************
7054 reads or writes a structure.
7055 ********************************************************************/
7057 bool samr_io_r_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7058 prs_struct *ps, int depth)
7063 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info2");
7069 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7072 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7073 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7078 switch (r_u->switch_value) {
7080 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
7084 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7088 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
7092 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
7096 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7100 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7104 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7108 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
7112 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7116 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7120 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7124 DEBUG(0, ("samr_io_r_query_domain_info2: unknown switch level 0x%x\n",
7125 r_u->switch_value));
7126 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7134 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7141 /*******************************************************************
7142 reads or writes a structure.
7143 ********************************************************************/
7145 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7146 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7148 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7150 q_u->domain_pol = *domain_pol;
7151 q_u->switch_value0 = switch_value;
7153 q_u->switch_value = switch_value;
7158 /*******************************************************************
7159 reads or writes a structure.
7160 ********************************************************************/
7162 bool samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7163 prs_struct *ps, int depth)
7168 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7174 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7177 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7180 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7186 if (UNMARSHALLING(ps)) {
7187 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7191 switch (q_u->switch_value) {
7194 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7198 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7202 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7206 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7210 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7214 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7218 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7222 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7223 q_u->switch_value));
7230 /*******************************************************************
7231 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7232 ********************************************************************/
7234 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7236 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7238 r_u->status = status; /* return status */
7241 /*******************************************************************
7242 reads or writes a structure.
7243 ********************************************************************/
7245 bool samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7246 prs_struct *ps, int depth)
7251 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7257 if(!prs_ntstatus("status", ps, depth, &r_u->status))