r4904: sync up with 3.0 for 3.0.11pre2
[Samba.git] / source / rpc_parse / parse_samr.c
blob748ee1fb7c8a328b9830d06da6ea041ef20f22ad
1 /*
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.
27 #include "includes.h"
28 #include "rpc_parse.h"
29 #include "nterr.h"
31 #undef DBGC_CLASS
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"));
42 q_c->pol = *hnd;
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)
52 if (q_u == NULL)
53 return False;
55 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
56 depth++;
58 if(!prs_align(ps))
59 return False;
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)
71 if (r_u == NULL)
72 return False;
74 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
75 depth++;
77 if(!prs_align(ps))
78 return False;
80 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
81 return False;
83 if(!prs_ntstatus("status", ps, depth, &r_u->status))
84 return False;
86 return True;
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 DEBUG(5, ("init_samr_q_lookup_domain\n"));
98 q_u->connect_pol = *pol;
100 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
101 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
104 /*******************************************************************
105 reads or writes a structure.
106 ********************************************************************/
107 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
108 prs_struct *ps, int depth)
110 if (q_u == NULL)
111 return False;
113 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
114 depth++;
116 if(!prs_align(ps))
117 return False;
119 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
120 return False;
122 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
123 return False;
125 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
126 return False;
128 return True;
131 /*******************************************************************
132 inits a SAMR_R_LOOKUP_DOMAIN structure.
133 ********************************************************************/
135 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
136 DOM_SID *dom_sid, NTSTATUS status)
138 DEBUG(5, ("init_samr_r_lookup_domain\n"));
140 r_u->status = status;
141 r_u->ptr_sid = 0;
142 if (NT_STATUS_IS_OK(status)) {
143 r_u->ptr_sid = 1;
144 init_dom_sid2(&r_u->dom_sid, dom_sid);
148 /*******************************************************************
149 reads or writes a structure.
150 ********************************************************************/
152 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
153 prs_struct *ps, int depth)
155 if (r_u == NULL)
156 return False;
158 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
159 depth++;
161 if(!prs_align(ps))
162 return False;
164 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
165 return False;
167 if (r_u->ptr_sid != 0) {
168 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
169 return False;
170 if(!prs_align(ps))
171 return False;
174 if(!prs_ntstatus("status", ps, depth, &r_u->status))
175 return False;
177 return True;
180 /*******************************************************************
181 reads or writes a structure.
182 ********************************************************************/
184 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
186 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
188 q_u->dom_pol = *dom_pol;
189 init_dom_sid2(&q_u->sid, sid);
192 /*******************************************************************
193 reads or writes a structure.
194 ********************************************************************/
196 BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
197 prs_struct *ps, int depth)
199 if (q_u == NULL)
200 return False;
202 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
203 depth++;
205 if(!prs_align(ps))
206 return False;
208 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
209 return False;
211 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
212 return False;
214 if(!prs_align(ps))
215 return False;
217 return True;
220 /*******************************************************************
221 reads or writes a structure.
222 ********************************************************************/
224 BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
225 prs_struct *ps, int depth)
227 if (r_u == NULL)
228 return False;
230 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
231 depth++;
233 if(!prs_align(ps))
234 return False;
236 if(!prs_ntstatus("status", ps, depth, &r_u->status))
237 return False;
239 return True;
242 /*******************************************************************
243 reads or writes a structure.
244 ********************************************************************/
246 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
247 POLICY_HND *pol, uint32 flags,
248 const DOM_SID *sid)
250 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
252 q_u->pol = *pol;
253 q_u->flags = flags;
254 init_dom_sid2(&q_u->dom_sid, sid);
257 /*******************************************************************
258 reads or writes a structure.
259 ********************************************************************/
261 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
262 prs_struct *ps, int depth)
264 if (q_u == NULL)
265 return False;
267 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
268 depth++;
270 if(!prs_align(ps))
271 return False;
273 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
274 return False;
276 if(!prs_uint32("flags", ps, depth, &q_u->flags))
277 return False;
279 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
280 return False;
282 return True;
285 /*******************************************************************
286 reads or writes a structure.
287 ********************************************************************/
289 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
290 prs_struct *ps, int depth)
292 if (r_u == NULL)
293 return False;
295 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
296 depth++;
298 if(!prs_align(ps))
299 return False;
301 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
302 return False;
304 if(!prs_ntstatus("status", ps, depth, &r_u->status))
305 return False;
307 return True;
310 /*******************************************************************
311 reads or writes a structure.
312 ********************************************************************/
314 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
315 POLICY_HND *user_pol)
317 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
319 q_u->user_pol = *user_pol;
322 /*******************************************************************
323 reads or writes a structure.
324 ********************************************************************/
326 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
327 prs_struct *ps, int depth)
329 if (q_u == NULL)
330 return False;
332 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
333 depth++;
335 if(!prs_align(ps))
336 return False;
338 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
341 /*******************************************************************
342 Init.
343 ********************************************************************/
345 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
347 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
349 r_u->unknown_0 = 0x0000;
352 * used to be
353 * r_u->unknown_1 = 0x0015;
354 * but for trusts.
356 r_u->unknown_1 = 0x01D1;
357 r_u->unknown_1 = 0x0015;
359 r_u->unknown_2 = 0x00000000;
361 r_u->status = status;
364 /*******************************************************************
365 reads or writes a structure.
366 ********************************************************************/
368 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
369 prs_struct *ps, int depth)
371 if (r_u == NULL)
372 return False;
374 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
375 depth++;
377 if(!prs_align(ps))
378 return False;
380 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
381 return False;
382 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
383 return False;
384 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
385 return False;
386 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
387 return False;
389 return True;
393 /*******************************************************************
394 reads or writes a structure.
395 ********************************************************************/
397 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
398 prs_struct *ps, int depth)
400 if (q_u == NULL)
401 return False;
403 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
404 depth++;
406 if(!prs_align(ps))
407 return False;
409 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
410 return False;
412 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
413 return False;
415 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
416 return False;
418 return True;
422 /*******************************************************************
423 reads or writes a structure.
424 ********************************************************************/
426 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
427 POLICY_HND *user_pol, uint32 sec_info)
429 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
431 q_u->user_pol = *user_pol;
432 q_u->sec_info = sec_info;
436 /*******************************************************************
437 reads or writes a structure.
438 ********************************************************************/
440 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
441 prs_struct *ps, int depth)
443 if (q_u == NULL)
444 return False;
446 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
447 depth++;
449 if(!prs_align(ps))
450 return False;
452 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
453 return False;
455 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
456 return False;
458 return True;
461 /*******************************************************************
462 reads or writes a structure.
463 ********************************************************************/
465 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
466 POLICY_HND *domain_pol, uint16 switch_value)
468 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
470 q_u->domain_pol = *domain_pol;
471 q_u->switch_value = switch_value;
474 /*******************************************************************
475 reads or writes a structure.
476 ********************************************************************/
478 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
479 prs_struct *ps, int depth)
481 if (q_u == NULL)
482 return False;
484 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
485 depth++;
487 if(!prs_align(ps))
488 return False;
490 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
491 return False;
493 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
494 return False;
496 return True;
500 /*******************************************************************
501 inits a structure.
502 ********************************************************************/
504 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
506 u_3->logout.low = nt_logout.low;
507 u_3->logout.high = nt_logout.high;
510 /*******************************************************************
511 reads or writes a structure.
512 ********************************************************************/
514 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
515 prs_struct *ps, int depth)
517 if (u_3 == NULL)
518 return False;
520 prs_debug(ps, depth, desc, "sam_io_unk_info3");
521 depth++;
523 if(!smb_io_time("logout", &u_3->logout, ps, depth))
524 return False;
526 return True;
529 /*******************************************************************
530 inits a structure.
531 ********************************************************************/
533 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
535 u_6->unknown_0 = 0x00000000;
536 u_6->ptr_0 = 1;
537 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
540 /*******************************************************************
541 reads or writes a structure.
542 ********************************************************************/
544 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
545 prs_struct *ps, int depth)
547 if (u_6 == NULL)
548 return False;
550 prs_debug(ps, depth, desc, "sam_io_unk_info6");
551 depth++;
553 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
554 return False;
555 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
556 return False;
557 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
558 return False;
560 return True;
563 /*******************************************************************
564 inits a structure.
565 ********************************************************************/
567 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
569 u_7->unknown_0 = 0x0003;
572 /*******************************************************************
573 reads or writes a structure.
574 ********************************************************************/
576 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
577 prs_struct *ps, int depth)
579 if (u_7 == NULL)
580 return False;
582 prs_debug(ps, depth, desc, "sam_io_unk_info7");
583 depth++;
585 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
586 return False;
588 return True;
591 /*******************************************************************
592 inits a structure.
593 ********************************************************************/
595 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
597 unix_to_nt_time(&u_8->domain_create_time, 0);
598 u_8->seq_num.low = seq_num;
599 u_8->seq_num.high = 0x0000;
602 /*******************************************************************
603 reads or writes a structure.
604 ********************************************************************/
606 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
607 prs_struct *ps, int depth)
609 if (u_8 == NULL)
610 return False;
612 prs_debug(ps, depth, desc, "sam_io_unk_info8");
613 depth++;
615 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
616 return False;
618 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
619 return False;
621 return True;
625 /*******************************************************************
626 inits a structure.
627 ********************************************************************/
629 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
631 u_12->duration.low = nt_lock_duration.low;
632 u_12->duration.high = nt_lock_duration.high;
633 u_12->reset_count.low = nt_reset_time.low;
634 u_12->reset_count.high = nt_reset_time.high;
636 u_12->bad_attempt_lockout = lockout;
639 /*******************************************************************
640 reads or writes a structure.
641 ********************************************************************/
643 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
644 prs_struct *ps, int depth)
646 if (u_12 == NULL)
647 return False;
649 prs_debug(ps, depth, desc, "sam_io_unk_info12");
650 depth++;
652 if(!smb_io_time("duration", &u_12->duration, ps, depth))
653 return False;
654 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
655 return False;
656 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
657 return False;
659 return True;
662 /*******************************************************************
663 inits a structure.
664 ********************************************************************/
666 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
668 init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE);
669 init_uni_hdr(&u_5->hdr_server, &u_5->uni_server);
672 /*******************************************************************
673 reads or writes a structure.
674 ********************************************************************/
676 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
677 prs_struct *ps, int depth)
679 if (u_5 == NULL)
680 return False;
682 prs_debug(ps, depth, desc, "sam_io_unk_info5");
683 depth++;
685 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
686 return False;
688 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
689 return False;
691 return True;
694 /*******************************************************************
695 inits a structure.
696 ********************************************************************/
698 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
699 const char *comment, const char *domain, const char *server,
700 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout)
702 u_2->logout.low = nt_logout.low;
703 u_2->logout.high = nt_logout.high;
705 u_2->seq_num.low = seq_num;
706 u_2->seq_num.high = 0x00000000;
709 u_2->unknown_4 = 0x00000001;
710 u_2->unknown_5 = 0x00000003;
711 u_2->unknown_6 = 0x00000001;
712 u_2->num_domain_usrs = num_users;
713 u_2->num_domain_grps = num_groups;
714 u_2->num_local_grps = num_alias;
716 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
718 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
719 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
720 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
721 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
722 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
723 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
726 /*******************************************************************
727 reads or writes a structure.
728 ********************************************************************/
730 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
731 prs_struct *ps, int depth)
733 if (u_2 == NULL)
734 return False;
736 prs_debug(ps, depth, desc, "sam_io_unk_info2");
737 depth++;
739 if(!smb_io_time("logout", &u_2->logout, ps, depth))
740 return False;
741 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
742 return False;
743 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
744 return False;
745 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
746 return False;
748 /* put all the data in here, at the moment, including what the above
749 pointer is referring to
752 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
753 return False;
755 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
756 return False;
757 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
758 return False;
759 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
760 return False;
761 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
762 return False;
763 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
764 return False;
765 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
766 return False;
768 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
769 return False;
770 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
771 return False;
772 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
773 return False;
775 return True;
778 /*******************************************************************
779 inits a structure.
780 ********************************************************************/
782 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
783 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
785 u_1->min_length_password = min_pass_len;
786 u_1->password_history = pass_hist;
787 u_1->flag = flag;
789 /* password never expire */
790 u_1->expire.high = nt_expire.high;
791 u_1->expire.low = nt_expire.low;
793 /* can change the password now */
794 u_1->min_passwordage.high = nt_min_age.high;
795 u_1->min_passwordage.low = nt_min_age.low;
799 /*******************************************************************
800 reads or writes a structure.
801 ********************************************************************/
803 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
804 prs_struct *ps, int depth)
806 if (u_1 == NULL)
807 return False;
809 prs_debug(ps, depth, desc, "sam_io_unk_info1");
810 depth++;
812 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
813 return False;
814 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
815 return False;
816 if(!prs_uint32("flag", ps, depth, &u_1->flag))
817 return False;
818 if(!smb_io_time("expire", &u_1->expire, ps, depth))
819 return False;
820 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
821 return False;
823 return True;
826 /*******************************************************************
827 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
828 ********************************************************************/
830 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
831 uint16 switch_value, SAM_UNK_CTR * ctr,
832 NTSTATUS status)
834 DEBUG(5, ("init_samr_r_query_dom_info\n"));
836 r_u->ptr_0 = 0;
837 r_u->switch_value = 0;
838 r_u->status = status; /* return status */
840 if (NT_STATUS_IS_OK(status)) {
841 r_u->switch_value = switch_value;
842 r_u->ptr_0 = 1;
843 r_u->ctr = ctr;
847 /*******************************************************************
848 reads or writes a structure.
849 ********************************************************************/
851 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
852 prs_struct *ps, int depth)
854 if (r_u == NULL)
855 return False;
857 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
858 depth++;
860 if(!prs_align(ps))
861 return False;
863 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
864 return False;
866 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
867 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
868 return False;
869 if(!prs_align(ps))
870 return False;
872 switch (r_u->switch_value) {
873 case 0x0c:
874 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
875 return False;
876 break;
877 case 0x08:
878 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
879 return False;
880 break;
881 case 0x07:
882 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
883 return False;
884 break;
885 case 0x06:
886 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
887 return False;
888 break;
889 case 0x05:
890 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
891 return False;
892 break;
893 case 0x03:
894 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
895 return False;
896 break;
897 case 0x02:
898 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
899 return False;
900 break;
901 case 0x01:
902 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
903 return False;
904 break;
905 default:
906 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
907 r_u->switch_value));
908 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
909 return False;
913 if(!prs_align(ps))
914 return False;
916 if(!prs_ntstatus("status", ps, depth, &r_u->status))
917 return False;
919 return True;
922 /*******************************************************************
923 reads or writes a SAMR_R_SET_SEC_OBJ structure.
924 ********************************************************************/
926 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
927 prs_struct *ps, int depth)
929 if (r_u == NULL)
930 return False;
932 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
933 depth++;
935 if(!prs_align(ps))
936 return False;
938 if(!prs_ntstatus("status", ps, depth, &r_u->status))
939 return False;
941 return True;
944 /*******************************************************************
945 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
946 ********************************************************************/
948 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
949 prs_struct *ps, int depth)
951 if (r_u == NULL)
952 return False;
954 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
955 depth++;
957 if(!prs_align(ps))
958 return False;
960 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
961 return False;
962 if (r_u->ptr != 0) {
963 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
964 return False;
967 if(!prs_ntstatus("status", ps, depth, &r_u->status))
968 return False;
970 return True;
973 /*******************************************************************
974 reads or writes a SAM_STR1 structure.
975 ********************************************************************/
977 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
978 uint32 name_buf, uint32 desc_buf,
979 prs_struct *ps, int depth)
981 if (sam == NULL)
982 return False;
984 prs_debug(ps, depth, desc, "sam_io_sam_str1");
985 depth++;
987 if(!prs_align(ps))
988 return False;
989 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
990 return False;
992 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
993 return False;
995 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
996 return False;
998 return True;
1001 /*******************************************************************
1002 inits a SAM_ENTRY1 structure.
1003 ********************************************************************/
1005 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1006 UNISTR2 *sam_name, UNISTR2 *sam_full,
1007 UNISTR2 *sam_desc, uint32 rid_user,
1008 uint16 acb_info)
1010 DEBUG(5, ("init_sam_entry1\n"));
1012 ZERO_STRUCTP(sam);
1014 sam->user_idx = user_idx;
1015 sam->rid_user = rid_user;
1016 sam->acb_info = acb_info;
1018 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1019 init_uni_hdr(&sam->hdr_user_name, sam_full);
1020 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1023 /*******************************************************************
1024 reads or writes a SAM_ENTRY1 structure.
1025 ********************************************************************/
1027 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1028 prs_struct *ps, int depth)
1030 if (sam == NULL)
1031 return False;
1033 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1034 depth++;
1036 if(!prs_align(ps))
1037 return False;
1039 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1040 return False;
1042 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1043 return False;
1044 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1045 return False;
1047 if(!prs_align(ps))
1048 return False;
1050 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1051 return False;
1052 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1053 return False;
1054 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1055 return False;
1057 return True;
1060 /*******************************************************************
1061 reads or writes a SAM_STR2 structure.
1062 ********************************************************************/
1064 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1065 uint32 desc_buf, prs_struct *ps, int depth)
1067 if (sam == NULL)
1068 return False;
1070 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1071 depth++;
1073 if(!prs_align(ps))
1074 return False;
1076 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1077 return False;
1078 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1079 return False;
1081 return True;
1084 /*******************************************************************
1085 inits a SAM_ENTRY2 structure.
1086 ********************************************************************/
1087 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1088 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1089 uint32 rid_user, uint16 acb_info)
1091 DEBUG(5, ("init_sam_entry2\n"));
1093 sam->user_idx = user_idx;
1094 sam->rid_user = rid_user;
1095 sam->acb_info = acb_info;
1097 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1098 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1101 /*******************************************************************
1102 reads or writes a SAM_ENTRY2 structure.
1103 ********************************************************************/
1105 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1106 prs_struct *ps, int depth)
1108 if (sam == NULL)
1109 return False;
1111 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1112 depth++;
1114 if(!prs_align(ps))
1115 return False;
1117 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1118 return False;
1120 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1121 return False;
1122 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1123 return False;
1125 if(!prs_align(ps))
1126 return False;
1128 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1129 return False;
1130 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1131 return False;
1133 return True;
1136 /*******************************************************************
1137 reads or writes a SAM_STR3 structure.
1138 ********************************************************************/
1140 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1141 uint32 desc_buf, prs_struct *ps, int depth)
1143 if (sam == NULL)
1144 return False;
1146 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1147 depth++;
1149 if(!prs_align(ps))
1150 return False;
1152 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1153 return False;
1154 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1155 return False;
1157 return True;
1160 /*******************************************************************
1161 inits a SAM_ENTRY3 structure.
1162 ********************************************************************/
1164 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1165 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1166 uint32 rid_grp)
1168 DEBUG(5, ("init_sam_entry3\n"));
1170 sam->grp_idx = grp_idx;
1171 sam->rid_grp = rid_grp;
1172 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1174 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1175 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1178 /*******************************************************************
1179 reads or writes a SAM_ENTRY3 structure.
1180 ********************************************************************/
1182 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1183 prs_struct *ps, int depth)
1185 if (sam == NULL)
1186 return False;
1188 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1189 depth++;
1191 if(!prs_align(ps))
1192 return False;
1194 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1195 return False;
1197 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1198 return False;
1199 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1200 return False;
1202 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1203 return False;
1204 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1205 return False;
1207 return True;
1210 /*******************************************************************
1211 inits a SAM_ENTRY4 structure.
1212 ********************************************************************/
1214 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1215 uint32 len_acct_name)
1217 DEBUG(5, ("init_sam_entry4\n"));
1219 sam->user_idx = user_idx;
1220 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1223 /*******************************************************************
1224 reads or writes a SAM_ENTRY4 structure.
1225 ********************************************************************/
1227 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1228 prs_struct *ps, int depth)
1230 if (sam == NULL)
1231 return False;
1233 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1234 depth++;
1236 if(!prs_align(ps))
1237 return False;
1239 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1240 return False;
1241 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1242 return False;
1244 return True;
1247 /*******************************************************************
1248 inits a SAM_ENTRY5 structure.
1249 ********************************************************************/
1251 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1252 uint32 len_grp_name)
1254 DEBUG(5, ("init_sam_entry5\n"));
1256 sam->grp_idx = grp_idx;
1257 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1258 len_grp_name != 0);
1261 /*******************************************************************
1262 reads or writes a SAM_ENTRY5 structure.
1263 ********************************************************************/
1265 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1266 prs_struct *ps, int depth)
1268 if (sam == NULL)
1269 return False;
1271 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1272 depth++;
1274 if(!prs_align(ps))
1275 return False;
1277 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1278 return False;
1279 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1280 return False;
1282 return True;
1285 /*******************************************************************
1286 inits a SAM_ENTRY structure.
1287 ********************************************************************/
1289 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1291 DEBUG(10, ("init_sam_entry: %d\n", rid));
1293 sam->rid = rid;
1294 init_uni_hdr(&sam->hdr_name, uni2);
1297 /*******************************************************************
1298 reads or writes a SAM_ENTRY structure.
1299 ********************************************************************/
1301 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1302 prs_struct *ps, int depth)
1304 if (sam == NULL)
1305 return False;
1307 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1308 depth++;
1310 if(!prs_align(ps))
1311 return False;
1312 if(!prs_uint32("rid", ps, depth, &sam->rid))
1313 return False;
1314 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1315 return False;
1317 return True;
1320 /*******************************************************************
1321 inits a SAMR_Q_ENUM_DOM_USERS structure.
1322 ********************************************************************/
1324 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1325 uint32 start_idx,
1326 uint16 acb_mask, uint16 unk_1, uint32 size)
1328 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1330 q_e->pol = *pol;
1332 q_e->start_idx = start_idx; /* zero indicates lots */
1333 q_e->acb_mask = acb_mask;
1334 q_e->unknown_1 = unk_1;
1335 q_e->max_size = size;
1338 /*******************************************************************
1339 reads or writes a structure.
1340 ********************************************************************/
1342 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1343 prs_struct *ps, int depth)
1345 if (q_e == NULL)
1346 return False;
1348 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1349 depth++;
1351 if(!prs_align(ps))
1352 return False;
1354 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1355 return False;
1357 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1358 return False;
1359 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1360 return False;
1361 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1362 return False;
1364 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1365 return False;
1367 return True;
1371 /*******************************************************************
1372 inits a SAMR_R_ENUM_DOM_USERS structure.
1373 ********************************************************************/
1375 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1376 uint32 next_idx, uint32 num_sam_entries)
1378 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1380 r_u->next_idx = next_idx;
1382 if (num_sam_entries != 0) {
1383 r_u->ptr_entries1 = 1;
1384 r_u->ptr_entries2 = 1;
1385 r_u->num_entries2 = num_sam_entries;
1386 r_u->num_entries3 = num_sam_entries;
1388 r_u->num_entries4 = num_sam_entries;
1389 } else {
1390 r_u->ptr_entries1 = 0;
1391 r_u->num_entries2 = num_sam_entries;
1392 r_u->ptr_entries2 = 1;
1396 /*******************************************************************
1397 reads or writes a structure.
1398 ********************************************************************/
1400 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1401 prs_struct *ps, int depth)
1403 uint32 i;
1405 if (r_u == NULL)
1406 return False;
1408 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1409 depth++;
1411 if(!prs_align(ps))
1412 return False;
1414 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1415 return False;
1416 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1417 return False;
1419 if (r_u->ptr_entries1 != 0) {
1420 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1421 return False;
1422 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1423 return False;
1424 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1425 return False;
1427 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1428 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1429 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1432 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1433 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1434 r_u->num_entries4 = 0;
1435 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1436 return False;
1439 for (i = 0; i < r_u->num_entries2; i++) {
1440 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1441 return False;
1444 for (i = 0; i < r_u->num_entries2; i++) {
1445 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1446 return False;
1451 if(!prs_align(ps))
1452 return False;
1454 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1455 return False;
1456 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1457 return False;
1459 return True;
1462 /*******************************************************************
1463 inits a SAMR_Q_QUERY_DISPINFO structure.
1464 ********************************************************************/
1466 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1467 uint16 switch_level, uint32 start_idx,
1468 uint32 max_entries, uint32 max_size)
1470 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1472 q_e->domain_pol = *pol;
1474 q_e->switch_level = switch_level;
1476 q_e->start_idx = start_idx;
1477 q_e->max_entries = max_entries;
1478 q_e->max_size = max_size;
1481 /*******************************************************************
1482 reads or writes a structure.
1483 ********************************************************************/
1485 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1486 prs_struct *ps, int depth)
1488 if (q_e == NULL)
1489 return False;
1491 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1492 depth++;
1494 if(!prs_align(ps))
1495 return False;
1497 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1498 return False;
1500 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1501 return False;
1502 if(!prs_align(ps))
1503 return False;
1505 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1506 return False;
1507 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1508 return False;
1509 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1510 return False;
1512 return True;
1515 /*******************************************************************
1516 inits a SAM_DISPINFO_1 structure.
1517 ********************************************************************/
1519 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1520 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1521 DOM_SID *domain_sid)
1523 uint32 i;
1525 SAM_ACCOUNT *pwd = NULL;
1526 ZERO_STRUCTP(sam);
1528 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1530 if (num_entries==0)
1531 return NT_STATUS_OK;
1533 sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1534 if (!sam->sam)
1535 return NT_STATUS_NO_MEMORY;
1537 sam->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1538 if (!sam->str)
1539 return NT_STATUS_NO_MEMORY;
1541 ZERO_STRUCTP(sam->sam);
1542 ZERO_STRUCTP(sam->str);
1544 for (i = 0; i < num_entries ; i++) {
1545 const char *username;
1546 const char *fullname;
1547 const char *acct_desc;
1548 uint32 user_rid;
1549 const DOM_SID *user_sid;
1550 fstring user_sid_string, domain_sid_string;
1552 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1554 pwd=&disp_user_info[i+start_idx];
1556 username = pdb_get_username(pwd);
1557 fullname = pdb_get_fullname(pwd);
1558 acct_desc = pdb_get_acct_desc(pwd);
1560 if (!username)
1561 username = "";
1563 if (!fullname)
1564 fullname = "";
1566 if (!acct_desc)
1567 acct_desc = "";
1569 user_sid = pdb_get_user_sid(pwd);
1571 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1572 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1573 "the domain sid %s. Failing operation.\n",
1574 username,
1575 sid_to_string(user_sid_string, user_sid),
1576 sid_to_string(domain_sid_string, domain_sid)));
1577 return NT_STATUS_UNSUCCESSFUL;
1580 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), UNI_FLAGS_NONE);
1581 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), UNI_FLAGS_NONE);
1582 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), UNI_FLAGS_NONE);
1584 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1585 &sam->str[i].uni_acct_name, &sam->str[i].uni_full_name, &sam->str[i].uni_acct_desc,
1586 user_rid, pdb_get_acct_ctrl(pwd));
1590 return NT_STATUS_OK;
1593 /*******************************************************************
1594 reads or writes a structure.
1595 ********************************************************************/
1597 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1598 uint32 num_entries,
1599 prs_struct *ps, int depth)
1601 uint32 i;
1603 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1604 depth++;
1606 if(!prs_align(ps))
1607 return False;
1609 if (UNMARSHALLING(ps) && num_entries > 0) {
1611 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1612 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1613 return False;
1616 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1617 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1618 return False;
1622 for (i = 0; i < num_entries; i++) {
1623 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1624 return False;
1627 for (i = 0; i < num_entries; i++) {
1628 if(!sam_io_sam_str1("", &sam->str[i],
1629 sam->sam[i].hdr_acct_name.buffer,
1630 sam->sam[i].hdr_user_name.buffer,
1631 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1632 return False;
1635 return True;
1638 /*******************************************************************
1639 inits a SAM_DISPINFO_2 structure.
1640 ********************************************************************/
1642 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1643 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1644 DOM_SID *domain_sid )
1646 uint32 i;
1648 SAM_ACCOUNT *pwd = NULL;
1649 ZERO_STRUCTP(sam);
1651 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1653 if (num_entries==0)
1654 return NT_STATUS_OK;
1656 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries)))
1657 return NT_STATUS_NO_MEMORY;
1659 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries)))
1660 return NT_STATUS_NO_MEMORY;
1662 ZERO_STRUCTP(sam->sam);
1663 ZERO_STRUCTP(sam->str);
1665 for (i = 0; i < num_entries; i++) {
1666 uint32 user_rid;
1667 const DOM_SID *user_sid;
1668 const char *username;
1669 const char *acct_desc;
1670 fstring user_sid_string, domain_sid_string;
1672 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1673 pwd=&disp_user_info[i+start_idx];
1675 username = pdb_get_username(pwd);
1676 acct_desc = pdb_get_acct_desc(pwd);
1677 user_sid = pdb_get_user_sid(pwd);
1679 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1680 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1681 "the domain sid %s. Failing operation.\n",
1682 username,
1683 sid_to_string(user_sid_string, user_sid),
1684 sid_to_string(domain_sid_string, domain_sid)));
1685 return NT_STATUS_UNSUCCESSFUL;
1688 init_unistr2(&sam->str[i].uni_srv_name, username, UNI_FLAGS_NONE);
1689 init_unistr2(&sam->str[i].uni_srv_desc, acct_desc, UNI_FLAGS_NONE);
1691 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1692 &sam->str[i].uni_srv_name, &sam->str[i].uni_srv_desc,
1693 user_rid, pdb_get_acct_ctrl(pwd));
1696 return NT_STATUS_OK;
1699 /*******************************************************************
1700 reads or writes a structure.
1701 ********************************************************************/
1703 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1704 uint32 num_entries,
1705 prs_struct *ps, int depth)
1707 uint32 i;
1709 if (sam == NULL)
1710 return False;
1712 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1713 depth++;
1715 if(!prs_align(ps))
1716 return False;
1718 if (UNMARSHALLING(ps) && num_entries > 0) {
1720 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1721 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1722 return False;
1725 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1726 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1727 return False;
1731 for (i = 0; i < num_entries; i++) {
1732 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1733 return False;
1736 for (i = 0; i < num_entries; i++) {
1737 if(!sam_io_sam_str2("", &sam->str[i],
1738 sam->sam[i].hdr_srv_name.buffer,
1739 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1740 return False;
1743 return True;
1746 /*******************************************************************
1747 inits a SAM_DISPINFO_3 structure.
1748 ********************************************************************/
1750 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1751 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1753 uint32 i;
1755 ZERO_STRUCTP(sam);
1757 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1759 if (num_entries==0)
1760 return NT_STATUS_OK;
1762 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1763 return NT_STATUS_NO_MEMORY;
1765 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1766 return NT_STATUS_NO_MEMORY;
1768 ZERO_STRUCTP(sam->sam);
1769 ZERO_STRUCTP(sam->str);
1771 for (i = 0; i < num_entries; i++) {
1772 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1774 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1776 init_unistr2(&sam->str[i].uni_grp_name, grp->name, UNI_FLAGS_NONE);
1777 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, UNI_FLAGS_NONE);
1779 init_sam_entry3(&sam->sam[i], start_idx + i + 1, &sam->str[i].uni_grp_name,
1780 &sam->str[i].uni_grp_desc, grp->rid);
1783 return NT_STATUS_OK;
1786 /*******************************************************************
1787 reads or writes a structure.
1788 ********************************************************************/
1790 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1791 uint32 num_entries,
1792 prs_struct *ps, int depth)
1794 uint32 i;
1796 if (sam == NULL)
1797 return False;
1799 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1800 depth++;
1802 if(!prs_align(ps))
1803 return False;
1805 if (UNMARSHALLING(ps) && num_entries > 0) {
1807 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1808 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1809 return False;
1812 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1813 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1814 return False;
1818 for (i = 0; i < num_entries; i++) {
1819 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1820 return False;
1823 for (i = 0; i < num_entries; i++) {
1824 if(!sam_io_sam_str3("", &sam->str[i],
1825 sam->sam[i].hdr_grp_name.buffer,
1826 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1827 return False;
1830 return True;
1833 /*******************************************************************
1834 inits a SAM_DISPINFO_4 structure.
1835 ********************************************************************/
1837 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1838 uint32 start_idx, SAM_ACCOUNT *disp_user_info)
1840 uint32 len_sam_name;
1841 uint32 i;
1843 SAM_ACCOUNT *pwd = NULL;
1844 ZERO_STRUCTP(sam);
1846 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1848 if (num_entries==0)
1849 return NT_STATUS_OK;
1851 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries)))
1852 return NT_STATUS_NO_MEMORY;
1854 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries)))
1855 return NT_STATUS_NO_MEMORY;
1857 ZERO_STRUCTP(sam->sam);
1858 ZERO_STRUCTP(sam->str);
1860 for (i = 0; i < num_entries; i++) {
1861 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1862 pwd=&disp_user_info[i+start_idx];
1864 len_sam_name = strlen(pdb_get_username(pwd));
1866 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1868 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1871 return NT_STATUS_OK;
1874 /*******************************************************************
1875 reads or writes a structure.
1876 ********************************************************************/
1878 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1879 uint32 num_entries,
1880 prs_struct *ps, int depth)
1882 uint32 i;
1884 if (sam == NULL)
1885 return False;
1887 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1888 depth++;
1890 if(!prs_align(ps))
1891 return False;
1893 if (UNMARSHALLING(ps) && num_entries > 0) {
1895 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1896 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1897 return False;
1900 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1901 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1902 return False;
1906 for (i = 0; i < num_entries; i++) {
1907 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1908 return False;
1911 for (i = 0; i < num_entries; i++) {
1912 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1913 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1914 return False;
1917 return True;
1920 /*******************************************************************
1921 inits a SAM_DISPINFO_5 structure.
1922 ********************************************************************/
1924 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1925 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1927 uint32 len_sam_name;
1928 uint32 i;
1930 ZERO_STRUCTP(sam);
1932 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1934 if (num_entries==0)
1935 return NT_STATUS_OK;
1937 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1938 return NT_STATUS_NO_MEMORY;
1940 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1941 return NT_STATUS_NO_MEMORY;
1943 ZERO_STRUCTP(sam->sam);
1944 ZERO_STRUCTP(sam->str);
1946 for (i = 0; i < num_entries; i++) {
1947 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1949 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1951 len_sam_name = strlen(grp->name);
1953 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1954 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1957 return NT_STATUS_OK;
1960 /*******************************************************************
1961 reads or writes a structure.
1962 ********************************************************************/
1964 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1965 uint32 num_entries,
1966 prs_struct *ps, int depth)
1968 uint32 i;
1970 if (sam == NULL)
1971 return False;
1973 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1974 depth++;
1976 if(!prs_align(ps))
1977 return False;
1979 if (UNMARSHALLING(ps) && num_entries > 0) {
1981 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1982 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1983 return False;
1986 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1987 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1988 return False;
1992 for (i = 0; i < num_entries; i++) {
1993 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1994 return False;
1997 for (i = 0; i < num_entries; i++) {
1998 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1999 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2000 return False;
2003 return True;
2006 /*******************************************************************
2007 inits a SAMR_R_QUERY_DISPINFO structure.
2008 ********************************************************************/
2010 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2011 uint32 num_entries, uint32 total_size, uint32 data_size,
2012 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2013 NTSTATUS status)
2015 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2017 r_u->total_size = total_size;
2019 r_u->data_size = data_size;
2021 r_u->switch_level = switch_level;
2022 r_u->num_entries = num_entries;
2024 if (num_entries==0)
2025 r_u->ptr_entries = 0;
2026 else
2027 r_u->ptr_entries = 1;
2029 r_u->num_entries2 = num_entries;
2030 r_u->ctr = ctr;
2032 r_u->status = status;
2035 /*******************************************************************
2036 reads or writes a structure.
2037 ********************************************************************/
2039 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2040 prs_struct *ps, int depth)
2042 if (r_u == NULL)
2043 return False;
2045 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2046 depth++;
2048 if(!prs_align(ps))
2049 return False;
2051 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2052 return False;
2053 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2054 return False;
2055 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2056 return False;
2057 if(!prs_align(ps))
2058 return False;
2060 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2061 return False;
2062 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2063 return False;
2065 if (r_u->ptr_entries==0) {
2066 if(!prs_align(ps))
2067 return False;
2068 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2069 return False;
2071 return True;
2074 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2075 return False;
2077 switch (r_u->switch_level) {
2078 case 0x1:
2079 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2080 r_u->num_entries, ps, depth))
2081 return False;
2082 break;
2083 case 0x2:
2084 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2085 r_u->num_entries, ps, depth))
2086 return False;
2087 break;
2088 case 0x3:
2089 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2090 r_u->num_entries, ps, depth))
2091 return False;
2092 break;
2093 case 0x4:
2094 if(!sam_io_sam_dispinfo_4("user list",
2095 r_u->ctr->sam.info4,
2096 r_u->num_entries, ps, depth))
2097 return False;
2098 break;
2099 case 0x5:
2100 if(!sam_io_sam_dispinfo_5("group list",
2101 r_u->ctr->sam.info5,
2102 r_u->num_entries, ps, depth))
2103 return False;
2104 break;
2105 default:
2106 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2107 break;
2110 if(!prs_align(ps))
2111 return False;
2112 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2113 return False;
2115 return True;
2118 /*******************************************************************
2119 inits a SAMR_Q_OPEN_GROUP structure.
2120 ********************************************************************/
2122 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2123 POLICY_HND *hnd,
2124 uint32 access_mask, uint32 rid)
2126 DEBUG(5, ("init_samr_q_open_group\n"));
2128 q_c->domain_pol = *hnd;
2129 q_c->access_mask = access_mask;
2130 q_c->rid_group = rid;
2133 /*******************************************************************
2134 reads or writes a structure.
2135 ********************************************************************/
2137 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2138 prs_struct *ps, int depth)
2140 if (q_u == NULL)
2141 return False;
2143 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2144 depth++;
2146 if(!prs_align(ps))
2147 return False;
2149 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2150 return False;
2152 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2153 return False;
2154 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2155 return False;
2157 return True;
2160 /*******************************************************************
2161 reads or writes a structure.
2162 ********************************************************************/
2164 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2165 prs_struct *ps, int depth)
2167 if (r_u == NULL)
2168 return False;
2170 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2171 depth++;
2173 if(!prs_align(ps))
2174 return False;
2176 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2177 return False;
2179 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2180 return False;
2182 return True;
2185 /*******************************************************************
2186 inits a GROUP_INFO1 structure.
2187 ********************************************************************/
2189 void init_samr_group_info1(GROUP_INFO1 * gr1,
2190 char *acct_name, char *acct_desc,
2191 uint32 num_members)
2193 DEBUG(5, ("init_samr_group_info1\n"));
2195 gr1->unknown_1 = 0x3;
2196 gr1->num_members = num_members;
2198 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2199 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2200 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2201 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2204 /*******************************************************************
2205 reads or writes a structure.
2206 ********************************************************************/
2208 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2209 prs_struct *ps, int depth)
2211 uint16 dummy = 1;
2213 if (gr1 == NULL)
2214 return False;
2216 prs_debug(ps, depth, desc, "samr_io_group_info1");
2217 depth++;
2219 if(!prs_uint16("level", ps, depth, &dummy))
2220 return False;
2222 if(!prs_align(ps))
2223 return False;
2225 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2226 return False;
2228 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2229 return False;
2230 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2231 return False;
2233 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2234 return False;
2236 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2237 gr1->hdr_acct_name.buffer, ps, depth))
2238 return False;
2240 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2241 gr1->hdr_acct_desc.buffer, ps, depth))
2242 return False;
2244 return True;
2247 /*******************************************************************
2248 inits a GROUP_INFO2 structure.
2249 ********************************************************************/
2251 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2253 DEBUG(5, ("init_samr_group_info2\n"));
2255 gr2->level = 2;
2256 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2257 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2260 /*******************************************************************
2261 reads or writes a structure.
2262 ********************************************************************/
2264 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2266 if (gr2 == NULL)
2267 return False;
2269 prs_debug(ps, depth, desc, "samr_io_group_info2");
2270 depth++;
2272 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2273 return False;
2275 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2276 return False;
2277 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2278 gr2->hdr_acct_name.buffer, ps, depth))
2279 return False;
2281 return True;
2284 /*******************************************************************
2285 inits a GROUP_INFO3 structure.
2286 ********************************************************************/
2288 void init_samr_group_info3(GROUP_INFO3 *gr3)
2290 DEBUG(5, ("init_samr_group_info3\n"));
2292 gr3->unknown_1 = 0x3;
2295 /*******************************************************************
2296 reads or writes a structure.
2297 ********************************************************************/
2299 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2301 if (gr3 == NULL)
2302 return False;
2304 prs_debug(ps, depth, desc, "samr_io_group_info3");
2305 depth++;
2307 if(!prs_align(ps))
2308 return False;
2310 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2311 return False;
2313 return True;
2316 /*******************************************************************
2317 inits a GROUP_INFO4 structure.
2318 ********************************************************************/
2320 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2322 DEBUG(5, ("init_samr_group_info4\n"));
2324 gr4->level = 4;
2325 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2326 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2329 /*******************************************************************
2330 reads or writes a structure.
2331 ********************************************************************/
2333 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2334 prs_struct *ps, int depth)
2336 if (gr4 == NULL)
2337 return False;
2339 prs_debug(ps, depth, desc, "samr_io_group_info4");
2340 depth++;
2342 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2343 return False;
2344 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2345 return False;
2346 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2347 gr4->hdr_acct_desc.buffer, ps, depth))
2348 return False;
2350 return True;
2353 /*******************************************************************
2354 reads or writes a structure.
2355 ********************************************************************/
2357 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2358 prs_struct *ps, int depth)
2360 if (UNMARSHALLING(ps))
2361 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2363 if (*ctr == NULL)
2364 return False;
2366 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2367 depth++;
2369 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2370 return False;
2372 switch ((*ctr)->switch_value1) {
2373 case 1:
2374 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2375 return False;
2376 break;
2377 case 2:
2378 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2379 return False;
2380 break;
2381 case 3:
2382 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2383 return False;
2384 break;
2385 case 4:
2386 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2387 return False;
2388 break;
2389 default:
2390 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2391 break;
2394 return True;
2397 /*******************************************************************
2398 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2399 ********************************************************************/
2401 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2402 POLICY_HND *pol, const char *acct_desc,
2403 uint32 access_mask)
2405 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2407 q_e->pol = *pol;
2409 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2410 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2412 q_e->access_mask = access_mask;
2415 /*******************************************************************
2416 reads or writes a structure.
2417 ********************************************************************/
2419 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2420 prs_struct *ps, int depth)
2422 if (q_e == NULL)
2423 return False;
2425 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2426 depth++;
2428 if(!prs_align(ps))
2429 return False;
2431 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2432 return False;
2434 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2435 return False;
2436 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2437 q_e->hdr_acct_desc.buffer, ps, depth))
2438 return False;
2440 if(!prs_align(ps))
2441 return False;
2442 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2443 return False;
2445 return True;
2448 /*******************************************************************
2449 reads or writes a structure.
2450 ********************************************************************/
2452 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2453 prs_struct *ps, int depth)
2455 if (r_u == NULL)
2456 return False;
2458 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2459 depth++;
2461 if(!prs_align(ps))
2462 return False;
2464 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2465 return False;
2467 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2468 return False;
2469 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2470 return False;
2472 return True;
2475 /*******************************************************************
2476 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2477 ********************************************************************/
2479 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2480 POLICY_HND *hnd)
2482 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2484 q_c->group_pol = *hnd;
2487 /*******************************************************************
2488 reads or writes a structure.
2489 ********************************************************************/
2491 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2492 prs_struct *ps, int depth)
2494 if (q_u == NULL)
2495 return False;
2497 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2498 depth++;
2500 if(!prs_align(ps))
2501 return False;
2503 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2504 return False;
2506 return True;
2509 /*******************************************************************
2510 reads or writes a structure.
2511 ********************************************************************/
2513 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2514 prs_struct *ps, int depth)
2516 if (r_u == NULL)
2517 return False;
2519 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2520 depth++;
2522 if(!prs_align(ps))
2523 return False;
2525 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2526 return False;
2528 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2529 return False;
2531 return True;
2534 /*******************************************************************
2535 inits a SAMR_Q_DEL_GROUPMEM structure.
2536 ********************************************************************/
2538 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2539 POLICY_HND *pol, uint32 rid)
2541 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2543 q_e->pol = *pol;
2544 q_e->rid = rid;
2547 /*******************************************************************
2548 reads or writes a structure.
2549 ********************************************************************/
2551 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2552 prs_struct *ps, int depth)
2554 if (q_e == NULL)
2555 return False;
2557 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2558 depth++;
2560 if(!prs_align(ps))
2561 return False;
2563 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2564 return False;
2566 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2567 return False;
2569 return True;
2572 /*******************************************************************
2573 inits a SAMR_R_DEL_GROUPMEM structure.
2574 ********************************************************************/
2576 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2577 NTSTATUS status)
2579 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2581 r_u->status = status;
2584 /*******************************************************************
2585 reads or writes a structure.
2586 ********************************************************************/
2588 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2589 prs_struct *ps, int depth)
2591 if (r_u == NULL)
2592 return False;
2594 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2595 depth++;
2597 if(!prs_align(ps))
2598 return False;
2600 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2601 return False;
2603 return True;
2606 /*******************************************************************
2607 inits a SAMR_Q_ADD_GROUPMEM structure.
2608 ********************************************************************/
2610 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2611 POLICY_HND *pol, uint32 rid)
2613 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2615 q_e->pol = *pol;
2616 q_e->rid = rid;
2617 q_e->unknown = 0x0005;
2620 /*******************************************************************
2621 reads or writes a structure.
2622 ********************************************************************/
2624 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2625 prs_struct *ps, int depth)
2627 if (q_e == NULL)
2628 return False;
2630 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2631 depth++;
2633 if(!prs_align(ps))
2634 return False;
2636 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2637 return False;
2639 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2640 return False;
2641 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2642 return False;
2644 return True;
2647 /*******************************************************************
2648 inits a SAMR_R_ADD_GROUPMEM structure.
2649 ********************************************************************/
2651 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2652 NTSTATUS status)
2654 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2656 r_u->status = status;
2659 /*******************************************************************
2660 reads or writes a structure.
2661 ********************************************************************/
2663 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2664 prs_struct *ps, int depth)
2666 if (r_u == NULL)
2667 return False;
2669 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2670 depth++;
2672 if(!prs_align(ps))
2673 return False;
2675 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2676 return False;
2678 return True;
2681 /*******************************************************************
2682 inits a SAMR_Q_SET_GROUPINFO structure.
2683 ********************************************************************/
2685 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2686 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2688 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2690 q_e->pol = *pol;
2691 q_e->ctr = ctr;
2694 /*******************************************************************
2695 reads or writes a structure.
2696 ********************************************************************/
2698 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2699 prs_struct *ps, int depth)
2701 if (q_e == NULL)
2702 return False;
2704 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2705 depth++;
2707 if(!prs_align(ps))
2708 return False;
2710 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2711 return False;
2713 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2714 return False;
2716 return True;
2719 /*******************************************************************
2720 inits a SAMR_R_SET_GROUPINFO structure.
2721 ********************************************************************/
2723 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2725 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2727 r_u->status = status;
2730 /*******************************************************************
2731 reads or writes a structure.
2732 ********************************************************************/
2734 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2735 prs_struct *ps, int depth)
2737 if (r_u == NULL)
2738 return False;
2740 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2741 depth++;
2743 if(!prs_align(ps))
2744 return False;
2746 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2747 return False;
2749 return True;
2752 /*******************************************************************
2753 inits a SAMR_Q_QUERY_GROUPINFO structure.
2754 ********************************************************************/
2756 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2757 POLICY_HND *pol, uint16 switch_level)
2759 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2761 q_e->pol = *pol;
2763 q_e->switch_level = switch_level;
2766 /*******************************************************************
2767 reads or writes a structure.
2768 ********************************************************************/
2770 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2771 prs_struct *ps, int depth)
2773 if (q_e == NULL)
2774 return False;
2776 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2777 depth++;
2779 if(!prs_align(ps))
2780 return False;
2782 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2783 return False;
2785 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2786 return False;
2788 return True;
2791 /*******************************************************************
2792 inits a SAMR_R_QUERY_GROUPINFO structure.
2793 ********************************************************************/
2795 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2796 GROUP_INFO_CTR * ctr, NTSTATUS status)
2798 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2800 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2801 r_u->ctr = ctr;
2802 r_u->status = status;
2805 /*******************************************************************
2806 reads or writes a structure.
2807 ********************************************************************/
2809 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2810 prs_struct *ps, int depth)
2812 if (r_u == NULL)
2813 return False;
2815 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2816 depth++;
2818 if(!prs_align(ps))
2819 return False;
2821 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2822 return False;
2824 if (r_u->ptr != 0) {
2825 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2826 return False;
2829 if(!prs_align(ps))
2830 return False;
2831 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2832 return False;
2834 return True;
2837 /*******************************************************************
2838 inits a SAMR_Q_QUERY_GROUPMEM structure.
2839 ********************************************************************/
2841 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2843 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2845 q_c->group_pol = *hnd;
2848 /*******************************************************************
2849 reads or writes a structure.
2850 ********************************************************************/
2852 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2853 prs_struct *ps, int depth)
2855 if (q_u == NULL)
2856 return False;
2858 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2859 depth++;
2861 if(!prs_align(ps))
2862 return False;
2864 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2865 return False;
2867 return True;
2870 /*******************************************************************
2871 inits a SAMR_R_QUERY_GROUPMEM structure.
2872 ********************************************************************/
2874 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2875 uint32 num_entries, uint32 *rid,
2876 uint32 *attr, NTSTATUS status)
2878 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2880 if (NT_STATUS_IS_OK(status)) {
2881 r_u->ptr = 1;
2882 r_u->num_entries = num_entries;
2884 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2885 r_u->ptr_rids = rid != NULL ? 1 : 0;
2887 r_u->num_rids = num_entries;
2888 r_u->rid = rid;
2890 r_u->num_attrs = num_entries;
2891 r_u->attr = attr;
2892 } else {
2893 r_u->ptr = 0;
2894 r_u->num_entries = 0;
2897 r_u->status = status;
2900 /*******************************************************************
2901 reads or writes a structure.
2902 ********************************************************************/
2904 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2905 prs_struct *ps, int depth)
2907 uint32 i;
2909 if (r_u == NULL)
2910 return False;
2912 if (UNMARSHALLING(ps))
2913 ZERO_STRUCTP(r_u);
2915 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2916 depth++;
2918 if(!prs_align(ps))
2919 return False;
2921 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2922 return False;
2923 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2924 return False;
2926 if (r_u->ptr != 0) {
2927 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2928 return False;
2929 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2930 return False;
2932 if (r_u->ptr_rids != 0) {
2933 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2934 return False;
2935 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2936 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2937 if (r_u->rid == NULL)
2938 return False;
2941 for (i = 0; i < r_u->num_rids; i++) {
2942 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2943 return False;
2947 if (r_u->ptr_attrs != 0) {
2948 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2949 return False;
2951 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2952 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2953 if (r_u->attr == NULL)
2954 return False;
2957 for (i = 0; i < r_u->num_attrs; i++) {
2958 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2959 return False;
2964 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2965 return False;
2967 return True;
2970 /*******************************************************************
2971 inits a SAMR_Q_QUERY_USERGROUPS structure.
2972 ********************************************************************/
2974 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2975 POLICY_HND *hnd)
2977 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2979 q_u->pol = *hnd;
2982 /*******************************************************************
2983 reads or writes a structure.
2984 ********************************************************************/
2986 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2987 prs_struct *ps, int depth)
2989 if (q_u == NULL)
2990 return False;
2992 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2993 depth++;
2995 if(!prs_align(ps))
2996 return False;
2998 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2999 return False;
3001 return True;
3004 /*******************************************************************
3005 inits a SAMR_R_QUERY_USERGROUPS structure.
3006 ********************************************************************/
3008 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3009 uint32 num_gids, DOM_GID * gid,
3010 NTSTATUS status)
3012 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3014 if (NT_STATUS_IS_OK(status)) {
3015 r_u->ptr_0 = 1;
3016 r_u->num_entries = num_gids;
3017 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3018 r_u->num_entries2 = num_gids;
3020 r_u->gid = gid;
3021 } else {
3022 r_u->ptr_0 = 0;
3023 r_u->num_entries = 0;
3024 r_u->ptr_1 = 0;
3025 r_u->gid = NULL;
3028 r_u->status = status;
3031 /*******************************************************************
3032 reads or writes a structure.
3033 ********************************************************************/
3035 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3036 prs_struct *ps, int depth)
3038 uint32 i;
3039 if (gid == NULL)
3040 return False;
3042 prs_debug(ps, depth, desc, "samr_io_gids");
3043 depth++;
3045 if(!prs_align(ps))
3046 return False;
3048 if(!prs_uint32("num_gids", ps, depth, num_gids))
3049 return False;
3051 if ((*num_gids) != 0) {
3052 if (UNMARSHALLING(ps)) {
3053 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3056 if ((*gid) == NULL) {
3057 return False;
3060 for (i = 0; i < (*num_gids); i++) {
3061 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3062 return False;
3066 return True;
3069 /*******************************************************************
3070 reads or writes a structure.
3071 ********************************************************************/
3073 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3074 prs_struct *ps, int depth)
3076 if (r_u == NULL)
3077 return False;
3079 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3080 depth++;
3082 if(!prs_align(ps))
3083 return False;
3085 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3086 return False;
3088 if (r_u->ptr_0 != 0) {
3089 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3090 return False;
3091 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3092 return False;
3094 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3095 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3096 return False;
3100 if(!prs_align(ps))
3101 return False;
3102 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3103 return False;
3105 return True;
3108 /*******************************************************************
3109 inits a SAMR_Q_ENUM_DOMAINS structure.
3110 ********************************************************************/
3112 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3113 POLICY_HND *pol,
3114 uint32 start_idx, uint32 size)
3116 DEBUG(5, ("init_samr_q_enum_domains\n"));
3118 q_e->pol = *pol;
3120 q_e->start_idx = start_idx;
3121 q_e->max_size = size;
3124 /*******************************************************************
3125 reads or writes a structure.
3126 ********************************************************************/
3128 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3129 prs_struct *ps, int depth)
3131 if (q_e == NULL)
3132 return False;
3134 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3135 depth++;
3137 if(!prs_align(ps))
3138 return False;
3140 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3141 return False;
3143 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3144 return False;
3145 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3146 return False;
3148 return True;
3151 /*******************************************************************
3152 inits a SAMR_R_ENUM_DOMAINS structure.
3153 ********************************************************************/
3155 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3156 uint32 next_idx, uint32 num_sam_entries)
3158 DEBUG(5, ("init_samr_r_enum_domains\n"));
3160 r_u->next_idx = next_idx;
3162 if (num_sam_entries != 0) {
3163 r_u->ptr_entries1 = 1;
3164 r_u->ptr_entries2 = 1;
3165 r_u->num_entries2 = num_sam_entries;
3166 r_u->num_entries3 = num_sam_entries;
3168 r_u->num_entries4 = num_sam_entries;
3169 } else {
3170 r_u->ptr_entries1 = 0;
3171 r_u->num_entries2 = num_sam_entries;
3172 r_u->ptr_entries2 = 1;
3176 /*******************************************************************
3177 reads or writes a structure.
3178 ********************************************************************/
3180 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3181 prs_struct *ps, int depth)
3183 uint32 i;
3185 if (r_u == NULL)
3186 return False;
3188 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3189 depth++;
3191 if(!prs_align(ps))
3192 return False;
3194 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3195 return False;
3196 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3197 return False;
3199 if (r_u->ptr_entries1 != 0) {
3200 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3201 return False;
3202 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3203 return False;
3204 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3205 return False;
3207 if (UNMARSHALLING(ps)) {
3208 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3209 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3212 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3213 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3214 r_u->num_entries4 = 0;
3215 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3216 return False;
3219 for (i = 0; i < r_u->num_entries2; i++) {
3220 fstring tmp;
3221 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3222 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3223 return False;
3226 for (i = 0; i < r_u->num_entries2; i++) {
3227 fstring tmp;
3228 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3229 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3230 r_u->sam[i].hdr_name.buffer, ps,
3231 depth))
3232 return False;
3237 if(!prs_align(ps))
3238 return False;
3239 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3240 return False;
3241 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3242 return False;
3244 return True;
3247 /*******************************************************************
3248 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3249 ********************************************************************/
3251 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3252 POLICY_HND *pol,
3253 uint32 start_idx, uint32 size)
3255 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3257 q_e->pol = *pol;
3259 q_e->start_idx = start_idx;
3260 q_e->max_size = size;
3263 /*******************************************************************
3264 reads or writes a structure.
3265 ********************************************************************/
3267 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3268 prs_struct *ps, int depth)
3270 if (q_e == NULL)
3271 return False;
3273 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3274 depth++;
3276 if(!prs_align(ps))
3277 return False;
3279 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3280 return False;
3282 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3283 return False;
3284 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3285 return False;
3287 return True;
3290 /*******************************************************************
3291 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3292 ********************************************************************/
3294 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3295 uint32 next_idx, uint32 num_sam_entries)
3297 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3299 r_u->next_idx = next_idx;
3301 if (num_sam_entries != 0) {
3302 r_u->ptr_entries1 = 1;
3303 r_u->ptr_entries2 = 1;
3304 r_u->num_entries2 = num_sam_entries;
3305 r_u->num_entries3 = num_sam_entries;
3307 r_u->num_entries4 = num_sam_entries;
3308 } else {
3309 r_u->ptr_entries1 = 0;
3310 r_u->num_entries2 = num_sam_entries;
3311 r_u->ptr_entries2 = 1;
3315 /*******************************************************************
3316 reads or writes a structure.
3317 ********************************************************************/
3319 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3320 prs_struct *ps, int depth)
3322 uint32 i;
3324 if (r_u == NULL)
3325 return False;
3327 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3328 depth++;
3330 if(!prs_align(ps))
3331 return False;
3333 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3334 return False;
3335 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3336 return False;
3338 if (r_u->ptr_entries1 != 0) {
3339 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3340 return False;
3341 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3342 return False;
3343 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3344 return False;
3346 if (UNMARSHALLING(ps)) {
3347 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3348 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3351 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3352 DEBUG(0,
3353 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3354 r_u->num_entries4 = 0;
3355 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3356 return False;
3359 for (i = 0; i < r_u->num_entries2; i++) {
3360 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3361 return False;
3364 for (i = 0; i < r_u->num_entries2; i++) {
3365 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3366 r_u->sam[i].hdr_name.buffer, ps, depth))
3367 return False;
3371 if(!prs_align(ps))
3372 return False;
3373 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3374 return False;
3375 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3376 return False;
3378 return True;
3381 /*******************************************************************
3382 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3383 ********************************************************************/
3385 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3386 POLICY_HND *pol, uint32 start_idx,
3387 uint32 size)
3389 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3391 q_e->pol = *pol;
3393 q_e->start_idx = start_idx;
3394 q_e->max_size = size;
3398 /*******************************************************************
3399 reads or writes a structure.
3400 ********************************************************************/
3402 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3403 prs_struct *ps, int depth)
3405 if (q_e == NULL)
3406 return False;
3408 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3409 depth++;
3411 if(!prs_align(ps))
3412 return False;
3414 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3415 return False;
3417 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3418 return False;
3419 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3420 return False;
3422 return True;
3425 /*******************************************************************
3426 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3427 ********************************************************************/
3429 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3431 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3433 r_u->next_idx = next_idx;
3435 if (num_sam_entries != 0) {
3436 r_u->ptr_entries1 = 1;
3437 r_u->ptr_entries2 = 1;
3438 r_u->num_entries2 = num_sam_entries;
3439 r_u->num_entries3 = num_sam_entries;
3441 r_u->num_entries4 = num_sam_entries;
3442 } else {
3443 r_u->ptr_entries1 = 0;
3444 r_u->num_entries2 = num_sam_entries;
3445 r_u->ptr_entries2 = 1;
3449 /*******************************************************************
3450 reads or writes a structure.
3451 ********************************************************************/
3453 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3454 prs_struct *ps, int depth)
3456 uint32 i;
3458 if (r_u == NULL)
3459 return False;
3461 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3462 depth++;
3464 if(!prs_align(ps))
3465 return False;
3467 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3468 return False;
3469 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3470 return False;
3472 if (r_u->ptr_entries1 != 0) {
3473 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3474 return False;
3475 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3476 return False;
3477 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3478 return False;
3480 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3481 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3482 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3485 if (r_u->num_entries2 != 0 &&
3486 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3487 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3488 r_u->num_entries4 = 0;
3489 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3490 return False;
3493 for (i = 0; i < r_u->num_entries2; i++) {
3494 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3495 return False;
3498 for (i = 0; i < r_u->num_entries2; i++) {
3499 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3500 r_u->sam[i].hdr_name.buffer, ps,
3501 depth))
3502 return False;
3506 if(!prs_align(ps))
3507 return False;
3508 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3509 return False;
3510 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3511 return False;
3513 return True;
3516 /*******************************************************************
3517 inits a ALIAS_INFO1 structure.
3518 ********************************************************************/
3520 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3522 DEBUG(5, ("init_samr_alias_info1\n"));
3524 init_unistr2(&al1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
3525 init_uni_hdr(&al1->hdr_acct_name, &al1->uni_acct_name);
3527 al1->num_member=num_member;
3529 init_unistr2(&al1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3530 init_uni_hdr(&al1->hdr_acct_desc, &al1->uni_acct_name);
3533 /*******************************************************************
3534 reads or writes a structure.
3535 ********************************************************************/
3537 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3538 prs_struct *ps, int depth)
3540 if (al1 == NULL)
3541 return False;
3543 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3544 depth++;
3546 if(!prs_align(ps))
3547 return False;
3549 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3550 return False;
3551 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3552 return False;
3553 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3554 return False;
3556 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3557 al1->hdr_acct_name.buffer, ps, depth))
3558 return False;
3560 if(!prs_align(ps))
3561 return False;
3563 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3564 al1->hdr_acct_desc.buffer, ps, depth))
3565 return False;
3567 return True;
3570 /*******************************************************************
3571 inits a ALIAS_INFO3 structure.
3572 ********************************************************************/
3574 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3576 DEBUG(5, ("init_samr_alias_info3\n"));
3578 init_unistr2(&al3->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
3579 init_uni_hdr(&al3->hdr_acct_desc, &al3->uni_acct_desc);
3582 /*******************************************************************
3583 reads or writes a structure.
3584 ********************************************************************/
3586 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
3587 prs_struct *ps, int depth)
3589 if (al3 == NULL)
3590 return False;
3592 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3593 depth++;
3595 if(!prs_align(ps))
3596 return False;
3598 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3599 return False;
3600 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3601 al3->hdr_acct_desc.buffer, ps, depth))
3602 return False;
3604 return True;
3607 /*******************************************************************
3608 reads or writes a structure.
3609 ********************************************************************/
3611 BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr,
3612 prs_struct *ps, int depth)
3614 if (ctr == NULL)
3615 return False;
3617 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3618 depth++;
3620 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3621 return False;
3622 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3623 return False;
3625 switch (ctr->switch_value1) {
3626 case 1:
3627 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3628 return False;
3629 break;
3630 case 3:
3631 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3632 return False;
3633 break;
3634 default:
3635 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3636 break;
3639 return True;
3642 /*******************************************************************
3643 inits a SAMR_Q_QUERY_ALIASINFO structure.
3644 ********************************************************************/
3646 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3647 POLICY_HND *pol, uint16 switch_level)
3649 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3651 q_e->pol = *pol;
3652 q_e->switch_level = switch_level;
3655 /*******************************************************************
3656 reads or writes a structure.
3657 ********************************************************************/
3659 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3660 prs_struct *ps, int depth)
3662 if (q_e == NULL)
3663 return False;
3665 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3666 depth++;
3668 if(!prs_align(ps))
3669 return False;
3671 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3672 return False;
3674 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3675 return False;
3677 return True;
3680 /*******************************************************************
3681 inits a SAMR_R_QUERY_ALIASINFO structure.
3682 ********************************************************************/
3684 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3685 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3687 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3689 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3690 r_u->ctr = *ctr;
3691 r_u->status = status;
3694 /*******************************************************************
3695 reads or writes a structure.
3696 ********************************************************************/
3698 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3699 prs_struct *ps, int depth)
3701 if (r_u == NULL)
3702 return False;
3704 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3705 depth++;
3707 if(!prs_align(ps))
3708 return False;
3710 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3711 return False;
3713 if (r_u->ptr != 0) {
3714 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3715 return False;
3718 if(!prs_align(ps))
3719 return False;
3720 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3721 return False;
3723 return True;
3726 /*******************************************************************
3727 inits a SAMR_Q_SET_ALIASINFO structure.
3728 ********************************************************************/
3730 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3731 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3733 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3735 q_u->alias_pol = *hnd;
3736 q_u->ctr = *ctr;
3739 /*******************************************************************
3740 reads or writes a structure.
3741 ********************************************************************/
3743 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3744 prs_struct *ps, int depth)
3746 if (q_u == NULL)
3747 return False;
3749 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3750 depth++;
3752 if(!prs_align(ps))
3753 return False;
3755 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3756 return False;
3757 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3758 return False;
3760 return True;
3763 /*******************************************************************
3764 reads or writes a structure.
3765 ********************************************************************/
3767 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3768 prs_struct *ps, int depth)
3770 if (r_u == NULL)
3771 return False;
3773 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3774 depth++;
3776 if(!prs_align(ps))
3777 return False;
3778 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3779 return False;
3781 return True;
3784 /*******************************************************************
3785 inits a SAMR_Q_QUERY_USERALIASES structure.
3786 ********************************************************************/
3788 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3789 POLICY_HND *hnd,
3790 uint32 num_sids,
3791 uint32 *ptr_sid, DOM_SID2 * sid)
3793 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3795 q_u->pol = *hnd;
3797 q_u->num_sids1 = num_sids;
3798 q_u->ptr = 1;
3799 q_u->num_sids2 = num_sids;
3801 q_u->ptr_sid = ptr_sid;
3802 q_u->sid = sid;
3805 /*******************************************************************
3806 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3807 ********************************************************************/
3809 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3810 prs_struct *ps, int depth)
3812 fstring tmp;
3813 uint32 i;
3815 if (q_u == NULL)
3816 return False;
3818 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3819 depth++;
3821 if(!prs_align(ps))
3822 return False;
3824 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3825 return False;
3827 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3828 return False;
3829 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3830 return False;
3832 if (q_u->ptr==0)
3833 return True;
3835 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3836 return False;
3838 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3839 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3840 if (q_u->ptr_sid == NULL)
3841 return False;
3843 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3844 if (q_u->sid == NULL)
3845 return False;
3848 for (i = 0; i < q_u->num_sids2; i++) {
3849 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3850 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3851 return False;
3854 for (i = 0; i < q_u->num_sids2; i++) {
3855 if (q_u->ptr_sid[i] != 0) {
3856 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3857 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3858 return False;
3862 return True;
3865 /*******************************************************************
3866 inits a SAMR_R_QUERY_USERALIASES structure.
3867 ********************************************************************/
3869 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3870 uint32 num_rids, uint32 *rid,
3871 NTSTATUS status)
3873 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3875 if (NT_STATUS_IS_OK(status)) {
3876 r_u->num_entries = num_rids;
3877 r_u->ptr = 1;
3878 r_u->num_entries2 = num_rids;
3880 r_u->rid = rid;
3881 } else {
3882 r_u->num_entries = 0;
3883 r_u->ptr = 0;
3884 r_u->num_entries2 = 0;
3887 r_u->status = status;
3890 /*******************************************************************
3891 reads or writes a structure.
3892 ********************************************************************/
3894 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3895 prs_struct *ps, int depth)
3897 fstring tmp;
3898 uint32 i;
3899 if (rid == NULL)
3900 return False;
3902 prs_debug(ps, depth, desc, "samr_io_rids");
3903 depth++;
3905 if(!prs_align(ps))
3906 return False;
3908 if(!prs_uint32("num_rids", ps, depth, num_rids))
3909 return False;
3911 if ((*num_rids) != 0) {
3912 if (UNMARSHALLING(ps)) {
3913 /* reading */
3914 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3916 if ((*rid) == NULL)
3917 return False;
3919 for (i = 0; i < (*num_rids); i++) {
3920 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3921 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3922 return False;
3926 return True;
3929 /*******************************************************************
3930 reads or writes a structure.
3931 ********************************************************************/
3933 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3934 prs_struct *ps, int depth)
3936 if (r_u == NULL)
3937 return False;
3939 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3940 depth++;
3942 if(!prs_align(ps))
3943 return False;
3945 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3946 return False;
3947 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3948 return False;
3950 if (r_u->ptr != 0) {
3951 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3952 return False;
3955 if(!prs_align(ps))
3956 return False;
3957 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3958 return False;
3960 return True;
3963 /*******************************************************************
3964 inits a SAMR_Q_OPEN_ALIAS structure.
3965 ********************************************************************/
3967 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3968 uint32 access_mask, uint32 rid)
3970 DEBUG(5, ("init_samr_q_open_alias\n"));
3972 q_u->dom_pol = *pol;
3973 q_u->access_mask = access_mask;
3974 q_u->rid_alias = rid;
3977 /*******************************************************************
3978 reads or writes a structure.
3979 ********************************************************************/
3981 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3982 prs_struct *ps, int depth)
3984 if (q_u == NULL)
3985 return False;
3987 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3988 depth++;
3990 if(!prs_align(ps))
3991 return False;
3993 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3994 return False;
3996 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3997 return False;
3998 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3999 return False;
4001 return True;
4004 /*******************************************************************
4005 reads or writes a structure.
4006 ********************************************************************/
4008 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4009 prs_struct *ps, int depth)
4011 if (r_u == NULL)
4012 return False;
4014 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4015 depth++;
4017 if(!prs_align(ps))
4018 return False;
4020 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4021 return False;
4023 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4024 return False;
4026 return True;
4029 /*******************************************************************
4030 inits a SAMR_Q_LOOKUP_RIDS structure.
4031 ********************************************************************/
4033 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4034 POLICY_HND *pol, uint32 flags,
4035 uint32 num_rids, uint32 *rid)
4037 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4039 q_u->pol = *pol;
4041 q_u->num_rids1 = num_rids;
4042 q_u->flags = flags;
4043 q_u->ptr = 0;
4044 q_u->num_rids2 = num_rids;
4045 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4046 if (q_u->rid == NULL) {
4047 q_u->num_rids1 = 0;
4048 q_u->num_rids2 = 0;
4049 } else {
4050 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4054 /*******************************************************************
4055 reads or writes a structure.
4056 ********************************************************************/
4058 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4059 prs_struct *ps, int depth)
4061 uint32 i;
4062 fstring tmp;
4064 if (q_u == NULL)
4065 return False;
4067 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4068 depth++;
4070 if (UNMARSHALLING(ps))
4071 ZERO_STRUCTP(q_u);
4073 if(!prs_align(ps))
4074 return False;
4076 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4077 return False;
4079 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4080 return False;
4081 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4082 return False;
4083 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4084 return False;
4085 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4086 return False;
4088 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4089 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4090 if (q_u->rid == NULL)
4091 return False;
4094 for (i = 0; i < q_u->num_rids2; i++) {
4095 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4096 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4097 return False;
4100 return True;
4103 /*******************************************************************
4104 inits a SAMR_R_LOOKUP_RIDS structure.
4105 ********************************************************************/
4107 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4108 uint32 num_names, UNIHDR * hdr_name,
4109 UNISTR2 *uni_name, uint32 *type)
4111 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4113 r_u->hdr_name = NULL;
4114 r_u->uni_name = NULL;
4115 r_u->type = NULL;
4117 if (num_names != 0) {
4118 r_u->num_names1 = num_names;
4119 r_u->ptr_names = 1;
4120 r_u->num_names2 = num_names;
4122 r_u->num_types1 = num_names;
4123 r_u->ptr_types = 1;
4124 r_u->num_types2 = num_names;
4126 r_u->hdr_name = hdr_name;
4127 r_u->uni_name = uni_name;
4128 r_u->type = type;
4129 } else {
4130 r_u->num_names1 = num_names;
4131 r_u->ptr_names = 0;
4132 r_u->num_names2 = num_names;
4134 r_u->num_types1 = num_names;
4135 r_u->ptr_types = 0;
4136 r_u->num_types2 = num_names;
4140 /*******************************************************************
4141 reads or writes a structure.
4142 ********************************************************************/
4144 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4145 prs_struct *ps, int depth)
4147 uint32 i;
4148 fstring tmp;
4149 if (r_u == NULL)
4150 return False;
4152 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4153 depth++;
4155 if(!prs_align(ps))
4156 return False;
4158 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4159 return False;
4160 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4161 return False;
4163 if (r_u->ptr_names != 0) {
4165 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4166 return False;
4169 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4170 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4171 if (r_u->hdr_name == NULL)
4172 return False;
4174 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4175 if (r_u->uni_name == NULL)
4176 return False;
4179 for (i = 0; i < r_u->num_names2; i++) {
4180 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4181 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4182 return False;
4184 for (i = 0; i < r_u->num_names2; i++) {
4185 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4186 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4187 return False;
4192 if(!prs_align(ps))
4193 return False;
4194 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4195 return False;
4196 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4197 return False;
4199 if (r_u->ptr_types != 0) {
4201 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4202 return False;
4204 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4205 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4206 if (r_u->type == NULL)
4207 return False;
4210 for (i = 0; i < r_u->num_types2; i++) {
4211 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4212 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4213 return False;
4217 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4218 return False;
4220 return True;
4223 /*******************************************************************
4224 inits a SAMR_Q_OPEN_ALIAS structure.
4225 ********************************************************************/
4227 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4229 DEBUG(5, ("init_samr_q_delete_alias\n"));
4231 q_u->alias_pol = *hnd;
4234 /*******************************************************************
4235 reads or writes a structure.
4236 ********************************************************************/
4238 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4239 prs_struct *ps, int depth)
4241 if (q_u == NULL)
4242 return False;
4244 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4245 depth++;
4247 if(!prs_align(ps))
4248 return False;
4250 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4251 return False;
4253 return True;
4256 /*******************************************************************
4257 reads or writes a structure.
4258 ********************************************************************/
4260 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4261 prs_struct *ps, int depth)
4263 if (r_u == NULL)
4264 return False;
4266 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4267 depth++;
4269 if(!prs_align(ps))
4270 return False;
4272 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4273 return False;
4274 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4275 return False;
4277 return True;
4280 /*******************************************************************
4281 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4282 ********************************************************************/
4284 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4285 POLICY_HND *hnd, const char *acct_desc)
4287 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4289 q_u->dom_pol = *hnd;
4291 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4292 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4294 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4297 /*******************************************************************
4298 reads or writes a structure.
4299 ********************************************************************/
4301 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4302 prs_struct *ps, int depth)
4304 if (q_u == NULL)
4305 return False;
4307 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4308 depth++;
4310 if(!prs_align(ps))
4311 return False;
4313 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4314 return False;
4316 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4317 return False;
4318 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4319 q_u->hdr_acct_desc.buffer, ps, depth))
4320 return False;
4322 if(!prs_align(ps))
4323 return False;
4324 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4325 return False;
4327 return True;
4330 /*******************************************************************
4331 reads or writes a structure.
4332 ********************************************************************/
4334 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4335 prs_struct *ps, int depth)
4337 if (r_u == NULL)
4338 return False;
4340 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4341 depth++;
4343 if(!prs_align(ps))
4344 return False;
4346 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4347 return False;
4349 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4350 return False;
4352 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4353 return False;
4355 return True;
4358 /*******************************************************************
4359 inits a SAMR_Q_ADD_ALIASMEM structure.
4360 ********************************************************************/
4362 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4363 DOM_SID *sid)
4365 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4367 q_u->alias_pol = *hnd;
4368 init_dom_sid2(&q_u->sid, sid);
4371 /*******************************************************************
4372 reads or writes a structure.
4373 ********************************************************************/
4375 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4376 prs_struct *ps, int depth)
4378 if (q_u == NULL)
4379 return False;
4381 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4382 depth++;
4384 if(!prs_align(ps))
4385 return False;
4387 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4388 return False;
4389 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4390 return False;
4392 return True;
4395 /*******************************************************************
4396 reads or writes a structure.
4397 ********************************************************************/
4399 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4400 prs_struct *ps, int depth)
4402 if (r_u == NULL)
4403 return False;
4405 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4406 depth++;
4408 if(!prs_align(ps))
4409 return False;
4411 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4412 return False;
4414 return True;
4417 /*******************************************************************
4418 inits a SAMR_Q_DEL_ALIASMEM structure.
4419 ********************************************************************/
4421 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4422 DOM_SID *sid)
4424 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4426 q_u->alias_pol = *hnd;
4427 init_dom_sid2(&q_u->sid, sid);
4430 /*******************************************************************
4431 reads or writes a structure.
4432 ********************************************************************/
4434 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4435 prs_struct *ps, int depth)
4437 if (q_u == NULL)
4438 return False;
4440 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4441 depth++;
4443 if(!prs_align(ps))
4444 return False;
4446 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4447 return False;
4448 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4449 return False;
4451 return True;
4454 /*******************************************************************
4455 reads or writes a structure.
4456 ********************************************************************/
4458 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4459 prs_struct *ps, int depth)
4461 if (r_u == NULL)
4462 return False;
4464 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4465 depth++;
4467 if(!prs_align(ps))
4468 return False;
4470 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4471 return False;
4473 return True;
4476 /*******************************************************************
4477 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4478 ********************************************************************/
4480 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4481 POLICY_HND *hnd)
4483 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4485 q_c->alias_pol = *hnd;
4488 /*******************************************************************
4489 reads or writes a structure.
4490 ********************************************************************/
4492 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4493 prs_struct *ps, int depth)
4495 if (q_u == NULL)
4496 return False;
4498 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4499 depth++;
4501 if(!prs_align(ps))
4502 return False;
4504 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4505 return False;
4507 return True;
4510 /*******************************************************************
4511 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4512 ********************************************************************/
4514 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4515 NTSTATUS status)
4517 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4519 r_u->status = status;
4522 /*******************************************************************
4523 reads or writes a structure.
4524 ********************************************************************/
4526 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4527 prs_struct *ps, int depth)
4529 if (r_u == NULL)
4530 return False;
4532 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4533 depth++;
4535 if(!prs_align(ps))
4536 return False;
4538 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4539 return False;
4541 return True;
4544 /*******************************************************************
4545 inits a SAMR_Q_QUERY_ALIASMEM structure.
4546 ********************************************************************/
4548 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4549 POLICY_HND *hnd)
4551 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4553 q_c->alias_pol = *hnd;
4556 /*******************************************************************
4557 reads or writes a structure.
4558 ********************************************************************/
4560 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4561 prs_struct *ps, int depth)
4563 if (q_u == NULL)
4564 return False;
4566 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4567 depth++;
4569 if(!prs_align(ps))
4570 return False;
4572 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4573 return False;
4575 return True;
4578 /*******************************************************************
4579 inits a SAMR_R_QUERY_ALIASMEM structure.
4580 ********************************************************************/
4582 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4583 uint32 num_sids, DOM_SID2 * sid,
4584 NTSTATUS status)
4586 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4588 if (NT_STATUS_IS_OK(status)) {
4589 r_u->num_sids = num_sids;
4590 r_u->ptr = (num_sids != 0) ? 1 : 0;
4591 r_u->num_sids1 = num_sids;
4593 r_u->sid = sid;
4594 } else {
4595 r_u->ptr = 0;
4596 r_u->num_sids = 0;
4599 r_u->status = status;
4602 /*******************************************************************
4603 reads or writes a structure.
4604 ********************************************************************/
4606 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4607 prs_struct *ps, int depth)
4609 uint32 i;
4611 if (r_u == NULL)
4612 return False;
4614 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4615 depth++;
4617 if(!prs_align(ps))
4618 return False;
4620 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4621 return False;
4622 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4623 return False;
4625 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4626 uint32 *ptr_sid = NULL;
4628 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4629 return False;
4631 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4632 if (!ptr_sid) {
4633 return False;
4636 for (i = 0; i < r_u->num_sids1; i++) {
4637 ptr_sid[i] = 1;
4638 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4639 return False;
4642 if (UNMARSHALLING(ps)) {
4643 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4646 for (i = 0; i < r_u->num_sids1; i++) {
4647 if (ptr_sid[i] != 0) {
4648 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4649 return False;
4654 if(!prs_align(ps))
4655 return False;
4656 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4657 return False;
4659 return True;
4662 /*******************************************************************
4663 inits a SAMR_Q_LOOKUP_NAMES structure.
4664 ********************************************************************/
4666 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4667 POLICY_HND *pol, uint32 flags,
4668 uint32 num_names, const char **name)
4670 uint32 i;
4672 DEBUG(5, ("init_samr_q_lookup_names\n"));
4674 q_u->pol = *pol;
4676 q_u->num_names1 = num_names;
4677 q_u->flags = flags;
4678 q_u->ptr = 0;
4679 q_u->num_names2 = num_names;
4681 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4682 return NT_STATUS_NO_MEMORY;
4684 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4685 return NT_STATUS_NO_MEMORY;
4687 for (i = 0; i < num_names; i++) {
4688 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4689 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4692 return NT_STATUS_OK;
4695 /*******************************************************************
4696 reads or writes a structure.
4697 ********************************************************************/
4699 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4700 prs_struct *ps, int depth)
4702 uint32 i;
4704 if (q_u == NULL)
4705 return False;
4707 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4708 depth++;
4710 if (UNMARSHALLING(ps))
4711 ZERO_STRUCTP(q_u);
4713 if(!prs_align(ps))
4714 return False;
4716 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4717 return False;
4719 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4720 return False;
4721 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4722 return False;
4723 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4724 return False;
4725 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4726 return False;
4728 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4729 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4730 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4731 if (!q_u->hdr_name || !q_u->uni_name)
4732 return False;
4735 for (i = 0; i < q_u->num_names2; i++) {
4736 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4737 return False;
4740 for (i = 0; i < q_u->num_names2; i++) {
4741 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4742 return False;
4745 return True;
4748 /*******************************************************************
4749 inits a SAMR_R_LOOKUP_NAMES structure.
4750 ********************************************************************/
4752 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4753 uint32 num_rids,
4754 uint32 *rid, uint32 *type,
4755 NTSTATUS status)
4757 DEBUG(5, ("init_samr_r_lookup_names\n"));
4759 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4760 uint32 i;
4762 r_u->num_types1 = num_rids;
4763 r_u->ptr_types = 1;
4764 r_u->num_types2 = num_rids;
4766 r_u->num_rids1 = num_rids;
4767 r_u->ptr_rids = 1;
4768 r_u->num_rids2 = num_rids;
4770 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4771 return NT_STATUS_NO_MEMORY;
4772 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4773 return NT_STATUS_NO_MEMORY;
4775 if (!r_u->rids || !r_u->types)
4776 goto empty;
4778 for (i = 0; i < num_rids; i++) {
4779 r_u->rids[i] = rid[i];
4780 r_u->types[i] = type[i];
4782 } else {
4784 empty:
4785 r_u->num_types1 = 0;
4786 r_u->ptr_types = 0;
4787 r_u->num_types2 = 0;
4789 r_u->num_rids1 = 0;
4790 r_u->ptr_rids = 0;
4791 r_u->num_rids2 = 0;
4793 r_u->rids = NULL;
4794 r_u->types = NULL;
4797 r_u->status = status;
4799 return NT_STATUS_OK;
4802 /*******************************************************************
4803 reads or writes a structure.
4804 ********************************************************************/
4806 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4807 prs_struct *ps, int depth)
4809 uint32 i;
4810 fstring tmp;
4812 if (r_u == NULL)
4813 return False;
4815 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4816 depth++;
4818 if (UNMARSHALLING(ps))
4819 ZERO_STRUCTP(r_u);
4821 if(!prs_align(ps))
4822 return False;
4824 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4825 return False;
4826 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4827 return False;
4829 if (r_u->ptr_rids != 0) {
4830 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4831 return False;
4833 if (r_u->num_rids2 != r_u->num_rids1) {
4834 /* RPC fault */
4835 return False;
4838 if (UNMARSHALLING(ps))
4839 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4841 if (!r_u->rids) {
4842 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4843 return False;
4846 for (i = 0; i < r_u->num_rids2; i++) {
4847 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4848 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4849 return False;
4853 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4854 return False;
4855 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4856 return False;
4858 if (r_u->ptr_types != 0) {
4859 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4860 return False;
4862 if (r_u->num_types2 != r_u->num_types1) {
4863 /* RPC fault */
4864 return False;
4867 if (UNMARSHALLING(ps))
4868 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4870 if (!r_u->types) {
4871 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4872 return False;
4875 for (i = 0; i < r_u->num_types2; i++) {
4876 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4877 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4878 return False;
4882 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4883 return False;
4885 return True;
4888 /*******************************************************************
4889 inits a SAMR_Q_DELETE_DOM_USER structure.
4890 ********************************************************************/
4892 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4893 POLICY_HND *hnd)
4895 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4897 q_c->user_pol = *hnd;
4900 /*******************************************************************
4901 reads or writes a structure.
4902 ********************************************************************/
4904 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4905 prs_struct *ps, int depth)
4907 if (q_u == NULL)
4908 return False;
4910 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4911 depth++;
4913 if(!prs_align(ps))
4914 return False;
4916 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4917 return False;
4919 return True;
4922 /*******************************************************************
4923 reads or writes a structure.
4924 ********************************************************************/
4926 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4927 prs_struct *ps, int depth)
4929 if (r_u == NULL)
4930 return False;
4932 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4933 depth++;
4935 if(!prs_align(ps))
4936 return False;
4938 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4939 return False;
4940 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4941 return False;
4943 return True;
4946 /*******************************************************************
4947 reads or writes a structure.
4948 ********************************************************************/
4950 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4951 POLICY_HND *pol,
4952 uint32 access_mask, uint32 rid)
4954 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4956 q_u->domain_pol = *pol;
4957 q_u->access_mask = access_mask;
4958 q_u->user_rid = rid;
4961 /*******************************************************************
4962 reads or writes a structure.
4963 ********************************************************************/
4965 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4966 prs_struct *ps, int depth)
4968 if (q_u == NULL)
4969 return False;
4971 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4972 depth++;
4974 if(!prs_align(ps))
4975 return False;
4977 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4978 return False;
4980 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4981 return False;
4982 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4983 return False;
4985 return True;
4988 /*******************************************************************
4989 reads or writes a structure.
4990 ********************************************************************/
4992 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4993 prs_struct *ps, int depth)
4995 if (r_u == NULL)
4996 return False;
4998 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4999 depth++;
5001 if(!prs_align(ps))
5002 return False;
5004 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5005 return False;
5007 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5008 return False;
5010 return True;
5014 /*******************************************************************
5015 reads or writes a structure.
5016 ********************************************************************/
5018 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5019 POLICY_HND *pol,
5020 const char *name,
5021 uint32 acb_info, uint32 access_mask)
5023 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5025 q_u->domain_pol = *pol;
5027 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5028 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5030 q_u->acb_info = acb_info;
5031 q_u->access_mask = access_mask;
5034 /*******************************************************************
5035 reads or writes a structure.
5036 ********************************************************************/
5038 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5039 prs_struct *ps, int depth)
5041 if (q_u == NULL)
5042 return False;
5044 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5045 depth++;
5047 if(!prs_align(ps))
5048 return False;
5050 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5051 return False;
5053 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5054 return False;
5055 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5056 return False;
5058 if(!prs_align(ps))
5059 return False;
5060 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5061 return False;
5062 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5063 return False;
5065 return True;
5068 /*******************************************************************
5069 reads or writes a structure.
5070 ********************************************************************/
5072 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5073 prs_struct *ps, int depth)
5075 if (r_u == NULL)
5076 return False;
5078 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5079 depth++;
5081 if(!prs_align(ps))
5082 return False;
5084 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5085 return False;
5087 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5088 return False;
5089 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5090 return False;
5091 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5092 return False;
5094 return True;
5097 /*******************************************************************
5098 inits a SAMR_Q_QUERY_USERINFO structure.
5099 ********************************************************************/
5101 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5102 POLICY_HND *hnd, uint16 switch_value)
5104 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5106 q_u->pol = *hnd;
5107 q_u->switch_value = switch_value;
5110 /*******************************************************************
5111 reads or writes a structure.
5112 ********************************************************************/
5114 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5115 prs_struct *ps, int depth)
5117 if (q_u == NULL)
5118 return False;
5120 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5121 depth++;
5123 if(!prs_align(ps))
5124 return False;
5126 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5127 return False;
5129 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5130 return False;
5132 return True;
5135 /*******************************************************************
5136 reads or writes a LOGON_HRS structure.
5137 ********************************************************************/
5139 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5140 prs_struct *ps, int depth)
5142 if (hrs == NULL)
5143 return False;
5145 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5146 depth++;
5148 if(!prs_align(ps))
5149 return False;
5151 if(!prs_uint32("len ", ps, depth, &hrs->len))
5152 return False;
5154 if (hrs->len > sizeof(hrs->hours)) {
5155 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5156 hrs->len = sizeof(hrs->hours);
5159 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5160 return False;
5162 return True;
5165 /*******************************************************************
5166 inits a SAM_USER_INFO_12 structure.
5167 ********************************************************************/
5169 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5170 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5172 DEBUG(5, ("init_sam_user_info12\n"));
5174 usr->lm_pwd_active =
5175 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5176 usr->nt_pwd_active =
5177 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5180 /*******************************************************************
5181 reads or writes a structure.
5182 ********************************************************************/
5184 static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u,
5185 prs_struct *ps, int depth)
5187 if (u == NULL)
5188 return False;
5190 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5191 depth++;
5193 if(!prs_align(ps))
5194 return False;
5196 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5197 return False;
5198 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5199 return False;
5201 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5202 return False;
5203 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5204 return False;
5206 return True;
5209 /*******************************************************************
5210 inits a SAM_USER_INFO_7 structure.
5211 ********************************************************************/
5213 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5215 DEBUG(5, ("init_sam_user_info7\n"));
5217 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5218 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5222 /*******************************************************************
5223 reads or writes a structure.
5224 ********************************************************************/
5226 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5227 prs_struct *ps, int depth)
5229 if (usr == NULL)
5230 return False;
5232 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5233 depth++;
5235 if(!prs_align(ps))
5236 return False;
5238 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5239 return False;
5241 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5242 return False;
5244 return True;
5247 /*******************************************************************
5248 inits a SAM_USER_INFO_10 structure.
5249 ********************************************************************/
5251 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5253 DEBUG(5, ("init_sam_user_info10\n"));
5255 usr->acb_info = acb_info;
5258 /*******************************************************************
5259 reads or writes a structure.
5260 ********************************************************************/
5262 static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr,
5263 prs_struct *ps, int depth)
5265 if (usr == NULL)
5266 return False;
5268 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5269 depth++;
5271 if(!prs_align(ps))
5272 return False;
5274 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5275 return False;
5277 return True;
5280 /*******************************************************************
5281 inits a SAM_USER_INFO_11 structure.
5282 ********************************************************************/
5284 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5285 NTTIME * expiry,
5286 char *mach_acct,
5287 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5289 DEBUG(5, ("init_sam_user_info11\n"));
5291 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5292 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5294 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5296 usr->ptr_1 = 1; /* pointer */
5297 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5298 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5300 usr->ptr_2 = 1; /* pointer */
5301 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5303 usr->ptr_3 = 1; /* pointer */
5304 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5306 usr->rid_user = rid_user;
5307 usr->rid_group = rid_group;
5309 usr->acct_ctrl = acct_ctrl;
5310 usr->unknown_3 = 0x0000;
5312 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5313 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5315 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5316 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5318 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5319 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5322 /*******************************************************************
5323 reads or writes a structure.
5324 ********************************************************************/
5326 static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr,
5327 prs_struct *ps, int depth)
5329 if (usr == NULL)
5330 return False;
5332 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5333 depth++;
5335 if(!prs_align(ps))
5336 return False;
5338 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5339 return False;
5341 if(!smb_io_time("time", &usr->expiry, ps, depth))
5342 return False;
5344 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5345 return False;
5347 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5348 return False;
5350 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5351 return False;
5353 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5354 return False;
5355 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5356 return False;
5358 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5359 return False;
5361 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5362 return False;
5363 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5364 return False;
5366 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5367 return False;
5368 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5369 return False;
5371 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5372 return False;
5373 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5374 return False;
5375 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5376 return False;
5377 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5378 return False;
5379 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5380 return False;
5381 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5382 return False;
5384 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5385 return False;
5387 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5388 return False;
5390 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5391 return False;
5393 if(!prs_align(ps))
5394 return False;
5396 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5397 return False;
5399 return True;
5402 /*************************************************************************
5403 init_sam_user_infoa
5404 *************************************************************************/
5406 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5408 DEBUG(10, ("init_sam_user_info24:\n"));
5409 memcpy(usr->pass, newpass, sizeof(usr->pass));
5410 usr->pw_len = pw_len;
5413 /*******************************************************************
5414 reads or writes a structure.
5415 ********************************************************************/
5417 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5418 prs_struct *ps, int depth)
5420 if (usr == NULL)
5421 return False;
5423 prs_debug(ps, depth, desc, "sam_io_user_info24");
5424 depth++;
5426 if(!prs_align(ps))
5427 return False;
5429 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5430 sizeof(usr->pass)))
5431 return False;
5433 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5434 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5435 return False;
5437 if(!prs_align(ps))
5438 return False;
5440 return True;
5443 /*************************************************************************
5444 init_sam_user_info23
5446 unknown_6 = 0x0000 04ec
5448 *************************************************************************/
5450 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5451 NTTIME * logoff_time, /* all zeros */
5452 NTTIME * kickoff_time, /* all zeros */
5453 NTTIME * pass_last_set_time, /* all zeros */
5454 NTTIME * pass_can_change_time, /* all zeros */
5455 NTTIME * pass_must_change_time, /* all zeros */
5456 UNISTR2 *user_name,
5457 UNISTR2 *full_name,
5458 UNISTR2 *home_dir,
5459 UNISTR2 *dir_drive,
5460 UNISTR2 *log_scr,
5461 UNISTR2 *prof_path,
5462 UNISTR2 *desc,
5463 UNISTR2 *wkstas,
5464 UNISTR2 *unk_str,
5465 UNISTR2 *mung_dial,
5466 uint32 user_rid, /* 0x0000 0000 */
5467 uint32 group_rid,
5468 uint32 acb_info,
5469 uint32 fields_present,
5470 uint16 logon_divs,
5471 LOGON_HRS * hrs,
5472 uint16 bad_password_count,
5473 uint16 logon_count,
5474 char newpass[516], uint32 unknown_6)
5476 usr->logon_time = *logon_time; /* all zeros */
5477 usr->logoff_time = *logoff_time; /* all zeros */
5478 usr->kickoff_time = *kickoff_time; /* all zeros */
5479 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5480 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5481 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5483 ZERO_STRUCT(usr->nt_pwd);
5484 ZERO_STRUCT(usr->lm_pwd);
5486 usr->user_rid = user_rid; /* 0x0000 0000 */
5487 usr->group_rid = group_rid;
5488 usr->acb_info = acb_info;
5489 usr->fields_present = fields_present; /* 09f8 27fa */
5491 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5492 usr->ptr_logon_hrs = hrs ? 1 : 0;
5494 if (nt_time_is_zero(pass_must_change_time)) {
5495 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5496 } else {
5497 usr->passmustchange=0;
5500 ZERO_STRUCT(usr->padding1);
5501 ZERO_STRUCT(usr->padding2);
5503 usr->bad_password_count = bad_password_count;
5504 usr->logon_count = logon_count;
5506 memcpy(usr->pass, newpass, sizeof(usr->pass));
5508 copy_unistr2(&usr->uni_user_name, user_name);
5509 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5511 copy_unistr2(&usr->uni_full_name, full_name);
5512 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5514 copy_unistr2(&usr->uni_home_dir, home_dir);
5515 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5517 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5518 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5520 copy_unistr2(&usr->uni_logon_script, log_scr);
5521 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5523 copy_unistr2(&usr->uni_profile_path, prof_path);
5524 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5526 copy_unistr2(&usr->uni_acct_desc, desc);
5527 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5529 copy_unistr2(&usr->uni_workstations, wkstas);
5530 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5532 copy_unistr2(&usr->uni_unknown_str, unk_str);
5533 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5535 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5536 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5538 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5539 usr->padding4 = 0;
5541 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5544 /*************************************************************************
5545 init_sam_user_info23
5547 unknown_6 = 0x0000 04ec
5549 *************************************************************************/
5551 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5552 NTTIME * logoff_time, /* all zeros */
5553 NTTIME * kickoff_time, /* all zeros */
5554 NTTIME * pass_last_set_time, /* all zeros */
5555 NTTIME * pass_can_change_time, /* all zeros */
5556 NTTIME * pass_must_change_time, /* all zeros */
5557 char *user_name, /* NULL */
5558 char *full_name,
5559 char *home_dir, char *dir_drive, char *log_scr,
5560 char *prof_path, const char *desc, char *wkstas,
5561 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5562 uint32 group_rid, uint32 acb_info,
5563 uint32 fields_present, uint16 logon_divs,
5564 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5565 char newpass[516], uint32 unknown_6)
5567 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5569 usr->logon_time = *logon_time; /* all zeros */
5570 usr->logoff_time = *logoff_time; /* all zeros */
5571 usr->kickoff_time = *kickoff_time; /* all zeros */
5572 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5573 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5574 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5576 ZERO_STRUCT(usr->nt_pwd);
5577 ZERO_STRUCT(usr->lm_pwd);
5579 usr->user_rid = user_rid; /* 0x0000 0000 */
5580 usr->group_rid = group_rid;
5581 usr->acb_info = acb_info;
5582 usr->fields_present = fields_present; /* 09f8 27fa */
5584 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5585 usr->ptr_logon_hrs = hrs ? 1 : 0;
5587 if (nt_time_is_zero(pass_must_change_time)) {
5588 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5589 } else {
5590 usr->passmustchange=0;
5593 ZERO_STRUCT(usr->padding1);
5594 ZERO_STRUCT(usr->padding2);
5596 usr->bad_password_count = bad_password_count;
5597 usr->logon_count = logon_count;
5599 memcpy(usr->pass, newpass, sizeof(usr->pass));
5601 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5602 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5604 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5605 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5607 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5608 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5610 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5611 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5613 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5614 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5616 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5617 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5619 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5620 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5622 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5623 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5625 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5626 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5628 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5629 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5631 data_blob_free(&blob);
5633 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5634 usr->padding4 = 0;
5636 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5639 /*******************************************************************
5640 reads or writes a structure.
5641 ********************************************************************/
5643 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5644 prs_struct *ps, int depth)
5646 if (usr == NULL)
5647 return False;
5649 prs_debug(ps, depth, desc, "sam_io_user_info23");
5650 depth++;
5652 if(!prs_align(ps))
5653 return False;
5655 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5656 return False;
5657 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5658 return False;
5659 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5660 return False;
5661 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5662 return False;
5663 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5664 return False;
5665 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5666 return False;
5668 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5669 return False;
5670 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5671 return False;
5672 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5673 return False;
5674 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5675 return False;
5676 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5677 return False;
5678 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5679 return False;
5680 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5681 return False;
5682 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5683 return False;
5684 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5685 return False;
5686 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5687 return False;
5689 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5690 return False;
5691 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5692 return False;
5694 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5695 return False;
5696 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5697 return False;
5698 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5699 return False;
5701 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5702 return False;
5703 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5704 return False;
5705 if(!prs_align(ps))
5706 return False;
5707 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5708 return False;
5710 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5711 return False;
5712 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5713 return False;
5715 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5716 return False;
5717 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5718 return False;
5719 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5720 return False;
5723 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5724 return False;
5726 /* here begins pointed-to data */
5728 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5729 return False;
5731 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5732 return False;
5734 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5735 return False;
5737 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5738 return False;
5740 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5741 return False;
5743 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5744 return False;
5746 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5747 return False;
5749 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5750 return False;
5752 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5753 return False;
5755 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5756 return False;
5758 /* ok, this is only guess-work (as usual) */
5759 if (usr->ptr_logon_hrs) {
5760 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5761 return False;
5762 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5763 return False;
5764 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5765 return False;
5766 } else if (UNMARSHALLING(ps)) {
5767 usr->unknown_6 = 0;
5768 usr->padding4 = 0;
5771 return True;
5774 /*******************************************************************
5775 reads or writes a structure.
5776 NB. This structure is *definately* incorrect. It's my best guess
5777 currently for W2K SP2. The password field is encrypted in a different
5778 way than normal... And there are definately other problems. JRA.
5779 ********************************************************************/
5781 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5783 if (usr == NULL)
5784 return False;
5786 prs_debug(ps, depth, desc, "sam_io_user_info25");
5787 depth++;
5789 if(!prs_align(ps))
5790 return False;
5792 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5793 return False;
5794 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5795 return False;
5796 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5797 return False;
5798 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5799 return False;
5800 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5801 return False;
5802 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5803 return False;
5805 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5806 return False;
5807 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5808 return False;
5809 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5810 return False;
5811 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5812 return False;
5813 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5814 return False;
5815 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5816 return False;
5817 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5818 return False;
5819 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5820 return False;
5821 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5822 return False;
5823 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5824 return False;
5826 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5827 return False;
5828 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5829 return False;
5831 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5832 return False;
5833 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5834 return False;
5835 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5836 return False;
5838 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5839 return False;
5841 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5842 return False;
5844 /* here begins pointed-to data */
5846 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5847 return False;
5849 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5850 return False;
5852 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5853 return False;
5855 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5856 return False;
5858 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5859 return False;
5861 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5862 return False;
5864 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5865 return False;
5867 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5868 return False;
5870 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5871 return False;
5873 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5874 return False;
5876 #if 0 /* JRA - unknown... */
5877 /* ok, this is only guess-work (as usual) */
5878 if (usr->ptr_logon_hrs) {
5879 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5880 return False;
5881 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5882 return False;
5883 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5884 return False;
5885 } else if (UNMARSHALLING(ps)) {
5886 usr->unknown_6 = 0;
5887 usr->padding4 = 0;
5889 #endif
5891 return True;
5895 /*************************************************************************
5896 init_sam_user_info21W
5898 unknown_6 = 0x0000 04ec
5900 *************************************************************************/
5902 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5903 NTTIME * logon_time,
5904 NTTIME * logoff_time,
5905 NTTIME * kickoff_time,
5906 NTTIME * pass_last_set_time,
5907 NTTIME * pass_can_change_time,
5908 NTTIME * pass_must_change_time,
5909 UNISTR2 *user_name,
5910 UNISTR2 *full_name,
5911 UNISTR2 *home_dir,
5912 UNISTR2 *dir_drive,
5913 UNISTR2 *log_scr,
5914 UNISTR2 *prof_path,
5915 UNISTR2 *desc,
5916 UNISTR2 *wkstas,
5917 UNISTR2 *unk_str,
5918 UNISTR2 *mung_dial,
5919 uchar lm_pwd[16],
5920 uchar nt_pwd[16],
5921 uint32 user_rid,
5922 uint32 group_rid,
5923 uint32 acb_info,
5924 uint32 fields_present,
5925 uint16 logon_divs,
5926 LOGON_HRS * hrs,
5927 uint16 bad_password_count,
5928 uint16 logon_count,
5929 uint32 unknown_6)
5931 usr->logon_time = *logon_time;
5932 usr->logoff_time = *logoff_time;
5933 usr->kickoff_time = *kickoff_time;
5934 usr->pass_last_set_time = *pass_last_set_time;
5935 usr->pass_can_change_time = *pass_can_change_time;
5936 usr->pass_must_change_time = *pass_must_change_time;
5938 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5939 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5941 usr->user_rid = user_rid;
5942 usr->group_rid = group_rid;
5943 usr->acb_info = acb_info;
5944 usr->fields_present = fields_present; /* 0x00ff ffff */
5946 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5947 usr->ptr_logon_hrs = hrs ? 1 : 0;
5948 usr->bad_password_count = bad_password_count;
5949 usr->logon_count = logon_count;
5951 if (nt_time_is_zero(pass_must_change_time)) {
5952 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5953 } else {
5954 usr->passmustchange=0;
5957 ZERO_STRUCT(usr->padding1);
5958 ZERO_STRUCT(usr->padding2);
5960 copy_unistr2(&usr->uni_user_name, user_name);
5961 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5963 copy_unistr2(&usr->uni_full_name, full_name);
5964 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5966 copy_unistr2(&usr->uni_home_dir, home_dir);
5967 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5969 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5970 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5972 copy_unistr2(&usr->uni_logon_script, log_scr);
5973 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5975 copy_unistr2(&usr->uni_profile_path, prof_path);
5976 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5978 copy_unistr2(&usr->uni_acct_desc, desc);
5979 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5981 copy_unistr2(&usr->uni_workstations, wkstas);
5982 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5984 copy_unistr2(&usr->uni_unknown_str, unk_str);
5985 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5987 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5988 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5990 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5991 usr->padding4 = 0;
5993 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5996 /*************************************************************************
5997 init_sam_user_info21
5999 unknown_6 = 0x0000 04ec
6001 *************************************************************************/
6003 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
6005 NTTIME logon_time, logoff_time, kickoff_time,
6006 pass_last_set_time, pass_can_change_time,
6007 pass_must_change_time;
6009 const char* user_name = pdb_get_username(pw);
6010 const char* full_name = pdb_get_fullname(pw);
6011 const char* home_dir = pdb_get_homedir(pw);
6012 const char* dir_drive = pdb_get_dir_drive(pw);
6013 const char* logon_script = pdb_get_logon_script(pw);
6014 const char* profile_path = pdb_get_profile_path(pw);
6015 const char* description = pdb_get_acct_desc(pw);
6016 const char* workstations = pdb_get_workstations(pw);
6017 const char* munged_dial = pdb_get_munged_dial(pw);
6018 DATA_BLOB munged_dial_blob;
6020 uint32 user_rid;
6021 const DOM_SID *user_sid;
6023 uint32 group_rid;
6024 const DOM_SID *group_sid;
6026 if (munged_dial) {
6027 munged_dial_blob = base64_decode_data_blob(munged_dial);
6028 } else {
6029 munged_dial_blob = data_blob(NULL, 0);
6032 /* Create NTTIME structs */
6033 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6034 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6035 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6036 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6037 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6038 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6040 /* structure assignment */
6041 usr->logon_time = logon_time;
6042 usr->logoff_time = logoff_time;
6043 usr->kickoff_time = kickoff_time;
6044 usr->pass_last_set_time = pass_last_set_time;
6045 usr->pass_can_change_time = pass_can_change_time;
6046 usr->pass_must_change_time = pass_must_change_time;
6048 ZERO_STRUCT(usr->nt_pwd);
6049 ZERO_STRUCT(usr->lm_pwd);
6051 user_sid = pdb_get_user_sid(pw);
6053 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6054 fstring user_sid_string;
6055 fstring domain_sid_string;
6056 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6057 "the domain sid %s. Failing operation.\n",
6058 user_name,
6059 sid_to_string(user_sid_string, user_sid),
6060 sid_to_string(domain_sid_string, domain_sid)));
6061 data_blob_free(&munged_dial_blob);
6062 return NT_STATUS_UNSUCCESSFUL;
6065 group_sid = pdb_get_group_sid(pw);
6067 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6068 fstring group_sid_string;
6069 fstring domain_sid_string;
6070 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6071 "which conflicts with the domain sid %s. Failing operation.\n",
6072 user_name,
6073 sid_to_string(group_sid_string, group_sid),
6074 sid_to_string(domain_sid_string, domain_sid)));
6075 data_blob_free(&munged_dial_blob);
6076 return NT_STATUS_UNSUCCESSFUL;
6079 usr->user_rid = user_rid;
6080 usr->group_rid = group_rid;
6081 usr->acb_info = pdb_get_acct_ctrl(pw);
6084 Look at a user on a real NT4 PDC with usrmgr, press
6085 'ok'. Then you will see that fields_present is set to
6086 0x08f827fa. Look at the user immediately after that again,
6087 and you will see that 0x00fffff is returned. This solves
6088 the problem that you get access denied after having looked
6089 at the user.
6090 -- Volker
6092 usr->fields_present = pdb_build_fields_present(pw);
6094 usr->logon_divs = pdb_get_logon_divs(pw);
6095 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6096 usr->bad_password_count = pdb_get_bad_password_count(pw);
6097 usr->logon_count = pdb_get_logon_count(pw);
6099 if (pdb_get_pass_must_change_time(pw) == 0) {
6100 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6101 } else {
6102 usr->passmustchange=0;
6105 ZERO_STRUCT(usr->padding1);
6106 ZERO_STRUCT(usr->padding2);
6108 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6109 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6111 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6112 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6114 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6115 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6117 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6118 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6120 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6121 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6123 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6124 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6126 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6127 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6129 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6130 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6132 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6133 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6135 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6136 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6137 data_blob_free(&munged_dial_blob);
6139 usr->unknown_6 = pdb_get_unknown_6(pw);
6140 usr->padding4 = 0;
6142 if (pdb_get_hours(pw)) {
6143 usr->logon_hrs.len = pdb_get_hours_len(pw);
6144 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6145 } else
6146 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6148 return NT_STATUS_OK;
6151 /*******************************************************************
6152 reads or writes a structure.
6153 ********************************************************************/
6155 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6156 prs_struct *ps, int depth)
6158 if (usr == NULL)
6159 return False;
6161 prs_debug(ps, depth, desc, "sam_io_user_info21");
6162 depth++;
6164 if(!prs_align(ps))
6165 return False;
6167 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6168 return False;
6169 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6170 return False;
6171 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6172 return False;
6173 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6174 return False;
6175 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6176 return False;
6177 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6178 return False;
6180 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6181 return False;
6182 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6183 return False;
6184 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6185 return False;
6186 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6187 return False;
6188 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6189 return False;
6190 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6191 return False;
6192 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6193 return False;
6194 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6195 return False;
6196 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6197 return False;
6198 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6199 return False;
6201 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6202 return False;
6203 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6204 return False;
6206 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6207 return False;
6208 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6209 return False;
6210 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6211 return False;
6213 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6214 return False;
6215 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6216 return False;
6217 if(!prs_align(ps))
6218 return False;
6219 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6220 return False;
6222 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6223 return False;
6224 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6225 return False;
6227 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6228 return False;
6229 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6230 return False;
6231 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6232 return False;
6234 /* here begins pointed-to data */
6236 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6237 return False;
6238 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6239 return False;
6240 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6241 return False;
6242 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6243 return False;
6244 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6245 return False;
6246 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6247 return False;
6248 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6249 return False;
6250 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6251 return False;
6252 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6253 return False;
6254 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6255 return False;
6257 /* ok, this is only guess-work (as usual) */
6258 if (usr->ptr_logon_hrs) {
6259 if(!prs_align(ps))
6260 return False;
6261 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6262 return False;
6263 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6264 return False;
6265 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6266 return False;
6267 } else if (UNMARSHALLING(ps)) {
6268 usr->unknown_6 = 0;
6269 usr->padding4 = 0;
6272 return True;
6275 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6277 const char *munged_dial = pdb_get_munged_dial(pw);
6278 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6280 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6281 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6282 data_blob_free(&blob);
6285 /*******************************************************************
6286 reads or writes a structure.
6287 ********************************************************************/
6289 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6290 prs_struct *ps, int depth)
6292 if (usr == NULL)
6293 return False;
6295 prs_debug(ps, depth, desc, "sam_io_user_info20");
6296 depth++;
6298 if(!prs_align(ps))
6299 return False;
6301 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6302 return False;
6304 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6305 return False;
6307 return True;
6310 /*******************************************************************
6311 inits a SAM_USERINFO_CTR structure.
6312 ********************************************************************/
6314 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6315 uint16 switch_value,
6316 SAM_USER_INFO_21 * usr)
6318 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6320 ctr->switch_value = switch_value;
6321 ctr->info.id = NULL;
6323 switch (switch_value) {
6324 case 0x10:
6325 ctr->info.id10 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_10);
6326 if (ctr->info.id10 == NULL)
6327 return NT_STATUS_NO_MEMORY;
6329 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6330 break;
6331 #if 0
6332 /* whoops - got this wrong. i think. or don't understand what's happening. */
6333 case 0x11:
6335 NTTIME expire;
6336 info = (void *)&id11;
6338 expire.low = 0xffffffff;
6339 expire.high = 0x7fffffff;
6341 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_11);
6342 init_sam_user_info11(ctr->info.id11, &expire,
6343 "BROOKFIELDS$", /* name */
6344 0x03ef, /* user rid */
6345 0x201, /* group rid */
6346 0x0080); /* acb info */
6348 break;
6350 #endif
6351 case 0x12:
6352 ctr->info.id12 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_12);
6353 if (ctr->info.id12 == NULL)
6354 return NT_STATUS_NO_MEMORY;
6356 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6357 break;
6358 case 21:
6360 SAM_USER_INFO_21 *cusr;
6361 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6362 ctr->info.id21 = cusr;
6363 if (ctr->info.id21 == NULL)
6364 return NT_STATUS_NO_MEMORY;
6365 memcpy(cusr, usr, sizeof(*usr));
6366 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6367 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6368 break;
6370 default:
6371 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6372 return NT_STATUS_INVALID_INFO_CLASS;
6375 return NT_STATUS_OK;
6378 /*******************************************************************
6379 inits a SAM_USERINFO_CTR structure.
6380 ********************************************************************/
6382 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6383 uint16 switch_value, void *info)
6385 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6387 ctr->switch_value = switch_value;
6388 ctr->info.id = info;
6390 switch (switch_value) {
6391 case 0x18:
6392 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6393 dump_data(100, (char *)sess_key->data, sess_key->length);
6394 dump_data(100, (char *)ctr->info.id24->pass, 516);
6395 break;
6396 case 0x17:
6397 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6398 dump_data(100, (char *)sess_key->data, sess_key->length);
6399 dump_data(100, (char *)ctr->info.id23->pass, 516);
6400 break;
6401 case 0x07:
6402 break;
6403 default:
6404 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6408 /*******************************************************************
6409 reads or writes a structure.
6410 ********************************************************************/
6412 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6413 prs_struct *ps, int depth)
6415 BOOL ret;
6416 SAM_USERINFO_CTR *ctr;
6418 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6419 depth++;
6421 if (UNMARSHALLING(ps)) {
6422 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6423 if (ctr == NULL)
6424 return False;
6425 *ppctr = ctr;
6426 } else {
6427 ctr = *ppctr;
6430 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6432 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6433 return False;
6434 if(!prs_align(ps))
6435 return False;
6437 ret = False;
6439 switch (ctr->switch_value) {
6440 case 0x07:
6441 if (UNMARSHALLING(ps))
6442 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6443 if (ctr->info.id7 == NULL) {
6444 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6445 return False;
6447 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6448 break;
6449 case 0x10:
6450 if (UNMARSHALLING(ps))
6451 ctr->info.id10 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_10,1);
6452 if (ctr->info.id10 == NULL) {
6453 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6454 return False;
6456 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6457 break;
6458 case 0x11:
6459 if (UNMARSHALLING(ps))
6460 ctr->info.id11 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_11,1);
6462 if (ctr->info.id11 == NULL) {
6463 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6464 return False;
6466 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6467 break;
6468 case 0x12:
6469 if (UNMARSHALLING(ps))
6470 ctr->info.id12 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_12,1);
6472 if (ctr->info.id12 == NULL) {
6473 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6474 return False;
6476 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6477 break;
6478 case 20:
6479 if (UNMARSHALLING(ps))
6480 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6482 if (ctr->info.id20 == NULL) {
6483 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6484 return False;
6486 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6487 break;
6488 case 21:
6489 if (UNMARSHALLING(ps))
6490 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6492 if (ctr->info.id21 == NULL) {
6493 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6494 return False;
6496 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6497 break;
6498 case 23:
6499 if (UNMARSHALLING(ps))
6500 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6502 if (ctr->info.id23 == NULL) {
6503 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6504 return False;
6506 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6507 break;
6508 case 24:
6509 if (UNMARSHALLING(ps))
6510 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6512 if (ctr->info.id24 == NULL) {
6513 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6514 return False;
6516 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6517 break;
6518 case 25:
6519 if (UNMARSHALLING(ps))
6520 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6522 if (ctr->info.id25 == NULL) {
6523 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6524 return False;
6526 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6527 break;
6528 default:
6529 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6530 ret = False;
6531 break;
6534 return ret;
6537 /*******************************************************************
6538 inits a SAMR_R_QUERY_USERINFO structure.
6539 ********************************************************************/
6541 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6542 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6544 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6546 r_u->ptr = 0;
6547 r_u->ctr = NULL;
6549 if (NT_STATUS_IS_OK(status)) {
6550 r_u->ptr = 1;
6551 r_u->ctr = ctr;
6554 r_u->status = status; /* return status */
6557 /*******************************************************************
6558 reads or writes a structure.
6559 ********************************************************************/
6561 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6562 prs_struct *ps, int depth)
6564 if (r_u == NULL)
6565 return False;
6567 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6568 depth++;
6570 if(!prs_align(ps))
6571 return False;
6573 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6574 return False;
6576 if (r_u->ptr != 0) {
6577 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6578 return False;
6581 if(!prs_align(ps))
6582 return False;
6583 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6584 return False;
6586 return True;
6589 /*******************************************************************
6590 inits a SAMR_Q_SET_USERINFO structure.
6591 ********************************************************************/
6593 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6594 POLICY_HND *hnd, DATA_BLOB *sess_key,
6595 uint16 switch_value, void *info)
6597 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6599 q_u->pol = *hnd;
6600 q_u->switch_value = switch_value;
6601 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6604 /*******************************************************************
6605 reads or writes a structure.
6606 ********************************************************************/
6608 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6609 prs_struct *ps, int depth)
6611 if (q_u == NULL)
6612 return False;
6614 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6615 depth++;
6617 if(!prs_align(ps))
6618 return False;
6620 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6622 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6623 return False;
6624 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6625 return False;
6627 return True;
6630 /*******************************************************************
6631 inits a SAMR_R_SET_USERINFO structure.
6632 ********************************************************************/
6634 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6636 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6638 r_u->status = status; /* return status */
6641 /*******************************************************************
6642 reads or writes a structure.
6643 ********************************************************************/
6645 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6646 prs_struct *ps, int depth)
6648 if (r_u == NULL)
6649 return False;
6651 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6652 depth++;
6654 if(!prs_align(ps))
6655 return False;
6657 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6658 return False;
6660 return True;
6663 /*******************************************************************
6664 inits a SAMR_Q_SET_USERINFO2 structure.
6665 ********************************************************************/
6667 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6668 POLICY_HND *hnd, DATA_BLOB *sess_key,
6669 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6671 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6673 q_u->pol = *hnd;
6674 q_u->switch_value = switch_value;
6675 q_u->ctr = ctr;
6677 if (q_u->ctr != NULL)
6678 q_u->ctr->switch_value = switch_value;
6680 switch (switch_value) {
6681 case 0x12:
6682 SamOEMhashBlob(ctr->info.id12->lm_pwd, 16, sess_key);
6683 SamOEMhashBlob(ctr->info.id12->nt_pwd, 16, sess_key);
6684 dump_data(100, (char *)sess_key->data, sess_key->length);
6685 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6686 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6687 break;
6691 /*******************************************************************
6692 reads or writes a structure.
6693 ********************************************************************/
6695 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6696 prs_struct *ps, int depth)
6698 if (q_u == NULL)
6699 return False;
6701 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6702 depth++;
6704 if(!prs_align(ps))
6705 return False;
6707 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6708 return False;
6710 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6711 return False;
6712 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6713 return False;
6715 return True;
6718 /*******************************************************************
6719 inits a SAMR_R_SET_USERINFO2 structure.
6720 ********************************************************************/
6722 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6724 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6726 r_u->status = status; /* return status */
6729 /*******************************************************************
6730 reads or writes a structure.
6731 ********************************************************************/
6733 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6734 prs_struct *ps, int depth)
6736 if (r_u == NULL)
6737 return False;
6739 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6740 depth++;
6742 if(!prs_align(ps))
6743 return False;
6745 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6746 return False;
6748 return True;
6751 /*******************************************************************
6752 inits a SAMR_Q_CONNECT structure.
6753 ********************************************************************/
6755 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6756 char *srv_name, uint32 access_mask)
6758 DEBUG(5, ("init_samr_q_connect\n"));
6760 /* make PDC server name \\server */
6761 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6762 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6764 /* example values: 0x0000 0002 */
6765 q_u->access_mask = access_mask;
6768 /*******************************************************************
6769 reads or writes a structure.
6770 ********************************************************************/
6772 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6773 prs_struct *ps, int depth)
6775 if (q_u == NULL)
6776 return False;
6778 prs_debug(ps, depth, desc, "samr_io_q_connect");
6779 depth++;
6781 if(!prs_align(ps))
6782 return False;
6784 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6785 return False;
6786 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6787 return False;
6789 if(!prs_align(ps))
6790 return False;
6791 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6792 return False;
6794 return True;
6797 /*******************************************************************
6798 reads or writes a structure.
6799 ********************************************************************/
6801 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6802 prs_struct *ps, int depth)
6804 if (r_u == NULL)
6805 return False;
6807 prs_debug(ps, depth, desc, "samr_io_r_connect");
6808 depth++;
6810 if(!prs_align(ps))
6811 return False;
6813 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6814 return False;
6816 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6817 return False;
6819 return True;
6822 /*******************************************************************
6823 inits a SAMR_Q_CONNECT4 structure.
6824 ********************************************************************/
6826 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6827 char *srv_name, uint32 access_mask)
6829 DEBUG(5, ("init_samr_q_connect\n"));
6831 /* make PDC server name \\server */
6832 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6833 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6835 /* Only value we've seen, possibly an address type ? */
6836 q_u->unk_0 = 2;
6838 /* example values: 0x0000 0002 */
6839 q_u->access_mask = access_mask;
6842 /*******************************************************************
6843 reads or writes a structure.
6844 ********************************************************************/
6846 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6847 prs_struct *ps, int depth)
6849 if (q_u == NULL)
6850 return False;
6852 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6853 depth++;
6855 if(!prs_align(ps))
6856 return False;
6858 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6859 return False;
6860 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6861 return False;
6863 if(!prs_align(ps))
6864 return False;
6865 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6866 return False;
6867 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6868 return False;
6870 return True;
6873 /*******************************************************************
6874 reads or writes a structure.
6875 ********************************************************************/
6877 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6878 prs_struct *ps, int depth)
6880 if (r_u == NULL)
6881 return False;
6883 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6884 depth++;
6886 if(!prs_align(ps))
6887 return False;
6889 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6890 return False;
6892 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6893 return False;
6895 return True;
6898 /*******************************************************************
6899 inits a SAMR_Q_CONNECT_ANON structure.
6900 ********************************************************************/
6902 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6904 DEBUG(5, ("init_samr_q_connect_anon\n"));
6906 q_u->ptr = 1;
6907 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6908 q_u->unknown_1 = 0x01;
6909 q_u->access_mask = 0x20;
6912 /*******************************************************************
6913 reads or writes a structure.
6914 ********************************************************************/
6916 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6917 prs_struct *ps, int depth)
6919 if (q_u == NULL)
6920 return False;
6922 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6923 depth++;
6925 if(!prs_align(ps))
6926 return False;
6928 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6929 return False;
6930 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6931 return False;
6932 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6933 return False;
6934 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6935 return False;
6937 return True;
6940 /*******************************************************************
6941 reads or writes a structure.
6942 ********************************************************************/
6944 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6945 prs_struct *ps, int depth)
6947 if (r_u == NULL)
6948 return False;
6950 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6951 depth++;
6953 if(!prs_align(ps))
6954 return False;
6956 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6957 return False;
6959 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6960 return False;
6962 return True;
6965 /*******************************************************************
6966 inits a SAMR_Q_GET_DOM_PWINFO structure.
6967 ********************************************************************/
6969 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6970 char *srv_name)
6972 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6974 q_u->ptr = 1;
6975 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
6976 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
6979 /*******************************************************************
6980 reads or writes a structure.
6981 ********************************************************************/
6983 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6984 prs_struct *ps, int depth)
6986 if (q_u == NULL)
6987 return False;
6989 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6990 depth++;
6992 if(!prs_align(ps))
6993 return False;
6995 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6996 return False;
6997 if (q_u->ptr != 0) {
6998 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6999 return False;
7000 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7001 return False;
7004 return True;
7007 /*******************************************************************
7008 reads or writes a structure.
7009 ********************************************************************/
7011 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7012 prs_struct *ps, int depth)
7014 if (r_u == NULL)
7015 return False;
7017 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7018 depth++;
7020 if(!prs_align(ps))
7021 return False;
7024 * see the Samba4 IDL for what these actually are.
7027 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
7028 return False;
7029 if(!prs_align(ps))
7030 return False;
7031 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
7032 return False;
7034 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7035 return False;
7037 return True;
7040 /*******************************************************************
7041 make a SAMR_ENC_PASSWD structure.
7042 ********************************************************************/
7044 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7046 ZERO_STRUCTP(pwd);
7048 if (pass == NULL) {
7049 pwd->ptr = 0;
7050 } else {
7051 pwd->ptr = 1;
7052 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7056 /*******************************************************************
7057 reads or writes a SAMR_ENC_PASSWD structure.
7058 ********************************************************************/
7060 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7061 prs_struct *ps, int depth)
7063 if (pwd == NULL)
7064 return False;
7066 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7067 depth++;
7069 if(!prs_align(ps))
7070 return False;
7072 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7073 return False;
7075 if (pwd->ptr != 0) {
7076 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7077 return False;
7080 return True;
7083 /*******************************************************************
7084 inits a SAMR_ENC_HASH structure.
7085 ********************************************************************/
7087 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7089 ZERO_STRUCTP(hsh);
7091 if (hash == NULL) {
7092 hsh->ptr = 0;
7093 } else {
7094 hsh->ptr = 1;
7095 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7099 /*******************************************************************
7100 reads or writes a SAMR_ENC_HASH structure.
7101 ********************************************************************/
7103 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7104 prs_struct *ps, int depth)
7106 if (hsh == NULL)
7107 return False;
7109 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7110 depth++;
7112 if(!prs_align(ps))
7113 return False;
7115 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7116 return False;
7117 if (hsh->ptr != 0) {
7118 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7119 return False;
7122 return True;
7125 /*******************************************************************
7126 inits a SAMR_R_GET_DOM_PWINFO structure.
7127 ********************************************************************/
7129 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7130 const char *dest_host, const char *user_name,
7131 const char nt_newpass[516],
7132 const uchar nt_oldhash[16],
7133 const char lm_newpass[516],
7134 const uchar lm_oldhash[16])
7136 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7138 q_u->ptr_0 = 1;
7139 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7140 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7142 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7143 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7145 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7146 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7148 q_u->unknown = 0x01;
7150 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7151 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7154 /*******************************************************************
7155 reads or writes a structure.
7156 ********************************************************************/
7158 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7159 prs_struct *ps, int depth)
7161 if (q_u == NULL)
7162 return False;
7164 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7165 depth++;
7167 if(!prs_align(ps))
7168 return False;
7170 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7171 return False;
7173 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7174 return False;
7175 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7176 return False;
7178 if(!prs_align(ps))
7179 return False;
7180 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7181 return False;
7182 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7183 return False;
7185 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7186 return False;
7187 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7188 return False;
7190 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7191 return False;
7193 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7194 return False;
7195 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7196 return False;
7198 return True;
7201 /*******************************************************************
7202 inits a SAMR_R_CHGPASSWD_USER structure.
7203 ********************************************************************/
7205 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7207 DEBUG(5, ("init_r_chgpasswd_user\n"));
7209 r_u->status = status;
7212 /*******************************************************************
7213 reads or writes a structure.
7214 ********************************************************************/
7216 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7217 prs_struct *ps, int depth)
7219 if (r_u == NULL)
7220 return False;
7222 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7223 depth++;
7225 if(!prs_align(ps))
7226 return False;
7228 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7229 return False;
7231 return True;
7234 /*******************************************************************
7235 reads or writes a structure.
7236 ********************************************************************/
7238 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7239 POLICY_HND *domain_pol, uint16 switch_value)
7241 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7243 q_u->domain_pol = *domain_pol;
7244 q_u->switch_value = switch_value;
7247 /*******************************************************************
7248 reads or writes a structure.
7249 ********************************************************************/
7251 BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7252 prs_struct *ps, int depth)
7254 if (q_u == NULL)
7255 return False;
7257 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7258 depth++;
7260 if(!prs_align(ps))
7261 return False;
7263 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7264 return False;
7266 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7267 return False;
7269 return True;
7272 /*******************************************************************
7273 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7274 ********************************************************************/
7276 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7277 uint16 switch_value, SAM_UNK_CTR * ctr,
7278 NTSTATUS status)
7280 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7282 r_u->ptr_0 = 0;
7283 r_u->switch_value = 0;
7284 r_u->status = status; /* return status */
7286 if (NT_STATUS_IS_OK(status)) {
7287 r_u->switch_value = switch_value;
7288 r_u->ptr_0 = 1;
7289 r_u->ctr = ctr;
7293 /*******************************************************************
7294 reads or writes a structure.
7295 ********************************************************************/
7297 BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u,
7298 prs_struct *ps, int depth)
7300 if (r_u == NULL)
7301 return False;
7303 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7304 depth++;
7306 if(!prs_align(ps))
7307 return False;
7309 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7310 return False;
7312 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7313 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7314 return False;
7315 if(!prs_align(ps))
7316 return False;
7318 switch (r_u->switch_value) {
7319 case 0x0c:
7320 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7321 return False;
7322 break;
7323 case 0x07:
7324 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7325 return False;
7326 break;
7327 case 0x06:
7328 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7329 return False;
7330 break;
7331 case 0x05:
7332 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7333 return False;
7334 break;
7335 case 0x03:
7336 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7337 return False;
7338 break;
7339 case 0x02:
7340 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7341 return False;
7342 break;
7343 case 0x01:
7344 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7345 return False;
7346 break;
7347 default:
7348 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7349 r_u->switch_value));
7350 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7351 return False;
7355 if(!prs_align(ps))
7356 return False;
7358 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7359 return False;
7361 return True;
7365 /*******************************************************************
7366 reads or writes a structure.
7367 ********************************************************************/
7369 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7370 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7372 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7374 q_u->domain_pol = *domain_pol;
7375 q_u->switch_value0 = switch_value;
7377 q_u->switch_value = switch_value;
7378 q_u->ctr = ctr;
7382 /*******************************************************************
7383 reads or writes a structure.
7384 ********************************************************************/
7386 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7387 prs_struct *ps, int depth)
7389 if (q_u == NULL)
7390 return False;
7392 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7393 depth++;
7395 if(!prs_align(ps))
7396 return False;
7398 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7399 return False;
7401 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7402 return False;
7404 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7405 return False;
7407 if(!prs_align(ps))
7408 return False;
7410 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7411 return False;
7413 switch (q_u->switch_value) {
7415 case 0x0c:
7416 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7417 return False;
7418 break;
7419 case 0x07:
7420 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7421 return False;
7422 break;
7423 case 0x06:
7424 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7425 return False;
7426 break;
7427 case 0x05:
7428 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7429 return False;
7430 break;
7431 case 0x03:
7432 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7433 return False;
7434 break;
7435 case 0x02:
7436 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7437 return False;
7438 break;
7439 case 0x01:
7440 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7441 return False;
7442 break;
7443 default:
7444 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7445 q_u->switch_value));
7446 return False;
7449 return True;
7452 /*******************************************************************
7453 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7454 ********************************************************************/
7456 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7458 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7460 r_u->status = status; /* return status */
7463 /*******************************************************************
7464 reads or writes a structure.
7465 ********************************************************************/
7467 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7468 prs_struct *ps, int depth)
7470 if (r_u == NULL)
7471 return False;
7473 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7474 depth++;
7476 if(!prs_align(ps))
7477 return False;
7479 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7480 return False;
7482 return True;