2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Paul Ashton 1997-2000,
7 * Copyright (C) Elrond 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Jean François Micouleau 1998-2001,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include "rpc_parse.h"
32 #define DBGC_CLASS DBGC_RPC_PARSE
34 /*******************************************************************
35 inits a SAMR_Q_CLOSE_HND structure.
36 ********************************************************************/
38 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
40 DEBUG(5, ("init_samr_q_close_hnd\n"));
45 /*******************************************************************
46 reads or writes a structure.
47 ********************************************************************/
49 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
50 prs_struct *ps, int depth)
55 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
61 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
64 /*******************************************************************
65 reads or writes a structure.
66 ********************************************************************/
68 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
69 prs_struct *ps, int depth)
74 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
80 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
83 if(!prs_ntstatus("status", ps, depth, &r_u->status))
89 /*******************************************************************
90 inits a SAMR_Q_LOOKUP_DOMAIN structure.
91 ********************************************************************/
93 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
94 POLICY_HND *pol, char *dom_name)
96 int len_name = strlen(dom_name);
98 DEBUG(5, ("init_samr_q_lookup_domain\n"));
100 q_u->connect_pol = *pol;
102 init_uni_hdr(&q_u->hdr_domain, len_name);
103 init_unistr2(&q_u->uni_domain, dom_name, len_name);
106 /*******************************************************************
107 reads or writes a structure.
108 ********************************************************************/
109 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
110 prs_struct *ps, int depth)
115 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
121 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
124 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
127 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
133 /*******************************************************************
134 inits a SAMR_R_LOOKUP_DOMAIN structure.
135 ********************************************************************/
137 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
138 DOM_SID *dom_sid, NTSTATUS status)
140 DEBUG(5, ("init_samr_r_lookup_domain\n"));
142 r_u->status = status;
144 if (NT_STATUS_IS_OK(status)) {
146 init_dom_sid2(&r_u->dom_sid, dom_sid);
150 /*******************************************************************
151 reads or writes a structure.
152 ********************************************************************/
154 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
155 prs_struct *ps, int depth)
160 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
166 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
169 if (r_u->ptr_sid != 0) {
170 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
176 if(!prs_ntstatus("status", ps, depth, &r_u->status))
182 /*******************************************************************
183 reads or writes a structure.
184 ********************************************************************/
186 void init_samr_q_remove_user_foreign_domain(SAMR_Q_REMOVE_USER_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
188 DEBUG(5, ("samr_init_samr_q_remove_user_foreign_domain\n"));
190 q_u->dom_pol = *dom_pol;
191 init_dom_sid2(&q_u->sid, sid);
194 /*******************************************************************
195 reads or writes a structure.
196 ********************************************************************/
198 BOOL samr_io_q_remove_user_foreign_domain(const char *desc, SAMR_Q_REMOVE_USER_FOREIGN_DOMAIN * q_u,
199 prs_struct *ps, int depth)
204 prs_debug(ps, depth, desc, "samr_io_q_remove_user_foreign_domain");
210 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
213 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
222 /*******************************************************************
223 reads or writes a structure.
224 ********************************************************************/
226 BOOL samr_io_r_remove_user_foreign_domain(const char *desc, SAMR_R_REMOVE_USER_FOREIGN_DOMAIN * r_u,
227 prs_struct *ps, int depth)
232 prs_debug(ps, depth, desc, "samr_io_r_remove_user_foreign_domain");
238 if(!prs_ntstatus("status", ps, depth, &r_u->status))
244 /*******************************************************************
245 reads or writes a structure.
246 ********************************************************************/
248 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
249 POLICY_HND *pol, uint32 flags,
252 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
256 init_dom_sid2(&q_u->dom_sid, sid);
259 /*******************************************************************
260 reads or writes a structure.
261 ********************************************************************/
263 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
264 prs_struct *ps, int depth)
269 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
275 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
278 if(!prs_uint32("flags", ps, depth, &q_u->flags))
281 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
287 /*******************************************************************
288 reads or writes a structure.
289 ********************************************************************/
291 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
292 prs_struct *ps, int depth)
297 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
303 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
306 if(!prs_ntstatus("status", ps, depth, &r_u->status))
312 /*******************************************************************
313 reads or writes a structure.
314 ********************************************************************/
316 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
317 POLICY_HND *user_pol)
319 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
321 q_u->user_pol = *user_pol;
324 /*******************************************************************
325 reads or writes a structure.
326 ********************************************************************/
328 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
329 prs_struct *ps, int depth)
334 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
340 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
343 /*******************************************************************
345 ********************************************************************/
347 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
349 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
351 r_u->unknown_0 = 0x0000;
355 * r_u->unknown_1 = 0x0015;
358 r_u->unknown_1 = 0x01D1;
359 r_u->unknown_1 = 0x0015;
361 r_u->unknown_2 = 0x00000000;
363 r_u->status = status;
366 /*******************************************************************
367 reads or writes a structure.
368 ********************************************************************/
370 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
371 prs_struct *ps, int depth)
376 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
382 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
384 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
386 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
388 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
395 /*******************************************************************
396 reads or writes a structure.
397 ********************************************************************/
399 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
400 prs_struct *ps, int depth)
405 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
411 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
414 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
417 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
424 /*******************************************************************
425 reads or writes a structure.
426 ********************************************************************/
428 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
429 POLICY_HND *user_pol, uint32 sec_info)
431 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
433 q_u->user_pol = *user_pol;
434 q_u->sec_info = sec_info;
438 /*******************************************************************
439 reads or writes a structure.
440 ********************************************************************/
442 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
443 prs_struct *ps, int depth)
448 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
454 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
457 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
463 /*******************************************************************
464 reads or writes a structure.
465 ********************************************************************/
467 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
468 POLICY_HND *domain_pol, uint16 switch_value)
470 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
472 q_u->domain_pol = *domain_pol;
473 q_u->switch_value = switch_value;
476 /*******************************************************************
477 reads or writes a structure.
478 ********************************************************************/
480 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
481 prs_struct *ps, int depth)
486 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
492 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
495 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
502 /*******************************************************************
504 ********************************************************************/
506 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
508 u_3->logout.low = nt_logout.low;
509 u_3->logout.high = nt_logout.high;
512 /*******************************************************************
513 reads or writes a structure.
514 ********************************************************************/
516 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
517 prs_struct *ps, int depth)
522 prs_debug(ps, depth, desc, "sam_io_unk_info3");
525 if(!smb_io_time("logout", &u_3->logout, ps, depth))
531 /*******************************************************************
533 ********************************************************************/
535 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
537 u_6->unknown_0 = 0x00000000;
539 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
542 /*******************************************************************
543 reads or writes a structure.
544 ********************************************************************/
546 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
547 prs_struct *ps, int depth)
552 prs_debug(ps, depth, desc, "sam_io_unk_info6");
555 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
557 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
559 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
565 /*******************************************************************
567 ********************************************************************/
569 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
571 u_7->unknown_0 = 0x0003;
574 /*******************************************************************
575 reads or writes a structure.
576 ********************************************************************/
578 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
579 prs_struct *ps, int depth)
584 prs_debug(ps, depth, desc, "sam_io_unk_info7");
587 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
593 /*******************************************************************
595 ********************************************************************/
597 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
599 u_12->duration.low = nt_lock_duration.low;
600 u_12->duration.high = nt_lock_duration.high;
601 u_12->reset_count.low = nt_reset_time.low;
602 u_12->reset_count.high = nt_reset_time.high;
604 u_12->bad_attempt_lockout = lockout;
607 /*******************************************************************
608 reads or writes a structure.
609 ********************************************************************/
611 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
612 prs_struct *ps, int depth)
617 prs_debug(ps, depth, desc, "sam_io_unk_info12");
620 if(!smb_io_time("duration", &u_12->duration, ps, depth))
622 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
624 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
630 /*******************************************************************
632 ********************************************************************/
633 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
635 int len_server = strlen(server);
637 init_uni_hdr(&u_5->hdr_server, len_server);
639 init_unistr2(&u_5->uni_server, server, len_server);
642 /*******************************************************************
643 reads or writes a structure.
644 ********************************************************************/
646 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
647 prs_struct *ps, int depth)
652 prs_debug(ps, depth, desc, "sam_io_unk_info5");
655 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
658 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
664 /*******************************************************************
666 ********************************************************************/
667 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
668 const char *domain, const char *server,
669 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
671 int len_domain = strlen(domain);
672 int len_server = strlen(server);
674 u_2->unknown_0 = 0x00000000;
675 u_2->unknown_1 = 0x80000000;
676 u_2->unknown_2 = 0x00000000;
679 init_uni_hdr(&u_2->hdr_domain, len_domain);
680 init_uni_hdr(&u_2->hdr_server, len_server);
682 u_2->seq_num = seq_num;
683 u_2->unknown_3 = 0x00000000;
685 u_2->unknown_4 = 0x00000001;
686 u_2->unknown_5 = 0x00000003;
687 u_2->unknown_6 = 0x00000001;
688 u_2->num_domain_usrs = num_users;
689 u_2->num_domain_grps = num_groups;
690 u_2->num_local_grps = num_alias;
692 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
694 init_unistr2(&u_2->uni_domain, domain, len_domain);
695 init_unistr2(&u_2->uni_server, server, len_server);
698 /*******************************************************************
699 reads or writes a structure.
700 ********************************************************************/
702 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
703 prs_struct *ps, int depth)
708 prs_debug(ps, depth, desc, "sam_io_unk_info2");
711 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
713 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
715 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
718 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
720 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
722 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
725 /* put all the data in here, at the moment, including what the above
726 pointer is referring to
729 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
731 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
734 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
736 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
738 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
740 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
742 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
744 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
748 /* this was originally marked as 'padding'. It isn't
749 padding, it is some sort of optional 12 byte
750 structure. When it is present it contains zeros
752 if(!prs_uint8s(False, "unknown", ps, depth, u_2->padding,sizeof(u_2->padding)))
756 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
758 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
764 /*******************************************************************
766 ********************************************************************/
768 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
769 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
771 u_1->min_length_password = min_pass_len;
772 u_1->password_history = pass_hist;
775 /* password never expire */
776 u_1->expire.high = nt_expire.high;
777 u_1->expire.low = nt_expire.low;
779 /* can change the password now */
780 u_1->min_passwordage.high = nt_min_age.high;
781 u_1->min_passwordage.low = nt_min_age.low;
785 /*******************************************************************
786 reads or writes a structure.
787 ********************************************************************/
789 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
790 prs_struct *ps, int depth)
795 prs_debug(ps, depth, desc, "sam_io_unk_info1");
798 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
800 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
802 if(!prs_uint32("flag", ps, depth, &u_1->flag))
804 if(!smb_io_time("expire", &u_1->expire, ps, depth))
806 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
812 /*******************************************************************
813 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
814 ********************************************************************/
816 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
817 uint16 switch_value, SAM_UNK_CTR * ctr,
820 DEBUG(5, ("init_samr_r_query_dom_info\n"));
823 r_u->switch_value = 0;
824 r_u->status = status; /* return status */
826 if (NT_STATUS_IS_OK(status)) {
827 r_u->switch_value = switch_value;
833 /*******************************************************************
834 reads or writes a structure.
835 ********************************************************************/
837 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
838 prs_struct *ps, int depth)
843 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
849 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
852 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
853 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
858 switch (r_u->switch_value) {
860 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
864 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
868 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
872 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
876 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
880 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
884 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
888 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
890 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
898 if(!prs_ntstatus("status", ps, depth, &r_u->status))
904 /*******************************************************************
905 reads or writes a SAMR_R_SET_SEC_OBJ structure.
906 ********************************************************************/
908 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
909 prs_struct *ps, int depth)
914 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
920 if(!prs_ntstatus("status", ps, depth, &r_u->status))
926 /*******************************************************************
927 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
928 ********************************************************************/
930 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
931 prs_struct *ps, int depth)
936 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
942 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
945 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
949 if(!prs_ntstatus("status", ps, depth, &r_u->status))
955 /*******************************************************************
956 reads or writes a SAM_STR1 structure.
957 ********************************************************************/
959 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
960 uint32 name_buf, uint32 desc_buf,
961 prs_struct *ps, int depth)
966 prs_debug(ps, depth, desc, "sam_io_sam_str1");
971 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
974 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
977 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
983 /*******************************************************************
984 inits a SAM_ENTRY1 structure.
985 ********************************************************************/
987 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
988 uint32 len_sam_name, uint32 len_sam_full,
989 uint32 len_sam_desc, uint32 rid_user,
992 DEBUG(5, ("init_sam_entry1\n"));
996 sam->user_idx = user_idx;
997 sam->rid_user = rid_user;
998 sam->acb_info = acb_info;
1000 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
1001 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
1002 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
1005 /*******************************************************************
1006 reads or writes a SAM_ENTRY1 structure.
1007 ********************************************************************/
1009 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1010 prs_struct *ps, int depth)
1015 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1021 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1024 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1026 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1032 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1034 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1036 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1042 /*******************************************************************
1043 reads or writes a SAM_STR2 structure.
1044 ********************************************************************/
1046 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1047 uint32 desc_buf, prs_struct *ps, int depth)
1052 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1058 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1060 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1066 /*******************************************************************
1067 inits a SAM_ENTRY2 structure.
1068 ********************************************************************/
1069 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1070 uint32 len_sam_name, uint32 len_sam_desc,
1071 uint32 rid_user, uint16 acb_info)
1073 DEBUG(5, ("init_sam_entry2\n"));
1075 sam->user_idx = user_idx;
1076 sam->rid_user = rid_user;
1077 sam->acb_info = acb_info;
1079 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
1080 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
1083 /*******************************************************************
1084 reads or writes a SAM_ENTRY2 structure.
1085 ********************************************************************/
1087 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1088 prs_struct *ps, int depth)
1093 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1099 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1102 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1104 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1110 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1112 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1118 /*******************************************************************
1119 reads or writes a SAM_STR3 structure.
1120 ********************************************************************/
1122 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1123 uint32 desc_buf, prs_struct *ps, int depth)
1128 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1134 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1136 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1142 /*******************************************************************
1143 inits a SAM_ENTRY3 structure.
1144 ********************************************************************/
1146 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1147 uint32 len_grp_name, uint32 len_grp_desc,
1150 DEBUG(5, ("init_sam_entry3\n"));
1152 sam->grp_idx = grp_idx;
1153 sam->rid_grp = rid_grp;
1154 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1156 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1157 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1160 /*******************************************************************
1161 reads or writes a SAM_ENTRY3 structure.
1162 ********************************************************************/
1164 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1165 prs_struct *ps, int depth)
1170 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1176 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1179 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1181 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1184 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1186 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1192 /*******************************************************************
1193 inits a SAM_ENTRY4 structure.
1194 ********************************************************************/
1196 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1197 uint32 len_acct_name)
1199 DEBUG(5, ("init_sam_entry4\n"));
1201 sam->user_idx = user_idx;
1202 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1205 /*******************************************************************
1206 reads or writes a SAM_ENTRY4 structure.
1207 ********************************************************************/
1209 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1210 prs_struct *ps, int depth)
1215 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1221 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1223 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1229 /*******************************************************************
1230 inits a SAM_ENTRY5 structure.
1231 ********************************************************************/
1233 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1234 uint32 len_grp_name)
1236 DEBUG(5, ("init_sam_entry5\n"));
1238 sam->grp_idx = grp_idx;
1239 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1243 /*******************************************************************
1244 reads or writes a SAM_ENTRY5 structure.
1245 ********************************************************************/
1247 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1248 prs_struct *ps, int depth)
1253 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1259 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1261 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1267 /*******************************************************************
1268 inits a SAM_ENTRY structure.
1269 ********************************************************************/
1271 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1273 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1276 init_uni_hdr(&sam->hdr_name, len_sam_name);
1279 /*******************************************************************
1280 reads or writes a SAM_ENTRY structure.
1281 ********************************************************************/
1283 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1284 prs_struct *ps, int depth)
1289 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1294 if(!prs_uint32("rid", ps, depth, &sam->rid))
1296 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1302 /*******************************************************************
1303 inits a SAMR_Q_ENUM_DOM_USERS structure.
1304 ********************************************************************/
1306 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1308 uint16 acb_mask, uint16 unk_1, uint32 size)
1310 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1314 q_e->start_idx = start_idx; /* zero indicates lots */
1315 q_e->acb_mask = acb_mask;
1316 q_e->unknown_1 = unk_1;
1317 q_e->max_size = size;
1320 /*******************************************************************
1321 reads or writes a structure.
1322 ********************************************************************/
1324 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1325 prs_struct *ps, int depth)
1330 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1336 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1339 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1341 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1343 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
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 = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1411 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(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, uint32 num_entries,
1502 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1503 DOM_SID *domain_sid)
1505 uint32 len_sam_name, len_sam_full, len_sam_desc;
1508 SAM_ACCOUNT *pwd = NULL;
1511 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1514 return NT_STATUS_OK;
1516 sam->sam=(SAM_ENTRY1 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY1));
1518 return NT_STATUS_NO_MEMORY;
1520 sam->str=(SAM_STR1 *)talloc(ctx, num_entries*sizeof(SAM_STR1));
1522 return NT_STATUS_NO_MEMORY;
1524 ZERO_STRUCTP(sam->sam);
1525 ZERO_STRUCTP(sam->str);
1527 for (i = 0; i < num_entries ; i++) {
1528 const char *username;
1529 const char *fullname;
1530 const char *acct_desc;
1532 const DOM_SID *user_sid;
1533 fstring user_sid_string, domain_sid_string;
1535 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1537 pwd=&disp_user_info[i+start_idx];
1539 username = pdb_get_username(pwd);
1540 fullname = pdb_get_fullname(pwd);
1541 acct_desc = pdb_get_acct_desc(pwd);
1552 user_sid = pdb_get_user_sid(pwd);
1554 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1555 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1556 "the domain sid %s. Failing operation.\n",
1558 sid_to_string(user_sid_string, user_sid),
1559 sid_to_string(domain_sid_string, domain_sid)));
1560 return NT_STATUS_UNSUCCESSFUL;
1563 len_sam_name = strlen(username);
1564 len_sam_full = strlen(fullname);
1565 len_sam_desc = strlen(acct_desc);
1567 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1568 len_sam_name, len_sam_full, len_sam_desc,
1569 user_rid, pdb_get_acct_ctrl(pwd));
1571 ZERO_STRUCTP(&sam->str[i].uni_acct_name);
1572 ZERO_STRUCTP(&sam->str[i].uni_full_name);
1573 ZERO_STRUCTP(&sam->str[i].uni_acct_desc);
1575 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), len_sam_name);
1576 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), len_sam_full);
1577 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1580 return NT_STATUS_OK;
1583 /*******************************************************************
1584 reads or writes a structure.
1585 ********************************************************************/
1587 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1589 prs_struct *ps, int depth)
1593 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1599 if (UNMARSHALLING(ps) && num_entries > 0) {
1601 if ((sam->sam = (SAM_ENTRY1 *)
1602 prs_alloc_mem(ps, sizeof(SAM_ENTRY1) *
1603 num_entries)) == NULL) {
1604 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1608 if ((sam->str = (SAM_STR1 *)
1609 prs_alloc_mem(ps, sizeof(SAM_STR1) *
1610 num_entries)) == NULL) {
1611 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1616 for (i = 0; i < num_entries; i++) {
1617 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1621 for (i = 0; i < num_entries; i++) {
1622 if(!sam_io_sam_str1("", &sam->str[i],
1623 sam->sam[i].hdr_acct_name.buffer,
1624 sam->sam[i].hdr_user_name.buffer,
1625 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1632 /*******************************************************************
1633 inits a SAM_DISPINFO_2 structure.
1634 ********************************************************************/
1636 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1637 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1638 DOM_SID *domain_sid )
1640 uint32 len_sam_name, len_sam_desc;
1643 SAM_ACCOUNT *pwd = NULL;
1646 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1649 return NT_STATUS_OK;
1651 if (!(sam->sam=(SAM_ENTRY2 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY2))))
1652 return NT_STATUS_NO_MEMORY;
1654 if (!(sam->str=(SAM_STR2 *)talloc(ctx, num_entries*sizeof(SAM_STR2))))
1655 return NT_STATUS_NO_MEMORY;
1657 ZERO_STRUCTP(sam->sam);
1658 ZERO_STRUCTP(sam->str);
1660 for (i = 0; i < num_entries; i++) {
1662 const DOM_SID *user_sid;
1663 const char *username;
1664 const char *acct_desc;
1665 fstring user_sid_string, domain_sid_string;
1667 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1668 pwd=&disp_user_info[i+start_idx];
1670 username = pdb_get_username(pwd);
1671 acct_desc = pdb_get_acct_desc(pwd);
1672 user_sid = pdb_get_user_sid(pwd);
1674 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1675 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1676 "the domain sid %s. Failing operation.\n",
1678 sid_to_string(user_sid_string, user_sid),
1679 sid_to_string(domain_sid_string, domain_sid)));
1680 return NT_STATUS_UNSUCCESSFUL;
1683 len_sam_name = strlen(username);
1684 len_sam_desc = strlen(acct_desc);
1686 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1687 len_sam_name, len_sam_desc,
1688 user_rid, pdb_get_acct_ctrl(pwd));
1690 ZERO_STRUCTP(&sam->str[i].uni_srv_name);
1691 ZERO_STRUCTP(&sam->str[i].uni_srv_desc);
1693 init_unistr2(&sam->str[i].uni_srv_name, username, len_sam_name);
1694 init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1697 return NT_STATUS_OK;
1700 /*******************************************************************
1701 reads or writes a structure.
1702 ********************************************************************/
1704 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1706 prs_struct *ps, int depth)
1713 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1719 if (UNMARSHALLING(ps) && num_entries > 0) {
1721 if ((sam->sam = (SAM_ENTRY2 *)
1722 prs_alloc_mem(ps, sizeof(SAM_ENTRY2) *
1723 num_entries)) == NULL) {
1724 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1728 if ((sam->str = (SAM_STR2 *)
1729 prs_alloc_mem(ps, sizeof(SAM_STR2) *
1730 num_entries)) == NULL) {
1731 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1736 for (i = 0; i < num_entries; i++) {
1737 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1741 for (i = 0; i < num_entries; i++) {
1742 if(!sam_io_sam_str2("", &sam->str[i],
1743 sam->sam[i].hdr_srv_name.buffer,
1744 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1751 /*******************************************************************
1752 inits a SAM_DISPINFO_3 structure.
1753 ********************************************************************/
1755 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1756 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1758 uint32 len_sam_name, len_sam_desc;
1763 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1766 return NT_STATUS_OK;
1768 if (!(sam->sam=(SAM_ENTRY3 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY3))))
1769 return NT_STATUS_NO_MEMORY;
1771 if (!(sam->str=(SAM_STR3 *)talloc(ctx, num_entries*sizeof(SAM_STR3))))
1772 return NT_STATUS_NO_MEMORY;
1774 ZERO_STRUCTP(sam->sam);
1775 ZERO_STRUCTP(sam->str);
1777 for (i = 0; i < num_entries; i++) {
1778 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1780 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1782 len_sam_name = strlen(grp->name);
1783 len_sam_desc = strlen(grp->comment);
1785 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp->rid);
1787 init_unistr2(&sam->str[i].uni_grp_name, grp->name, len_sam_name);
1788 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, len_sam_desc);
1791 return NT_STATUS_OK;
1794 /*******************************************************************
1795 reads or writes a structure.
1796 ********************************************************************/
1798 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1800 prs_struct *ps, int depth)
1807 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1813 if (UNMARSHALLING(ps) && num_entries > 0) {
1815 if ((sam->sam = (SAM_ENTRY3 *)
1816 prs_alloc_mem(ps, sizeof(SAM_ENTRY3) *
1817 num_entries)) == NULL) {
1818 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1822 if ((sam->str = (SAM_STR3 *)
1823 prs_alloc_mem(ps, sizeof(SAM_STR3) *
1824 num_entries)) == NULL) {
1825 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1830 for (i = 0; i < num_entries; i++) {
1831 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1835 for (i = 0; i < num_entries; i++) {
1836 if(!sam_io_sam_str3("", &sam->str[i],
1837 sam->sam[i].hdr_grp_name.buffer,
1838 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1845 /*******************************************************************
1846 inits a SAM_DISPINFO_4 structure.
1847 ********************************************************************/
1849 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1850 uint32 start_idx, SAM_ACCOUNT *disp_user_info)
1852 uint32 len_sam_name;
1855 SAM_ACCOUNT *pwd = NULL;
1858 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1861 return NT_STATUS_OK;
1863 if (!(sam->sam=(SAM_ENTRY4 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY4))))
1864 return NT_STATUS_NO_MEMORY;
1866 if (!(sam->str=(SAM_STR4 *)talloc(ctx, num_entries*sizeof(SAM_STR4))))
1867 return NT_STATUS_NO_MEMORY;
1869 ZERO_STRUCTP(sam->sam);
1870 ZERO_STRUCTP(sam->str);
1872 for (i = 0; i < num_entries; i++) {
1873 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1874 pwd=&disp_user_info[i+start_idx];
1876 len_sam_name = strlen(pdb_get_username(pwd));
1878 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1880 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1883 return NT_STATUS_OK;
1886 /*******************************************************************
1887 reads or writes a structure.
1888 ********************************************************************/
1890 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1892 prs_struct *ps, int depth)
1899 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1905 if (UNMARSHALLING(ps) && num_entries > 0) {
1907 if ((sam->sam = (SAM_ENTRY4 *)
1908 prs_alloc_mem(ps, sizeof(SAM_ENTRY4) *
1909 num_entries)) == NULL) {
1910 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1914 if ((sam->str = (SAM_STR4 *)
1915 prs_alloc_mem(ps, sizeof(SAM_STR4) *
1916 num_entries)) == NULL) {
1917 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1922 for (i = 0; i < num_entries; i++) {
1923 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1927 for (i = 0; i < num_entries; i++) {
1928 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1929 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1936 /*******************************************************************
1937 inits a SAM_DISPINFO_5 structure.
1938 ********************************************************************/
1940 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1941 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1943 uint32 len_sam_name;
1948 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1951 return NT_STATUS_OK;
1953 if (!(sam->sam=(SAM_ENTRY5 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY5))))
1954 return NT_STATUS_NO_MEMORY;
1956 if (!(sam->str=(SAM_STR5 *)talloc(ctx, num_entries*sizeof(SAM_STR5))))
1957 return NT_STATUS_NO_MEMORY;
1959 ZERO_STRUCTP(sam->sam);
1960 ZERO_STRUCTP(sam->str);
1962 for (i = 0; i < num_entries; i++) {
1963 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1965 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1967 len_sam_name = strlen(grp->name);
1969 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1970 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1973 return NT_STATUS_OK;
1976 /*******************************************************************
1977 reads or writes a structure.
1978 ********************************************************************/
1980 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1982 prs_struct *ps, int depth)
1989 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1995 if (UNMARSHALLING(ps) && num_entries > 0) {
1997 if ((sam->sam = (SAM_ENTRY5 *)
1998 prs_alloc_mem(ps, sizeof(SAM_ENTRY5) *
1999 num_entries)) == NULL) {
2000 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
2004 if ((sam->str = (SAM_STR5 *)
2005 prs_alloc_mem(ps, sizeof(SAM_STR5) *
2006 num_entries)) == NULL) {
2007 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2012 for (i = 0; i < num_entries; i++) {
2013 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2017 for (i = 0; i < num_entries; i++) {
2018 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
2019 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2026 /*******************************************************************
2027 inits a SAMR_R_QUERY_DISPINFO structure.
2028 ********************************************************************/
2030 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2031 uint32 num_entries, uint32 total_size, uint32 data_size,
2032 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2035 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2037 r_u->total_size = total_size;
2039 r_u->data_size = data_size;
2041 r_u->switch_level = switch_level;
2042 r_u->num_entries = num_entries;
2045 r_u->ptr_entries = 0;
2047 r_u->ptr_entries = 1;
2049 r_u->num_entries2 = num_entries;
2052 r_u->status = status;
2055 /*******************************************************************
2056 reads or writes a structure.
2057 ********************************************************************/
2059 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2060 prs_struct *ps, int depth)
2065 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2071 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2073 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2075 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2080 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2082 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2085 if (r_u->ptr_entries==0) {
2088 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2094 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2097 switch (r_u->switch_level) {
2099 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2100 r_u->num_entries, ps, depth))
2104 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2105 r_u->num_entries, ps, depth))
2109 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2110 r_u->num_entries, ps, depth))
2114 if(!sam_io_sam_dispinfo_4("user list",
2115 r_u->ctr->sam.info4,
2116 r_u->num_entries, ps, depth))
2120 if(!sam_io_sam_dispinfo_5("group list",
2121 r_u->ctr->sam.info5,
2122 r_u->num_entries, ps, depth))
2126 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2132 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2138 /*******************************************************************
2139 inits a SAMR_Q_OPEN_GROUP structure.
2140 ********************************************************************/
2142 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2144 uint32 access_mask, uint32 rid)
2146 DEBUG(5, ("init_samr_q_open_group\n"));
2148 q_c->domain_pol = *hnd;
2149 q_c->access_mask = access_mask;
2150 q_c->rid_group = rid;
2153 /*******************************************************************
2154 reads or writes a structure.
2155 ********************************************************************/
2157 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2158 prs_struct *ps, int depth)
2163 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2169 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2172 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2174 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2180 /*******************************************************************
2181 reads or writes a structure.
2182 ********************************************************************/
2184 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2185 prs_struct *ps, int depth)
2190 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2196 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2199 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2205 /*******************************************************************
2206 inits a GROUP_INFO1 structure.
2207 ********************************************************************/
2209 void init_samr_group_info1(GROUP_INFO1 * gr1,
2210 char *acct_name, char *acct_desc,
2213 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2214 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
2216 DEBUG(5, ("init_samr_group_info1\n"));
2218 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
2220 gr1->unknown_1 = 0x3;
2221 gr1->num_members = num_members;
2223 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
2225 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
2226 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
2229 /*******************************************************************
2230 reads or writes a structure.
2231 ********************************************************************/
2233 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2234 prs_struct *ps, int depth)
2239 prs_debug(ps, depth, desc, "samr_io_group_info1");
2245 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2248 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2250 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2253 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2256 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2257 gr1->hdr_acct_name.buffer, ps, depth))
2260 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2261 gr1->hdr_acct_desc.buffer, ps, depth))
2267 /*******************************************************************
2268 inits a GROUP_INFO3 structure.
2269 ********************************************************************/
2271 void init_samr_group_info3(GROUP_INFO3 *gr3)
2273 DEBUG(5, ("init_samr_group_info3\n"));
2275 gr3->unknown_1 = 0x3;
2278 /*******************************************************************
2279 reads or writes a structure.
2280 ********************************************************************/
2282 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2287 prs_debug(ps, depth, desc, "samr_io_group_info3");
2293 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2299 /*******************************************************************
2300 inits a GROUP_INFO4 structure.
2301 ********************************************************************/
2303 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2305 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2307 DEBUG(5, ("init_samr_group_info4\n"));
2309 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2310 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2313 /*******************************************************************
2314 reads or writes a structure.
2315 ********************************************************************/
2317 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2318 prs_struct *ps, int depth)
2323 prs_debug(ps, depth, desc, "samr_io_group_info4");
2329 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2331 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2332 gr4->hdr_acct_desc.buffer, ps, depth))
2338 /*******************************************************************
2339 reads or writes a structure.
2340 ********************************************************************/
2342 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2343 prs_struct *ps, int depth)
2345 if (UNMARSHALLING(ps))
2346 *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
2351 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2354 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2357 switch ((*ctr)->switch_value1) {
2359 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2363 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2367 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2371 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2378 /*******************************************************************
2379 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2380 ********************************************************************/
2382 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2383 POLICY_HND *pol, char *acct_desc,
2386 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2388 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2392 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2393 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2395 q_e->access_mask = access_mask;
2398 /*******************************************************************
2399 reads or writes a structure.
2400 ********************************************************************/
2402 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2403 prs_struct *ps, int depth)
2408 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2414 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2417 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2419 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2420 q_e->hdr_acct_desc.buffer, ps, depth))
2425 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2431 /*******************************************************************
2432 reads or writes a structure.
2433 ********************************************************************/
2435 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2436 prs_struct *ps, int depth)
2441 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2447 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2450 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2452 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2458 /*******************************************************************
2459 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2460 ********************************************************************/
2462 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2465 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2467 q_c->group_pol = *hnd;
2470 /*******************************************************************
2471 reads or writes a structure.
2472 ********************************************************************/
2474 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2475 prs_struct *ps, int depth)
2480 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2486 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2492 /*******************************************************************
2493 reads or writes a structure.
2494 ********************************************************************/
2496 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2497 prs_struct *ps, int depth)
2502 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2508 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2511 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2517 /*******************************************************************
2518 inits a SAMR_Q_DEL_GROUPMEM structure.
2519 ********************************************************************/
2521 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2522 POLICY_HND *pol, uint32 rid)
2524 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2530 /*******************************************************************
2531 reads or writes a structure.
2532 ********************************************************************/
2534 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2535 prs_struct *ps, int depth)
2540 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2546 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2549 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2555 /*******************************************************************
2556 inits a SAMR_R_DEL_GROUPMEM structure.
2557 ********************************************************************/
2559 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2562 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2564 r_u->status = status;
2567 /*******************************************************************
2568 reads or writes a structure.
2569 ********************************************************************/
2571 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2572 prs_struct *ps, int depth)
2577 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2583 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2589 /*******************************************************************
2590 inits a SAMR_Q_ADD_GROUPMEM structure.
2591 ********************************************************************/
2593 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2594 POLICY_HND *pol, uint32 rid)
2596 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2600 q_e->unknown = 0x0005;
2603 /*******************************************************************
2604 reads or writes a structure.
2605 ********************************************************************/
2607 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2608 prs_struct *ps, int depth)
2613 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2619 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2622 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2624 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2630 /*******************************************************************
2631 inits a SAMR_R_ADD_GROUPMEM structure.
2632 ********************************************************************/
2634 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2637 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2639 r_u->status = status;
2642 /*******************************************************************
2643 reads or writes a structure.
2644 ********************************************************************/
2646 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2647 prs_struct *ps, int depth)
2652 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2658 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2664 /*******************************************************************
2665 inits a SAMR_Q_SET_GROUPINFO structure.
2666 ********************************************************************/
2668 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2669 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2671 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2677 /*******************************************************************
2678 reads or writes a structure.
2679 ********************************************************************/
2681 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2682 prs_struct *ps, int depth)
2687 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2693 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2696 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2702 /*******************************************************************
2703 inits a SAMR_R_SET_GROUPINFO structure.
2704 ********************************************************************/
2706 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2708 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2710 r_u->status = status;
2713 /*******************************************************************
2714 reads or writes a structure.
2715 ********************************************************************/
2717 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2718 prs_struct *ps, int depth)
2723 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2729 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2735 /*******************************************************************
2736 inits a SAMR_Q_QUERY_GROUPINFO structure.
2737 ********************************************************************/
2739 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2740 POLICY_HND *pol, uint16 switch_level)
2742 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2746 q_e->switch_level = switch_level;
2749 /*******************************************************************
2750 reads or writes a structure.
2751 ********************************************************************/
2753 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2754 prs_struct *ps, int depth)
2759 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2765 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2768 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2774 /*******************************************************************
2775 inits a SAMR_R_QUERY_GROUPINFO structure.
2776 ********************************************************************/
2778 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2779 GROUP_INFO_CTR * ctr, NTSTATUS status)
2781 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2783 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2785 r_u->status = status;
2788 /*******************************************************************
2789 reads or writes a structure.
2790 ********************************************************************/
2792 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2793 prs_struct *ps, int depth)
2798 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2804 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2807 if (r_u->ptr != 0) {
2808 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2814 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2820 /*******************************************************************
2821 inits a SAMR_Q_QUERY_GROUPMEM structure.
2822 ********************************************************************/
2824 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2826 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2828 q_c->group_pol = *hnd;
2831 /*******************************************************************
2832 reads or writes a structure.
2833 ********************************************************************/
2835 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2836 prs_struct *ps, int depth)
2841 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2847 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2853 /*******************************************************************
2854 inits a SAMR_R_QUERY_GROUPMEM structure.
2855 ********************************************************************/
2857 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2858 uint32 num_entries, uint32 *rid,
2859 uint32 *attr, NTSTATUS status)
2861 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2863 if (NT_STATUS_IS_OK(status)) {
2865 r_u->num_entries = num_entries;
2867 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2868 r_u->ptr_rids = rid != NULL ? 1 : 0;
2870 r_u->num_rids = num_entries;
2873 r_u->num_attrs = num_entries;
2877 r_u->num_entries = 0;
2880 r_u->status = status;
2883 /*******************************************************************
2884 reads or writes a structure.
2885 ********************************************************************/
2887 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2888 prs_struct *ps, int depth)
2895 if (UNMARSHALLING(ps))
2898 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2904 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2906 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2909 if (r_u->ptr != 0) {
2910 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2912 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2915 if (r_u->ptr_rids != 0) {
2916 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2918 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2919 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2920 if (r_u->rid == NULL)
2924 for (i = 0; i < r_u->num_rids; i++) {
2925 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2930 if (r_u->ptr_attrs != 0) {
2931 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2934 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2935 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2936 if (r_u->attr == NULL)
2940 for (i = 0; i < r_u->num_attrs; i++) {
2941 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2947 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2953 /*******************************************************************
2954 inits a SAMR_Q_QUERY_USERGROUPS structure.
2955 ********************************************************************/
2957 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2960 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2965 /*******************************************************************
2966 reads or writes a structure.
2967 ********************************************************************/
2969 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2970 prs_struct *ps, int depth)
2975 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2981 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2987 /*******************************************************************
2988 inits a SAMR_R_QUERY_USERGROUPS structure.
2989 ********************************************************************/
2991 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2992 uint32 num_gids, DOM_GID * gid,
2995 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2997 if (NT_STATUS_IS_OK(status)) {
2999 r_u->num_entries = num_gids;
3000 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3001 r_u->num_entries2 = num_gids;
3006 r_u->num_entries = 0;
3011 r_u->status = status;
3014 /*******************************************************************
3015 reads or writes a structure.
3016 ********************************************************************/
3018 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3019 prs_struct *ps, int depth)
3025 prs_debug(ps, depth, desc, "samr_io_gids");
3031 if(!prs_uint32("num_gids", ps, depth, num_gids))
3034 if ((*num_gids) != 0) {
3035 if (UNMARSHALLING(ps)) {
3036 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
3039 if ((*gid) == NULL) {
3043 for (i = 0; i < (*num_gids); i++) {
3044 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3052 /*******************************************************************
3053 reads or writes a structure.
3054 ********************************************************************/
3056 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3057 prs_struct *ps, int depth)
3062 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3068 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3071 if (r_u->ptr_0 != 0) {
3072 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3074 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3077 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3078 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3085 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3091 /*******************************************************************
3092 inits a SAMR_Q_ENUM_DOMAINS structure.
3093 ********************************************************************/
3095 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3097 uint32 start_idx, uint32 size)
3099 DEBUG(5, ("init_samr_q_enum_domains\n"));
3103 q_e->start_idx = start_idx;
3104 q_e->max_size = size;
3107 /*******************************************************************
3108 reads or writes a structure.
3109 ********************************************************************/
3111 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3112 prs_struct *ps, int depth)
3117 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3123 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3126 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3128 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3134 /*******************************************************************
3135 inits a SAMR_R_ENUM_DOMAINS structure.
3136 ********************************************************************/
3138 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3139 uint32 next_idx, uint32 num_sam_entries)
3141 DEBUG(5, ("init_samr_r_enum_domains\n"));
3143 r_u->next_idx = next_idx;
3145 if (num_sam_entries != 0) {
3146 r_u->ptr_entries1 = 1;
3147 r_u->ptr_entries2 = 1;
3148 r_u->num_entries2 = num_sam_entries;
3149 r_u->num_entries3 = num_sam_entries;
3151 r_u->num_entries4 = num_sam_entries;
3153 r_u->ptr_entries1 = 0;
3154 r_u->num_entries2 = num_sam_entries;
3155 r_u->ptr_entries2 = 1;
3159 /*******************************************************************
3160 reads or writes a structure.
3161 ********************************************************************/
3163 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3164 prs_struct *ps, int depth)
3171 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3177 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3179 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3182 if (r_u->ptr_entries1 != 0) {
3183 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3185 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3187 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3190 if (UNMARSHALLING(ps)) {
3191 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3192 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3195 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3196 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3197 r_u->num_entries4 = 0;
3198 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3202 for (i = 0; i < r_u->num_entries2; i++) {
3204 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3205 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3209 for (i = 0; i < r_u->num_entries2; i++) {
3211 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3212 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3213 r_u->sam[i].hdr_name.buffer, ps,
3222 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3224 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3230 /*******************************************************************
3231 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3232 ********************************************************************/
3234 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3236 uint32 start_idx, uint32 size)
3238 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3242 q_e->start_idx = start_idx;
3243 q_e->max_size = size;
3246 /*******************************************************************
3247 reads or writes a structure.
3248 ********************************************************************/
3250 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3251 prs_struct *ps, int depth)
3256 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3262 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3265 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3267 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3273 /*******************************************************************
3274 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3275 ********************************************************************/
3277 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3278 uint32 next_idx, uint32 num_sam_entries)
3280 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3282 r_u->next_idx = next_idx;
3284 if (num_sam_entries != 0) {
3285 r_u->ptr_entries1 = 1;
3286 r_u->ptr_entries2 = 1;
3287 r_u->num_entries2 = num_sam_entries;
3288 r_u->num_entries3 = num_sam_entries;
3290 r_u->num_entries4 = num_sam_entries;
3292 r_u->ptr_entries1 = 0;
3293 r_u->num_entries2 = num_sam_entries;
3294 r_u->ptr_entries2 = 1;
3298 /*******************************************************************
3299 reads or writes a structure.
3300 ********************************************************************/
3302 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3303 prs_struct *ps, int depth)
3310 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3316 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3318 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3321 if (r_u->ptr_entries1 != 0) {
3322 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3324 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3326 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3329 if (UNMARSHALLING(ps)) {
3330 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3331 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3334 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3336 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3337 r_u->num_entries4 = 0;
3338 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3342 for (i = 0; i < r_u->num_entries2; i++) {
3343 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3347 for (i = 0; i < r_u->num_entries2; i++) {
3348 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3349 r_u->sam[i].hdr_name.buffer, ps, depth))
3356 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3358 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3364 /*******************************************************************
3365 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3366 ********************************************************************/
3368 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3369 POLICY_HND *pol, uint32 start_idx,
3372 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3376 q_e->start_idx = start_idx;
3377 q_e->max_size = size;
3381 /*******************************************************************
3382 reads or writes a structure.
3383 ********************************************************************/
3385 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3386 prs_struct *ps, int depth)
3391 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3397 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3400 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3402 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3408 /*******************************************************************
3409 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3410 ********************************************************************/
3412 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3414 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3416 r_u->next_idx = next_idx;
3418 if (num_sam_entries != 0) {
3419 r_u->ptr_entries1 = 1;
3420 r_u->ptr_entries2 = 1;
3421 r_u->num_entries2 = num_sam_entries;
3422 r_u->num_entries3 = num_sam_entries;
3424 r_u->num_entries4 = num_sam_entries;
3426 r_u->ptr_entries1 = 0;
3427 r_u->num_entries2 = num_sam_entries;
3428 r_u->ptr_entries2 = 1;
3432 /*******************************************************************
3433 reads or writes a structure.
3434 ********************************************************************/
3436 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3437 prs_struct *ps, int depth)
3444 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3450 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3452 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3455 if (r_u->ptr_entries1 != 0) {
3456 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3458 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3460 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3463 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3464 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3465 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3468 if (r_u->num_entries2 != 0 &&
3469 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3470 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3471 r_u->num_entries4 = 0;
3472 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3476 for (i = 0; i < r_u->num_entries2; i++) {
3477 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3481 for (i = 0; i < r_u->num_entries2; i++) {
3482 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3483 r_u->sam[i].hdr_name.buffer, ps,
3491 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3493 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3499 /*******************************************************************
3500 inits a ALIAS_INFO1 structure.
3501 ********************************************************************/
3503 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3505 int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0;
3506 int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0;
3508 DEBUG(5, ("init_samr_alias_info1\n"));
3510 init_uni_hdr(&al1->hdr_acct_name, acct_len_name);
3511 init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name);
3513 al1->num_member=num_member;
3515 init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc);
3516 init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc);
3519 /*******************************************************************
3520 reads or writes a structure.
3521 ********************************************************************/
3523 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3524 prs_struct *ps, int depth)
3529 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3535 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3537 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3539 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3542 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3543 al1->hdr_acct_name.buffer, ps, depth))
3549 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3550 al1->hdr_acct_desc.buffer, ps, depth))
3556 /*******************************************************************
3557 inits a ALIAS_INFO3 structure.
3558 ********************************************************************/
3560 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3562 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3564 DEBUG(5, ("init_samr_alias_info3\n"));
3566 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3567 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3570 /*******************************************************************
3571 reads or writes a structure.
3572 ********************************************************************/
3574 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
3575 prs_struct *ps, int depth)
3580 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3586 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3588 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3589 al3->hdr_acct_desc.buffer, ps, depth))
3595 /*******************************************************************
3596 reads or writes a structure.
3597 ********************************************************************/
3599 BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr,
3600 prs_struct *ps, int depth)
3605 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3608 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3610 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3613 switch (ctr->switch_value1) {
3615 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3619 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3623 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3630 /*******************************************************************
3631 inits a SAMR_Q_QUERY_ALIASINFO structure.
3632 ********************************************************************/
3634 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3635 POLICY_HND *pol, uint16 switch_level)
3637 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3640 q_e->switch_level = switch_level;
3643 /*******************************************************************
3644 reads or writes a structure.
3645 ********************************************************************/
3647 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3648 prs_struct *ps, int depth)
3653 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3659 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3662 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3668 /*******************************************************************
3669 inits a SAMR_R_QUERY_ALIASINFO structure.
3670 ********************************************************************/
3672 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3673 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3675 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3677 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3679 r_u->status = status;
3682 /*******************************************************************
3683 reads or writes a structure.
3684 ********************************************************************/
3686 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3687 prs_struct *ps, int depth)
3692 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3698 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3701 if (r_u->ptr != 0) {
3702 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3708 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3714 /*******************************************************************
3715 inits a SAMR_Q_SET_ALIASINFO structure.
3716 ********************************************************************/
3718 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3719 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3721 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3723 q_u->alias_pol = *hnd;
3727 /*******************************************************************
3728 reads or writes a structure.
3729 ********************************************************************/
3731 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3732 prs_struct *ps, int depth)
3737 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3743 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3745 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3751 /*******************************************************************
3752 reads or writes a structure.
3753 ********************************************************************/
3755 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3756 prs_struct *ps, int depth)
3761 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3766 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3772 /*******************************************************************
3773 inits a SAMR_Q_QUERY_USERALIASES structure.
3774 ********************************************************************/
3776 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3779 uint32 *ptr_sid, DOM_SID2 * sid)
3781 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3785 q_u->num_sids1 = num_sids;
3787 q_u->num_sids2 = num_sids;
3789 q_u->ptr_sid = ptr_sid;
3793 /*******************************************************************
3794 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3795 ********************************************************************/
3797 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3798 prs_struct *ps, int depth)
3806 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3812 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3815 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3817 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3823 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3826 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3827 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3828 if (q_u->ptr_sid == NULL)
3831 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3832 if (q_u->sid == NULL)
3836 for (i = 0; i < q_u->num_sids2; i++) {
3837 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3838 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3842 for (i = 0; i < q_u->num_sids2; i++) {
3843 if (q_u->ptr_sid[i] != 0) {
3844 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3845 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3853 /*******************************************************************
3854 inits a SAMR_R_QUERY_USERALIASES structure.
3855 ********************************************************************/
3857 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3858 uint32 num_rids, uint32 *rid,
3861 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3863 if (NT_STATUS_IS_OK(status)) {
3864 r_u->num_entries = num_rids;
3866 r_u->num_entries2 = num_rids;
3870 r_u->num_entries = 0;
3872 r_u->num_entries2 = 0;
3875 r_u->status = status;
3878 /*******************************************************************
3879 reads or writes a structure.
3880 ********************************************************************/
3882 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3883 prs_struct *ps, int depth)
3890 prs_debug(ps, depth, desc, "samr_io_rids");
3896 if(!prs_uint32("num_rids", ps, depth, num_rids))
3899 if ((*num_rids) != 0) {
3900 if (UNMARSHALLING(ps)) {
3902 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3907 for (i = 0; i < (*num_rids); i++) {
3908 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3909 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3917 /*******************************************************************
3918 reads or writes a structure.
3919 ********************************************************************/
3921 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3922 prs_struct *ps, int depth)
3927 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3933 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3935 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3938 if (r_u->ptr != 0) {
3939 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3945 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3951 /*******************************************************************
3952 inits a SAMR_Q_OPEN_ALIAS structure.
3953 ********************************************************************/
3955 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3956 uint32 access_mask, uint32 rid)
3958 DEBUG(5, ("init_samr_q_open_alias\n"));
3960 q_u->dom_pol = *pol;
3961 q_u->access_mask = access_mask;
3962 q_u->rid_alias = rid;
3965 /*******************************************************************
3966 reads or writes a structure.
3967 ********************************************************************/
3969 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3970 prs_struct *ps, int depth)
3975 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3981 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3984 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3986 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3992 /*******************************************************************
3993 reads or writes a structure.
3994 ********************************************************************/
3996 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
3997 prs_struct *ps, int depth)
4002 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4008 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4011 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4017 /*******************************************************************
4018 inits a SAMR_Q_LOOKUP_RIDS structure.
4019 ********************************************************************/
4021 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4022 POLICY_HND *pol, uint32 flags,
4023 uint32 num_rids, uint32 *rid)
4025 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4029 q_u->num_rids1 = num_rids;
4032 q_u->num_rids2 = num_rids;
4033 q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0]));
4034 if (q_u->rid == NULL) {
4038 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4042 /*******************************************************************
4043 reads or writes a structure.
4044 ********************************************************************/
4046 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4047 prs_struct *ps, int depth)
4055 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4058 if (UNMARSHALLING(ps))
4064 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4067 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4069 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4071 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4073 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4076 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4077 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
4078 if (q_u->rid == NULL)
4082 for (i = 0; i < q_u->num_rids2; i++) {
4083 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4084 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4091 /*******************************************************************
4092 inits a SAMR_R_LOOKUP_RIDS structure.
4093 ********************************************************************/
4095 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4096 uint32 num_names, UNIHDR * hdr_name,
4097 UNISTR2 *uni_name, uint32 *type)
4099 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4101 r_u->hdr_name = NULL;
4102 r_u->uni_name = NULL;
4105 if (num_names != 0) {
4106 r_u->num_names1 = num_names;
4108 r_u->num_names2 = num_names;
4110 r_u->num_types1 = num_names;
4112 r_u->num_types2 = num_names;
4114 r_u->hdr_name = hdr_name;
4115 r_u->uni_name = uni_name;
4118 r_u->num_names1 = num_names;
4120 r_u->num_names2 = num_names;
4122 r_u->num_types1 = num_names;
4124 r_u->num_types2 = num_names;
4128 /*******************************************************************
4129 reads or writes a structure.
4130 ********************************************************************/
4132 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4133 prs_struct *ps, int depth)
4140 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4146 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4148 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4151 if (r_u->ptr_names != 0) {
4153 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4157 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4158 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
4159 if (r_u->hdr_name == NULL)
4162 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
4163 if (r_u->uni_name == NULL)
4167 for (i = 0; i < r_u->num_names2; i++) {
4168 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4169 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4172 for (i = 0; i < r_u->num_names2; i++) {
4173 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4174 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4182 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4184 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4187 if (r_u->ptr_types != 0) {
4189 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4192 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4193 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
4194 if (r_u->type == NULL)
4198 for (i = 0; i < r_u->num_types2; i++) {
4199 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4200 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4205 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4211 /*******************************************************************
4212 inits a SAMR_Q_OPEN_ALIAS structure.
4213 ********************************************************************/
4215 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4217 DEBUG(5, ("init_samr_q_delete_alias\n"));
4219 q_u->alias_pol = *hnd;
4222 /*******************************************************************
4223 reads or writes a structure.
4224 ********************************************************************/
4226 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4227 prs_struct *ps, int depth)
4232 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4238 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4244 /*******************************************************************
4245 reads or writes a structure.
4246 ********************************************************************/
4248 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4249 prs_struct *ps, int depth)
4254 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4260 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4262 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4268 /*******************************************************************
4269 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4270 ********************************************************************/
4272 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4273 POLICY_HND *hnd, char *acct_desc)
4275 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
4277 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4279 q_u->dom_pol = *hnd;
4281 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
4282 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
4284 q_u->access_mask = 0x001f000f;
4287 /*******************************************************************
4288 reads or writes a structure.
4289 ********************************************************************/
4291 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4292 prs_struct *ps, int depth)
4297 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4303 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4306 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4308 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4309 q_u->hdr_acct_desc.buffer, ps, depth))
4314 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4320 /*******************************************************************
4321 reads or writes a structure.
4322 ********************************************************************/
4324 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4325 prs_struct *ps, int depth)
4330 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4336 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4339 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4342 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4348 /*******************************************************************
4349 inits a SAMR_Q_ADD_ALIASMEM structure.
4350 ********************************************************************/
4352 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4355 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4357 q_u->alias_pol = *hnd;
4358 init_dom_sid2(&q_u->sid, sid);
4361 /*******************************************************************
4362 reads or writes a structure.
4363 ********************************************************************/
4365 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4366 prs_struct *ps, int depth)
4371 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4377 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4379 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4385 /*******************************************************************
4386 reads or writes a structure.
4387 ********************************************************************/
4389 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4390 prs_struct *ps, int depth)
4395 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4401 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4407 /*******************************************************************
4408 inits a SAMR_Q_DEL_ALIASMEM structure.
4409 ********************************************************************/
4411 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4414 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4416 q_u->alias_pol = *hnd;
4417 init_dom_sid2(&q_u->sid, sid);
4420 /*******************************************************************
4421 reads or writes a structure.
4422 ********************************************************************/
4424 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4425 prs_struct *ps, int depth)
4430 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4436 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4438 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4444 /*******************************************************************
4445 reads or writes a structure.
4446 ********************************************************************/
4448 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4449 prs_struct *ps, int depth)
4454 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4460 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4466 /*******************************************************************
4467 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4468 ********************************************************************/
4470 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4473 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4475 q_c->alias_pol = *hnd;
4478 /*******************************************************************
4479 reads or writes a structure.
4480 ********************************************************************/
4482 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4483 prs_struct *ps, int depth)
4488 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4494 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4500 /*******************************************************************
4501 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4502 ********************************************************************/
4504 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4507 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4509 r_u->status = status;
4512 /*******************************************************************
4513 reads or writes a structure.
4514 ********************************************************************/
4516 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4517 prs_struct *ps, int depth)
4522 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4528 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4534 /*******************************************************************
4535 inits a SAMR_Q_QUERY_ALIASMEM structure.
4536 ********************************************************************/
4538 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4541 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4543 q_c->alias_pol = *hnd;
4546 /*******************************************************************
4547 reads or writes a structure.
4548 ********************************************************************/
4550 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4551 prs_struct *ps, int depth)
4556 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4562 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4568 /*******************************************************************
4569 inits a SAMR_R_QUERY_ALIASMEM structure.
4570 ********************************************************************/
4572 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4573 uint32 num_sids, DOM_SID2 * sid,
4576 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4578 if (NT_STATUS_IS_OK(status)) {
4579 r_u->num_sids = num_sids;
4580 r_u->ptr = (num_sids != 0) ? 1 : 0;
4581 r_u->num_sids1 = num_sids;
4589 r_u->status = status;
4592 /*******************************************************************
4593 reads or writes a structure.
4594 ********************************************************************/
4596 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4597 prs_struct *ps, int depth)
4604 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4610 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4612 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4615 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4616 uint32 *ptr_sid = NULL;
4618 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4621 ptr_sid = talloc(ps->mem_ctx, sizeof(uint32) * r_u->num_sids1);
4626 for (i = 0; i < r_u->num_sids1; i++) {
4628 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4632 if (UNMARSHALLING(ps)) {
4633 r_u->sid = talloc(ps->mem_ctx, r_u->num_sids1 * sizeof(DOM_SID2));
4636 for (i = 0; i < r_u->num_sids1; i++) {
4637 if (ptr_sid[i] != 0) {
4638 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4646 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4652 /*******************************************************************
4653 inits a SAMR_Q_LOOKUP_NAMES structure.
4654 ********************************************************************/
4656 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4657 POLICY_HND *pol, uint32 flags,
4658 uint32 num_names, const char **name)
4662 DEBUG(5, ("init_samr_q_lookup_names\n"));
4666 q_u->num_names1 = num_names;
4669 q_u->num_names2 = num_names;
4671 if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR))))
4672 return NT_STATUS_NO_MEMORY;
4674 if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2))))
4675 return NT_STATUS_NO_MEMORY;
4677 for (i = 0; i < num_names; i++) {
4678 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4679 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4680 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4683 return NT_STATUS_OK;
4686 /*******************************************************************
4687 reads or writes a structure.
4688 ********************************************************************/
4690 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4691 prs_struct *ps, int depth)
4698 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4701 if (UNMARSHALLING(ps))
4707 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4710 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4712 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4714 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4716 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4719 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4720 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4722 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4724 if (!q_u->hdr_name || !q_u->uni_name)
4728 for (i = 0; i < q_u->num_names2; i++) {
4729 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4733 for (i = 0; i < q_u->num_names2; i++) {
4734 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4741 /*******************************************************************
4742 inits a SAMR_R_LOOKUP_NAMES structure.
4743 ********************************************************************/
4745 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4747 uint32 *rid, uint32 *type,
4750 DEBUG(5, ("init_samr_r_lookup_names\n"));
4752 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4755 r_u->num_types1 = num_rids;
4757 r_u->num_types2 = num_rids;
4759 r_u->num_rids1 = num_rids;
4761 r_u->num_rids2 = num_rids;
4763 if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4764 return NT_STATUS_NO_MEMORY;
4765 if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4766 return NT_STATUS_NO_MEMORY;
4768 if (!r_u->rids || !r_u->types)
4771 for (i = 0; i < num_rids; i++) {
4772 r_u->rids[i] = rid[i];
4773 r_u->types[i] = type[i];
4778 r_u->num_types1 = 0;
4780 r_u->num_types2 = 0;
4790 r_u->status = status;
4792 return NT_STATUS_OK;
4795 /*******************************************************************
4796 reads or writes a structure.
4797 ********************************************************************/
4799 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4800 prs_struct *ps, int depth)
4808 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4811 if (UNMARSHALLING(ps))
4817 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4819 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4822 if (r_u->ptr_rids != 0) {
4823 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4826 if (r_u->num_rids2 != r_u->num_rids1) {
4831 if (UNMARSHALLING(ps))
4832 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4835 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4839 for (i = 0; i < r_u->num_rids2; i++) {
4840 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4841 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4846 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4848 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4851 if (r_u->ptr_types != 0) {
4852 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4855 if (r_u->num_types2 != r_u->num_types1) {
4860 if (UNMARSHALLING(ps))
4861 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4864 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4868 for (i = 0; i < r_u->num_types2; i++) {
4869 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4870 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4875 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4881 /*******************************************************************
4882 inits a SAMR_Q_DELETE_DOM_USER structure.
4883 ********************************************************************/
4885 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4888 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4890 q_c->user_pol = *hnd;
4893 /*******************************************************************
4894 reads or writes a structure.
4895 ********************************************************************/
4897 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4898 prs_struct *ps, int depth)
4903 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4909 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4915 /*******************************************************************
4916 reads or writes a structure.
4917 ********************************************************************/
4919 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4920 prs_struct *ps, int depth)
4925 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4931 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4933 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4939 /*******************************************************************
4940 reads or writes a structure.
4941 ********************************************************************/
4943 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4945 uint32 access_mask, uint32 rid)
4947 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4949 q_u->domain_pol = *pol;
4950 q_u->access_mask = access_mask;
4951 q_u->user_rid = rid;
4954 /*******************************************************************
4955 reads or writes a structure.
4956 ********************************************************************/
4958 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4959 prs_struct *ps, int depth)
4964 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4970 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4973 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4975 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4981 /*******************************************************************
4982 reads or writes a structure.
4983 ********************************************************************/
4985 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4986 prs_struct *ps, int depth)
4991 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4997 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5000 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5007 /*******************************************************************
5008 reads or writes a structure.
5009 ********************************************************************/
5011 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5014 uint32 acb_info, uint32 access_mask)
5017 len_name = strlen(name);
5019 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5021 q_u->domain_pol = *pol;
5023 init_uni_hdr(&q_u->hdr_name, len_name);
5024 init_unistr2(&q_u->uni_name, name, len_name);
5026 q_u->acb_info = acb_info;
5027 q_u->access_mask = access_mask;
5030 /*******************************************************************
5031 reads or writes a structure.
5032 ********************************************************************/
5034 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5035 prs_struct *ps, int depth)
5040 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5046 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5049 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5051 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5056 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5058 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5064 /*******************************************************************
5065 reads or writes a structure.
5066 ********************************************************************/
5068 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5069 prs_struct *ps, int depth)
5074 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5080 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5083 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5085 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5087 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5093 /*******************************************************************
5094 inits a SAMR_Q_QUERY_USERINFO structure.
5095 ********************************************************************/
5097 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5098 POLICY_HND *hnd, uint16 switch_value)
5100 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5103 q_u->switch_value = switch_value;
5106 /*******************************************************************
5107 reads or writes a structure.
5108 ********************************************************************/
5110 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5111 prs_struct *ps, int depth)
5116 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5122 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5125 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5131 /*******************************************************************
5132 reads or writes a LOGON_HRS structure.
5133 ********************************************************************/
5135 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5136 prs_struct *ps, int depth)
5141 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5147 if(!prs_uint32("len ", ps, depth, &hrs->len))
5150 if (hrs->len > sizeof(hrs->hours)) {
5151 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5152 hrs->len = sizeof(hrs->hours);
5155 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5161 /*******************************************************************
5162 inits a SAM_USER_INFO_12 structure.
5163 ********************************************************************/
5165 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5166 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5168 DEBUG(5, ("init_sam_user_info12\n"));
5170 usr->lm_pwd_active =
5171 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5172 usr->nt_pwd_active =
5173 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5176 /*******************************************************************
5177 reads or writes a structure.
5178 ********************************************************************/
5180 static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u,
5181 prs_struct *ps, int depth)
5186 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5192 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5194 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5197 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5199 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5205 /*******************************************************************
5206 inits a SAM_USER_INFO_10 structure.
5207 ********************************************************************/
5209 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5211 DEBUG(5, ("init_sam_user_info10\n"));
5213 usr->acb_info = acb_info;
5216 /*******************************************************************
5217 reads or writes a structure.
5218 ********************************************************************/
5220 static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr,
5221 prs_struct *ps, int depth)
5226 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5232 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5238 /*******************************************************************
5239 inits a SAM_USER_INFO_11 structure.
5240 ********************************************************************/
5242 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5245 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5249 DEBUG(5, ("init_sam_user_info11\n"));
5251 len_mach_acct = strlen(mach_acct);
5253 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
5254 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5256 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
5257 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5259 usr->ptr_1 = 1; /* pointer */
5260 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5261 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5263 usr->ptr_2 = 1; /* pointer */
5264 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5266 usr->ptr_3 = 1; /* pointer */
5267 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5269 usr->rid_user = rid_user;
5270 usr->rid_group = rid_group;
5272 usr->acct_ctrl = acct_ctrl;
5273 usr->unknown_3 = 0x0000;
5275 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5276 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5278 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5279 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5281 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
5284 /*******************************************************************
5285 reads or writes a structure.
5286 ********************************************************************/
5288 static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr,
5289 prs_struct *ps, int depth)
5294 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5300 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5303 if(!smb_io_time("time", &usr->expiry, ps, depth))
5306 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5309 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5312 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5315 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5317 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5320 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5323 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5325 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5328 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5330 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5333 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5335 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5337 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5339 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5341 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5343 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5346 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5349 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5352 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5358 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5364 /*************************************************************************
5367 unknown_3 = 0x09f8 27fa
5368 unknown_5 = 0x0001 0000
5369 unknown_6 = 0x0000 04ec
5371 *************************************************************************/
5373 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5375 DEBUG(10, ("init_sam_user_info24:\n"));
5376 memcpy(usr->pass, newpass, sizeof(usr->pass));
5377 usr->pw_len = pw_len;
5380 /*******************************************************************
5381 reads or writes a structure.
5382 ********************************************************************/
5384 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5385 prs_struct *ps, int depth)
5390 prs_debug(ps, depth, desc, "sam_io_user_info24");
5396 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5400 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5401 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5410 /*************************************************************************
5411 init_sam_user_info23
5413 unknown_3 = 0x09f8 27fa
5414 unknown_6 = 0x0000 04ec
5416 *************************************************************************/
5418 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5419 NTTIME * logoff_time, /* all zeros */
5420 NTTIME * kickoff_time, /* all zeros */
5421 NTTIME * pass_last_set_time, /* all zeros */
5422 NTTIME * pass_can_change_time, /* all zeros */
5423 NTTIME * pass_must_change_time, /* all zeros */
5434 uint32 user_rid, /* 0x0000 0000 */
5440 uint16 bad_password_count,
5442 char newpass[516], uint32 unknown_6)
5444 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5445 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5446 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5447 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5448 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5449 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5450 int len_description = desc != NULL ? desc->uni_str_len : 0;
5451 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5452 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5453 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5455 usr->logon_time = *logon_time; /* all zeros */
5456 usr->logoff_time = *logoff_time; /* all zeros */
5457 usr->kickoff_time = *kickoff_time; /* all zeros */
5458 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5459 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5460 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5462 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5463 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5464 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5465 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5466 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5467 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5468 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5469 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5470 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5471 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5473 ZERO_STRUCT(usr->nt_pwd);
5474 ZERO_STRUCT(usr->lm_pwd);
5476 usr->user_rid = user_rid; /* 0x0000 0000 */
5477 usr->group_rid = group_rid;
5478 usr->acb_info = acb_info;
5479 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5481 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5482 usr->ptr_logon_hrs = hrs ? 1 : 0;
5484 if (nt_time_is_zero(pass_must_change_time)) {
5485 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5487 usr->passmustchange=0;
5490 ZERO_STRUCT(usr->padding1);
5491 ZERO_STRUCT(usr->padding2);
5493 usr->bad_password_count = bad_password_count;
5494 usr->logon_count = logon_count;
5496 memcpy(usr->pass, newpass, sizeof(usr->pass));
5498 copy_unistr2(&usr->uni_user_name, user_name);
5499 copy_unistr2(&usr->uni_full_name, full_name);
5500 copy_unistr2(&usr->uni_home_dir, home_dir);
5501 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5502 copy_unistr2(&usr->uni_logon_script, log_scr);
5503 copy_unistr2(&usr->uni_profile_path, prof_path);
5504 copy_unistr2(&usr->uni_acct_desc, desc);
5505 copy_unistr2(&usr->uni_workstations, wkstas);
5506 copy_unistr2(&usr->uni_unknown_str, unk_str);
5507 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5509 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5512 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5515 /*************************************************************************
5516 init_sam_user_info23
5518 unknown_3 = 0x09f8 27fa
5519 unknown_6 = 0x0000 04ec
5521 *************************************************************************/
5523 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5524 NTTIME * logoff_time, /* all zeros */
5525 NTTIME * kickoff_time, /* all zeros */
5526 NTTIME * pass_last_set_time, /* all zeros */
5527 NTTIME * pass_can_change_time, /* all zeros */
5528 NTTIME * pass_must_change_time, /* all zeros */
5529 char *user_name, /* NULL */
5531 char *home_dir, char *dir_drive, char *log_scr,
5532 char *prof_path, const char *desc, char *wkstas,
5533 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5534 uint32 group_rid, uint32 acb_info,
5535 uint32 unknown_3, uint16 logon_divs,
5536 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5537 char newpass[516], uint32 unknown_6)
5539 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5540 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5541 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5542 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5543 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5544 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5545 int len_description = desc != NULL ? strlen(desc) : 0;
5546 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5547 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5548 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5550 usr->logon_time = *logon_time; /* all zeros */
5551 usr->logoff_time = *logoff_time; /* all zeros */
5552 usr->kickoff_time = *kickoff_time; /* all zeros */
5553 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5554 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5555 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5557 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5558 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5559 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5560 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5561 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5562 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5563 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5564 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5565 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5566 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5568 ZERO_STRUCT(usr->nt_pwd);
5569 ZERO_STRUCT(usr->lm_pwd);
5571 usr->user_rid = user_rid; /* 0x0000 0000 */
5572 usr->group_rid = group_rid;
5573 usr->acb_info = acb_info;
5574 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5576 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5577 usr->ptr_logon_hrs = hrs ? 1 : 0;
5579 if (nt_time_is_zero(pass_must_change_time)) {
5580 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5582 usr->passmustchange=0;
5585 ZERO_STRUCT(usr->padding1);
5586 ZERO_STRUCT(usr->padding2);
5588 usr->bad_password_count = bad_password_count;
5589 usr->logon_count = logon_count;
5591 memcpy(usr->pass, newpass, sizeof(usr->pass));
5593 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5594 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5595 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5596 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5597 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5598 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5599 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5600 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5601 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5602 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5604 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5607 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5610 /*******************************************************************
5611 reads or writes a structure.
5612 ********************************************************************/
5614 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5615 prs_struct *ps, int depth)
5620 prs_debug(ps, depth, desc, "sam_io_user_info23");
5626 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5628 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5630 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5632 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5634 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5636 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5639 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5641 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5643 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5645 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5647 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5649 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5651 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5653 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5655 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5657 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5660 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5662 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5665 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5667 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5669 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5672 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5674 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5678 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5681 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5683 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5686 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5688 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5690 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5694 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5697 /* here begins pointed-to data */
5699 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5702 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5705 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5708 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5711 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5714 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5717 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5720 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5723 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5726 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5729 /* ok, this is only guess-work (as usual) */
5730 if (usr->ptr_logon_hrs) {
5731 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5733 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5735 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5737 } else if (UNMARSHALLING(ps)) {
5745 /*******************************************************************
5746 reads or writes a structure.
5747 NB. This structure is *definately* incorrect. It's my best guess
5748 currently for W2K SP2. The password field is encrypted in a different
5749 way than normal... And there are definately other problems. JRA.
5750 ********************************************************************/
5752 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5757 prs_debug(ps, depth, desc, "sam_io_user_info25");
5763 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5765 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5767 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5769 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5771 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5773 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5776 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5778 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5780 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5782 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5784 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5786 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5788 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5790 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5792 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5794 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5797 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5799 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5802 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5804 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5806 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5809 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5812 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5815 /* here begins pointed-to data */
5817 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5820 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5823 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5826 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5829 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5832 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5835 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5838 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5841 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5844 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5847 #if 0 /* JRA - unknown... */
5848 /* ok, this is only guess-work (as usual) */
5849 if (usr->ptr_logon_hrs) {
5850 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5852 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5854 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5856 } else if (UNMARSHALLING(ps)) {
5866 /*************************************************************************
5867 init_sam_user_info21W
5869 unknown_3 = 0x00ff ffff
5870 unknown_6 = 0x0000 04ec
5872 *************************************************************************/
5874 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5875 NTTIME * logon_time,
5876 NTTIME * logoff_time,
5877 NTTIME * kickoff_time,
5878 NTTIME * pass_last_set_time,
5879 NTTIME * pass_can_change_time,
5880 NTTIME * pass_must_change_time,
5899 uint16 bad_password_count,
5903 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5904 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5905 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5906 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5907 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5908 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5909 int len_description = desc != NULL ? desc->uni_str_len : 0;
5910 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5911 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5912 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5914 usr->logon_time = *logon_time;
5915 usr->logoff_time = *logoff_time;
5916 usr->kickoff_time = *kickoff_time;
5917 usr->pass_last_set_time = *pass_last_set_time;
5918 usr->pass_can_change_time = *pass_can_change_time;
5919 usr->pass_must_change_time = *pass_must_change_time;
5921 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5922 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5923 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5924 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5925 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5926 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5927 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5928 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5929 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5930 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5932 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5933 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5935 usr->user_rid = user_rid;
5936 usr->group_rid = group_rid;
5937 usr->acb_info = acb_info;
5938 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5940 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5941 usr->ptr_logon_hrs = hrs ? 1 : 0;
5942 usr->bad_password_count = bad_password_count;
5943 usr->logon_count = logon_count;
5945 if (nt_time_is_zero(pass_must_change_time)) {
5946 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5948 usr->passmustchange=0;
5951 ZERO_STRUCT(usr->padding1);
5952 ZERO_STRUCT(usr->padding2);
5954 copy_unistr2(&usr->uni_user_name, user_name);
5955 copy_unistr2(&usr->uni_full_name, full_name);
5956 copy_unistr2(&usr->uni_home_dir, home_dir);
5957 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5958 copy_unistr2(&usr->uni_logon_script, log_scr);
5959 copy_unistr2(&usr->uni_profile_path, prof_path);
5960 copy_unistr2(&usr->uni_acct_desc, desc);
5961 copy_unistr2(&usr->uni_workstations, wkstas);
5962 copy_unistr2(&usr->uni_unknown_str, unk_str);
5963 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5965 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5968 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5971 /*************************************************************************
5972 init_sam_user_info21
5974 unknown_3 = 0x00ff ffff
5975 unknown_6 = 0x0000 04ec
5977 *************************************************************************/
5979 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5981 NTTIME logon_time, logoff_time, kickoff_time,
5982 pass_last_set_time, pass_can_change_time,
5983 pass_must_change_time;
5985 int len_user_name, len_full_name, len_home_dir,
5986 len_dir_drive, len_logon_script, len_profile_path,
5987 len_description, len_workstations, len_unknown_str,
5990 const char* user_name = pdb_get_username(pw);
5991 const char* full_name = pdb_get_fullname(pw);
5992 const char* home_dir = pdb_get_homedir(pw);
5993 const char* dir_drive = pdb_get_dir_drive(pw);
5994 const char* logon_script = pdb_get_logon_script(pw);
5995 const char* profile_path = pdb_get_profile_path(pw);
5996 const char* description = pdb_get_acct_desc(pw);
5997 const char* workstations = pdb_get_workstations(pw);
5998 const char* munged_dial = pdb_get_munged_dial(pw);
6001 const DOM_SID *user_sid;
6004 const DOM_SID *group_sid;
6006 len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
6007 len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
6008 len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
6009 len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
6010 len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
6011 len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
6012 len_description = description != NULL ? strlen(description )+1 : 0;
6013 len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
6014 len_unknown_str = 0;
6015 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6018 /* Create NTTIME structs */
6019 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6020 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6021 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6022 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6023 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6024 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6026 /* structure assignment */
6027 usr->logon_time = logon_time;
6028 usr->logoff_time = logoff_time;
6029 usr->kickoff_time = kickoff_time;
6030 usr->pass_last_set_time = pass_last_set_time;
6031 usr->pass_can_change_time = pass_can_change_time;
6032 usr->pass_must_change_time = pass_must_change_time;
6034 init_uni_hdr(&usr->hdr_user_name, len_user_name);
6035 init_uni_hdr(&usr->hdr_full_name, len_full_name);
6036 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
6037 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
6038 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
6039 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
6040 init_uni_hdr(&usr->hdr_acct_desc, len_description);
6041 init_uni_hdr(&usr->hdr_workstations, len_workstations);
6042 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
6043 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6045 ZERO_STRUCT(usr->nt_pwd);
6046 ZERO_STRUCT(usr->lm_pwd);
6048 user_sid = pdb_get_user_sid(pw);
6050 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6051 fstring user_sid_string;
6052 fstring domain_sid_string;
6053 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6054 "the domain sid %s. Failing operation.\n",
6056 sid_to_string(user_sid_string, user_sid),
6057 sid_to_string(domain_sid_string, domain_sid)));
6058 return NT_STATUS_UNSUCCESSFUL;
6061 group_sid = pdb_get_group_sid(pw);
6063 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6064 fstring group_sid_string;
6065 fstring domain_sid_string;
6066 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6067 "which conflicts with the domain sid %s. Failing operation.\n",
6069 sid_to_string(group_sid_string, group_sid),
6070 sid_to_string(domain_sid_string, domain_sid)));
6071 return NT_STATUS_UNSUCCESSFUL;
6074 usr->user_rid = user_rid;
6075 usr->group_rid = group_rid;
6076 usr->acb_info = pdb_get_acct_ctrl(pw);
6079 Look at a user on a real NT4 PDC with usrmgr, press
6080 'ok'. Then you will see that unknown_3 is set to
6081 0x08f827fa. Look at the user immediately after that again,
6082 and you will see that 0x00fffff is returned. This solves
6083 the problem that you get access denied after having looked
6087 usr->unknown_3 = 0x00ffffff;
6089 usr->logon_divs = pdb_get_logon_divs(pw);
6090 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6091 usr->bad_password_count = pdb_get_bad_password_count(pw);
6092 usr->logon_count = pdb_get_logon_count(pw);
6094 if (pdb_get_pass_must_change_time(pw) == 0) {
6095 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6097 usr->passmustchange=0;
6100 ZERO_STRUCT(usr->padding1);
6101 ZERO_STRUCT(usr->padding2);
6103 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
6104 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
6105 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
6106 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
6107 init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
6108 init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
6109 init_unistr2(&usr->uni_acct_desc, description, len_description);
6110 init_unistr2(&usr->uni_workstations, workstations, len_workstations);
6111 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
6112 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6114 usr->unknown_6 = pdb_get_unknown_6(pw);
6117 if (pdb_get_hours(pw)) {
6118 usr->logon_hrs.len = pdb_get_hours_len(pw);
6119 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6121 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6123 return NT_STATUS_OK;
6126 /*******************************************************************
6127 reads or writes a structure.
6128 ********************************************************************/
6130 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6131 prs_struct *ps, int depth)
6136 prs_debug(ps, depth, desc, "sam_io_user_info21");
6142 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6144 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6146 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6148 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6150 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6152 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6155 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6157 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6159 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6161 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6163 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6165 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6167 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6169 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6171 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6173 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6176 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6178 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6181 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6183 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6185 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6188 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
6190 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6194 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6197 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6199 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6202 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6204 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6206 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6209 /* here begins pointed-to data */
6211 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6213 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6215 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6217 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6219 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6221 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6223 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6225 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6227 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6229 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6232 /* ok, this is only guess-work (as usual) */
6233 if (usr->ptr_logon_hrs) {
6236 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6238 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6240 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6242 } else if (UNMARSHALLING(ps)) {
6250 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6252 int len_munged_dial;
6253 const char* munged_dial = pdb_get_munged_dial(pw);
6255 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6256 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6257 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6261 /*******************************************************************
6262 reads or writes a structure.
6263 ********************************************************************/
6265 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6266 prs_struct *ps, int depth)
6271 prs_debug(ps, depth, desc, "sam_io_user_info20");
6277 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6280 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6286 /*******************************************************************
6287 inits a SAM_USERINFO_CTR structure.
6288 ********************************************************************/
6290 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6291 uint16 switch_value,
6292 SAM_USER_INFO_21 * usr)
6294 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6296 ctr->switch_value = switch_value;
6297 ctr->info.id = NULL;
6299 switch (switch_value) {
6301 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
6302 if (ctr->info.id10 == NULL)
6303 return NT_STATUS_NO_MEMORY;
6305 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6308 /* whoops - got this wrong. i think. or don't understand what's happening. */
6312 info = (void *)&id11;
6314 expire.low = 0xffffffff;
6315 expire.high = 0x7fffffff;
6317 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
6318 init_sam_user_info11(ctr->info.id11, &expire,
6319 "BROOKFIELDS$", /* name */
6320 0x03ef, /* user rid */
6321 0x201, /* group rid */
6322 0x0080); /* acb info */
6328 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
6329 if (ctr->info.id12 == NULL)
6330 return NT_STATUS_NO_MEMORY;
6332 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6336 SAM_USER_INFO_21 *cusr;
6337 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
6338 ctr->info.id21 = cusr;
6339 if (ctr->info.id21 == NULL)
6340 return NT_STATUS_NO_MEMORY;
6341 memcpy(cusr, usr, sizeof(*usr));
6342 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6343 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6347 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6348 return NT_STATUS_INVALID_INFO_CLASS;
6351 return NT_STATUS_OK;
6354 /*******************************************************************
6355 inits a SAM_USERINFO_CTR structure.
6356 ********************************************************************/
6358 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
6359 uint16 switch_value, void *info)
6361 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6363 ctr->switch_value = switch_value;
6364 ctr->info.id = info;
6366 switch (switch_value) {
6368 SamOEMhash(ctr->info.id24->pass, sess_key, 516);
6369 dump_data(100, (char *)sess_key, 16);
6370 dump_data(100, (char *)ctr->info.id24->pass, 516);
6373 SamOEMhash(ctr->info.id23->pass, sess_key, 516);
6374 dump_data(100, (char *)sess_key, 16);
6375 dump_data(100, (char *)ctr->info.id23->pass, 516);
6378 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6382 /*******************************************************************
6383 reads or writes a structure.
6384 ********************************************************************/
6386 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6387 prs_struct *ps, int depth)
6390 SAM_USERINFO_CTR *ctr;
6392 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6395 if (UNMARSHALLING(ps)) {
6396 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
6404 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6406 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6413 switch (ctr->switch_value) {
6415 if (UNMARSHALLING(ps))
6416 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
6417 if (ctr->info.id10 == NULL) {
6418 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6421 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6424 if (UNMARSHALLING(ps))
6425 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
6427 if (ctr->info.id11 == NULL) {
6428 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6431 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6434 if (UNMARSHALLING(ps))
6435 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
6437 if (ctr->info.id12 == NULL) {
6438 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6441 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6444 if (UNMARSHALLING(ps))
6445 ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20));
6447 if (ctr->info.id20 == NULL) {
6448 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6451 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6454 if (UNMARSHALLING(ps))
6455 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
6457 if (ctr->info.id21 == NULL) {
6458 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6461 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6464 if (UNMARSHALLING(ps))
6465 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
6467 if (ctr->info.id23 == NULL) {
6468 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6471 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6474 if (UNMARSHALLING(ps))
6475 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
6477 if (ctr->info.id24 == NULL) {
6478 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6481 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6484 if (UNMARSHALLING(ps))
6485 ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25));
6487 if (ctr->info.id25 == NULL) {
6488 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6491 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6494 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6502 /*******************************************************************
6503 inits a SAMR_R_QUERY_USERINFO structure.
6504 ********************************************************************/
6506 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6507 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6509 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6514 if (NT_STATUS_IS_OK(status)) {
6519 r_u->status = status; /* return status */
6522 /*******************************************************************
6523 reads or writes a structure.
6524 ********************************************************************/
6526 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6527 prs_struct *ps, int depth)
6532 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6538 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6541 if (r_u->ptr != 0) {
6542 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6548 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6554 /*******************************************************************
6555 inits a SAMR_Q_SET_USERINFO structure.
6556 ********************************************************************/
6558 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6559 POLICY_HND *hnd, unsigned char sess_key[16],
6560 uint16 switch_value, void *info)
6562 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6565 q_u->switch_value = switch_value;
6566 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6569 /*******************************************************************
6570 reads or writes a structure.
6571 ********************************************************************/
6573 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6574 prs_struct *ps, int depth)
6579 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6585 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6587 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6589 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6595 /*******************************************************************
6596 inits a SAMR_R_SET_USERINFO structure.
6597 ********************************************************************/
6599 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6601 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6603 r_u->status = status; /* return status */
6606 /*******************************************************************
6607 reads or writes a structure.
6608 ********************************************************************/
6610 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6611 prs_struct *ps, int depth)
6616 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6622 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6628 /*******************************************************************
6629 inits a SAMR_Q_SET_USERINFO2 structure.
6630 ********************************************************************/
6632 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6633 POLICY_HND *hnd, unsigned char sess_key[16],
6634 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6636 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6639 q_u->switch_value = switch_value;
6642 if (q_u->ctr != NULL)
6643 q_u->ctr->switch_value = switch_value;
6645 switch (switch_value) {
6647 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16);
6648 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16);
6649 dump_data(100, (char *)sess_key, 16);
6650 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6651 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6656 /*******************************************************************
6657 reads or writes a structure.
6658 ********************************************************************/
6660 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6661 prs_struct *ps, int depth)
6666 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6672 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6675 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6677 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6683 /*******************************************************************
6684 inits a SAMR_R_SET_USERINFO2 structure.
6685 ********************************************************************/
6687 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6689 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6691 r_u->status = status; /* return status */
6694 /*******************************************************************
6695 reads or writes a structure.
6696 ********************************************************************/
6698 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6699 prs_struct *ps, int depth)
6704 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6710 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6716 /*******************************************************************
6717 inits a SAMR_Q_CONNECT structure.
6718 ********************************************************************/
6720 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6721 char *srv_name, uint32 access_mask)
6723 int len_srv_name = strlen(srv_name);
6725 DEBUG(5, ("init_samr_q_connect\n"));
6727 /* make PDC server name \\server */
6728 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6729 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6731 /* example values: 0x0000 0002 */
6732 q_u->access_mask = access_mask;
6735 /*******************************************************************
6736 reads or writes a structure.
6737 ********************************************************************/
6739 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6740 prs_struct *ps, int depth)
6745 prs_debug(ps, depth, desc, "samr_io_q_connect");
6751 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6753 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6758 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6764 /*******************************************************************
6765 reads or writes a structure.
6766 ********************************************************************/
6768 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6769 prs_struct *ps, int depth)
6774 prs_debug(ps, depth, desc, "samr_io_r_connect");
6780 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6783 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6789 /*******************************************************************
6790 inits a SAMR_Q_CONNECT4 structure.
6791 ********************************************************************/
6793 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6794 char *srv_name, uint32 access_mask)
6796 int len_srv_name = strlen(srv_name);
6798 DEBUG(5, ("init_samr_q_connect\n"));
6800 /* make PDC server name \\server */
6801 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6802 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6804 /* Only value we've seen, possibly an address type ? */
6807 /* example values: 0x0000 0002 */
6808 q_u->access_mask = access_mask;
6811 /*******************************************************************
6812 reads or writes a structure.
6813 ********************************************************************/
6815 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6816 prs_struct *ps, int depth)
6821 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6827 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6829 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6834 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6836 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6842 /*******************************************************************
6843 reads or writes a structure.
6844 ********************************************************************/
6846 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6847 prs_struct *ps, int depth)
6852 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6858 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6861 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6867 /*******************************************************************
6868 inits a SAMR_Q_CONNECT_ANON structure.
6869 ********************************************************************/
6871 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6873 DEBUG(5, ("init_samr_q_connect_anon\n"));
6876 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6877 q_u->unknown_1 = 0x01;
6878 q_u->access_mask = 0x20;
6881 /*******************************************************************
6882 reads or writes a structure.
6883 ********************************************************************/
6885 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6886 prs_struct *ps, int depth)
6891 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6897 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6899 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6901 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6903 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6909 /*******************************************************************
6910 reads or writes a structure.
6911 ********************************************************************/
6913 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6914 prs_struct *ps, int depth)
6919 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6925 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6928 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6934 /*******************************************************************
6935 inits a SAMR_Q_GET_DOM_PWINFO structure.
6936 ********************************************************************/
6938 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6941 int len_srv_name = strlen(srv_name);
6943 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6946 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6947 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6950 /*******************************************************************
6951 reads or writes a structure.
6952 ********************************************************************/
6954 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6955 prs_struct *ps, int depth)
6960 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6966 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6968 if (q_u->ptr != 0) {
6969 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6971 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6978 /*******************************************************************
6979 reads or writes a structure.
6980 ********************************************************************/
6982 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6983 prs_struct *ps, int depth)
6988 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6995 * We need 16 bytes here according to tests. Don't know
6996 * what they are, but the length is important for the singing
6999 if(!prs_uint32("unk_0", ps, depth, &r_u->unk_0))
7001 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
7003 if(!prs_uint32("unk_2", ps, depth, &r_u->unk_2))
7006 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7012 /*******************************************************************
7013 make a SAMR_ENC_PASSWD structure.
7014 ********************************************************************/
7016 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
7024 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7028 /*******************************************************************
7029 reads or writes a SAMR_ENC_PASSWD structure.
7030 ********************************************************************/
7032 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7033 prs_struct *ps, int depth)
7038 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7044 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7047 if (pwd->ptr != 0) {
7048 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7055 /*******************************************************************
7056 inits a SAMR_ENC_HASH structure.
7057 ********************************************************************/
7059 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
7067 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7071 /*******************************************************************
7072 reads or writes a SAMR_ENC_HASH structure.
7073 ********************************************************************/
7075 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7076 prs_struct *ps, int depth)
7081 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7087 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7089 if (hsh->ptr != 0) {
7090 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7097 /*******************************************************************
7098 inits a SAMR_R_GET_DOM_PWINFO structure.
7099 ********************************************************************/
7101 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7102 char *dest_host, char *user_name,
7103 char nt_newpass[516],
7104 uchar nt_oldhash[16],
7105 char lm_newpass[516],
7106 uchar lm_oldhash[16])
7108 int len_dest_host = strlen(dest_host);
7109 int len_user_name = strlen(user_name);
7111 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7114 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
7115 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
7116 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
7117 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
7119 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7120 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7122 q_u->unknown = 0x01;
7124 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7125 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7128 /*******************************************************************
7129 reads or writes a structure.
7130 ********************************************************************/
7132 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7133 prs_struct *ps, int depth)
7138 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7144 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7147 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7149 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7154 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7156 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7159 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7161 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7164 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7167 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7169 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7175 /*******************************************************************
7176 inits a SAMR_R_CHGPASSWD_USER structure.
7177 ********************************************************************/
7179 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7181 DEBUG(5, ("init_r_chgpasswd_user\n"));
7183 r_u->status = status;
7186 /*******************************************************************
7187 reads or writes a structure.
7188 ********************************************************************/
7190 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7191 prs_struct *ps, int depth)
7196 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7202 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7208 /*******************************************************************
7209 reads or writes a structure.
7210 ********************************************************************/
7212 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7213 POLICY_HND *domain_pol, uint16 switch_value)
7215 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7217 q_u->domain_pol = *domain_pol;
7218 q_u->switch_value = switch_value;
7221 /*******************************************************************
7222 reads or writes a structure.
7223 ********************************************************************/
7225 BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7226 prs_struct *ps, int depth)
7231 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7237 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7240 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7246 /*******************************************************************
7247 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7248 ********************************************************************/
7250 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7251 uint16 switch_value, SAM_UNK_CTR * ctr,
7254 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7257 r_u->switch_value = 0;
7258 r_u->status = status; /* return status */
7260 if (NT_STATUS_IS_OK(status)) {
7261 r_u->switch_value = switch_value;
7267 /*******************************************************************
7268 reads or writes a structure.
7269 ********************************************************************/
7271 BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u,
7272 prs_struct *ps, int depth)
7277 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7283 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7286 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7287 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7292 switch (r_u->switch_value) {
7294 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7298 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7302 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7306 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7310 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7314 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7318 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7322 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7323 r_u->switch_value));
7324 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7332 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7339 /*******************************************************************
7340 reads or writes a structure.
7341 ********************************************************************/
7343 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7344 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7346 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7348 q_u->domain_pol = *domain_pol;
7349 q_u->switch_value0 = switch_value;
7351 q_u->switch_value = switch_value;
7356 /*******************************************************************
7357 reads or writes a structure.
7358 ********************************************************************/
7360 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7361 prs_struct *ps, int depth)
7366 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7372 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7375 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7378 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7384 if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL)
7387 switch (q_u->switch_value) {
7390 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7394 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7398 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7402 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7406 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7410 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7414 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7418 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7419 q_u->switch_value));
7426 /*******************************************************************
7427 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7428 ********************************************************************/
7430 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7432 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7434 r_u->status = status; /* return status */
7437 /*******************************************************************
7438 reads or writes a structure.
7439 ********************************************************************/
7441 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7442 prs_struct *ps, int depth)
7447 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7453 if(!prs_ntstatus("status", ps, depth, &r_u->status))